Most voted "php-autoload" questions
The autoload function is used in PHP to automatically load classes.
Learn more…35 questions
Sort by count of
-
29
votes2
answers13485
viewsComposer - Autoload and PSR-0 vs PSR-4
I’m starting to study Composer and am developing a system where I separate files from the core of the application files, as follows: / root |-- /src |-- /App |-- /DBConfig |-- /Controller |-- /Model…
-
25
votes2
answers1684
viewsHow does namespaces work in PHP?
The namespaces were implemented from PHP version 5.3.0 as a form of "encapsulating items". I never really understood his real concept, and I always get confused with autoload of classes. Could…
-
11
votes5
answers1562
viewsOptimize function to include classes also looking in sub-directories
I have the following function to include classes when we are trying to use a class that has not yet been defined: /** * Attempt to load undefined class * @param object $class_name object class name…
-
5
votes2
answers4997
viewsWhat are the differences between __autoload and spl_autoload_register?
In php, we have two methods of making one autoload class: __autoload function Example: function __autoload($class_name) { require_once $class_name . '.php'; } $obj = new MyClass1(); $obj2 = new…
-
4
votes1
answer6287
viewsUnexpected 'use' (T_USE) error when using autoload
I have the following folder and file structure: -api -v1 -libs -Slim -Facebook -autoload.php -index.php -login.php Inside the "index.php" I do the include of "login.php": require_once 'login.php';…
-
4
votes1
answer5136
views"New" autoload from PHP 7
I would like to understand the "new" autoload of PHP, in it I can choose the name I want to put? For example, in the old one, it was __autoload. That in case, I can put autoload_de_teste ? Another…
-
3
votes1
answer566
viewsHow does [modus operandi] autoload in PHP work?
Suppose I have the following file structure at the root of my site: index.php autoload.php ----| /Models --------| /MainModel ------------| MainModel.php ----| /Controllers --------| /MainController…
-
2
votes1
answer930
viewsAutoload PSR4 class
I would like to create a class of autoload to follow the recommendations of PSR4 which can be used jointly and independently of the autoload of the Composer. The application I’m creating will have…
-
2
votes1
answer245
viewsPoser extends class not found
How to use extends with the Poser autoloade? As it is returns me the following error: Fatal error: Class 'App\Modulos\Mail\Mail' not found in ...Google.php on line 7 Composer: "autoload": { "psr-4":…
-
2
votes1
answer2964
viewsDoes Poser autoload not work?
I’m trying to use the autoload of composer and I can’t, he says the class not found and trying to load a class from an external library. I’ve already executed on the command line: composer install…
-
2
votes0
answers38
viewsAutoloading does not recognize use command , after a Ubmit?
<?php namespace App\Controller; class Action { function mostrarDado(){ echo "Mostrando…
-
1
votes1
answer319
viewsDoubt about autoload php
About autoload I studied about: Autoload for classes in the same folder function __autoload($nomeClass) { require_once ("$nomeClass.php"); } Autoload for classes in specific folders…
-
1
votes1
answer272
viewsDo php’s autoload functions make an object available to any part of the site in the same session, even in different subdirectories?
I intend to make my code cleaner and therefore avoid using include or include_once all page start. I would not like to use frameworks that already do this work as Windows for example. I want to…
-
1
votes1
answer458
viewsConfigure Namespace and autoload PSR-0
I am developing a project with the following structure: The goal is to make autoload load the classes. The archive autoload.php: function autoload($className) { $className = ltrim($className, '\\');…
-
1
votes0
answers802
viewsError Class not found with Composer
Good people, next, I’m doing a project here and giving me some problems, I think I’m mixing things up. I installed Composer to use autoload and other dependencies, but now I have a problem: The…
-
1
votes2
answers78
viewsAutoload does not find PSR-0 class
I made an application using Poser with autload, configured the file Composer.js and set the namespace correctly, but when executing the code one of the classes is not found generating the error…
-
0
votes1
answer340
viewsPHP Moip class autoloader
How do I make this require 'vendor/autoload.php', it does not come in the documentation. <?php require 'vendor/autoload.php'; use Moip\Moip; use Moip\MoipBasicAuth; $endpoint =…
-
0
votes0
answers35
viewsHow to use namespace when creating a class?
I’m working on a project that was created in php (5.3) without a framework. I need to use a database connection class I developed myself. The name of this class shall be db, but another class db…
-
0
votes1
answer56
viewsCan you list all namespaces from a specific one?
I need to instantiate a class by just passing her name and trying to instantiate her at several different nemapaces until I do. The Framework does not accept instantiating any class without the…
-
0
votes0
answers122
viewsMigration problem from PSR-0 to PSR-4
I’m new here but I’ve been programming for over 10 years in PHP and I’ve been programming Object Oriented for a short time. Doing some tests I saw that the PSR-0 is deprecated and then a project of…
-
0
votes1
answer132
viewsAuto load of multiple directories
I have these functions: core/init.php: ... spl_autoload_register(function($class) { require_once ('libs/'.$class.'.php'); }); --- controllers/Images_controller.php require_once "core/init.php";…
-
0
votes0
answers83
viewsProblem with Composer - PSR-4
I am studying Composer and its autoload forms (classmap, file, psr-0, psr-4), but in my example it is appearing with the following error: Fatal error: Class 'Library\Exemplo' not found…
-
0
votes1
answer185
viewsTest autoload problem with Phpunit and Composer on Windows
I’m having a problem with the Composer on Windows 7. I developed a project with the following structure: Simpla_HTML |--/src | |--/Simpla | |--/Html | |--/Element.php /---tests | |--/Simpla |…
-
0
votes0
answers279
viewsAutoload problems in PHP
I have the following autoload function of classes on my system, it is working perfectly on localhost, but when I went up to the server it gave error when including the class Line error: 47 :: Could…
-
0
votes1
answer133
viewsAutoload controllers using namespace
I’m trying to give a restructured in a personal microframework, before not used much standard in the structure of the project, now I played all my back-end in the folder source, and I’m using…
-
0
votes0
answers216
viewsPDO class not found in namespace other than global
I’m creating a class that uses PDO, but in a different namespace than global: namespace Classes\Config; use \PDO; class Connection { public static function getConnection() { $dbhost = "algumhost";…
-
0
votes0
answers41
viewsProblems optimizing autoload login system
I did an optimization in the login and as I had problems with directory I decided to search the web and found a nice PHP resource that is the autoload. I did all the implementation according to the…
-
0
votes0
answers280
viewsProblem in Autoload PHP
I’m starting to POO and SPL and recently faced the following problem: I have the following file that makes the whole bootstrapping of my application init.php, and in it, I do the autoload of all…
-
0
votes2
answers1437
viewsAutoload Composer class not found
Good afternoon! I have a problem and do not know how to solve, creating a mini application, using the autoload of Composer, but is not working, is giving that class does not exist. This is my…
-
0
votes0
answers105
viewsClasses of autoload Composer do not work
I’m using the composer to manage the classes of my project, in the archive composer.json defined the folders, in the classes I put their respective namespaces, but I can’t use them in other files.…
-
0
votes1
answer79
viewsComposer autoload
I’m having trouble in hr adding a class to my autoload, keeps giving Class Routes not found! Could someone help me? Composer.json "autoload": { "psr-4": { "App\\Http\\Controllers\\":…
-
0
votes1
answer249
viewsProblem with PSR-4 and Poser autoload
I’m having a problem with Poser’s autoload, the structure and code are all right, only he’s not finding the class. I’ve already updated the autoloads by bash and nothing... anyone knows what it…
-
0
votes0
answers96
viewsspl_autoload_register does not work
I am developing a system in mvc. Developing locally, everything worked correctly... But when I put it online to be able to test, it just didn’t load, it was 500. So I started trying to find the…
-
0
votes0
answers17
viewsProblem loading Composer class to web server
I’m having trouble correctly running a site developed with the MVC architecture on web server. Locally, everything is going well. The folder structure is as follows: public_html(public directory of…
php commiserate server-side php-autoload internal-server-errorasked 3 years, 11 months ago ademir moreira 1 -
-2
votes1
answer302
viewsNeed to install Composer on the server?
I’m studying php and learning how to use autoload and Composer. I got a server to use during my studies. The server must be installed for autoload to work?