I try to use composer autoload but I get this error
composer.json
{
"autoload":{
"psr-4":{
"App\\":"app/"
},
"files": ["app/functions/helper.php"]
},
"require": {
"vlucas/phpdotenv": "^2.4",
"altorouter/altorouter": "^1.2",
"philo/laravel-blade": "^3.1"
},
"config":{
"optimize-autoloader":true
}
}
my terminal output
Generating optimized autoload files
Class App\Controllers\BaseController located in D:/php/Xamp/htdocs/MVC_PHP/app\controllers\BaseController.php does not comply with psr-4 autoloading standard. Skipping.
Class App\Controllers\IndexControllers located in D:/php/Xamp/htdocs/MVC_PHP/app\controllers\IndexControllers.php does not comply with psr-4 autoloading standard. Skipping.
Class App\RoutingDispatcher located in D:/php/Xamp/htdocs/MVC_PHP/app\routing\RoutingDispatcher.php does not comply with psr-4 autoloading standard. Skipping.
Generated optimized autoload files containing 508 classes
This PSR describes a specification for autoloading classes from file paths. It is fully interoperable, and can be used in addition to any other autoloading specification, including PSR-0. This PSR also describes where to place files that will be autoloaded according to the specification.
composer dump-autoload. php artisan dump-autoload. It regenerates the list of all the classes that need to be included in the project (autoload_classmap. php). It will 'recompile' loads of files creating the huge bootstrap/compiled.php.
The PSR-4 standard requires your files and directories to be case sensitive and the corresponding classes and namespaces to be in PascalCase.
For a App\Controllers\BaseController
class, the file should be located in:
app/Controllers/BaseController.php
Notice the uppercase
C
2nd error:
For any namespace after the top level namespace, there must be a directory with the same name.
You have a App\RoutingDispatcher
class that should be placed as app/RoutingDispatcher.php
but the app/routing/RoutingDispatcher.php
file would correspond to a App\Routing\RoutingDispatcher
class.
You must change the namespace of that class or move the file.
If you change its namespace, be sure to rename the
app/routing
directory with a leading uppercase letter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With