. Advertisement .
..3..
. Advertisement .
..4..
You might have encountered an error message that says, “BaseController.php does not comply with psr-4 autoloading standard. Skipping“. What does it mean? In this blog, we will be discussing this error message and how to fix it.
When Does The Error “BaseController.php does not comply with psr-4 autoloading standard. Skipping” Happen?
You may get the following error in your terminal when running composer autoload.
Generating optimized autoload files
Class App\Controllers\BaseController located in
E:Xampp/htdocs/Wondra/app\controllers\BaseController.php does not comply with psr-4 autoloading standard. Skipping.
Class App\Controllers\UserControllers located in
E:Xampp/htdocs/Wondra/app\controllers\UserControllers.php does not comply with psr-4 autoloading standard. Skipping.
Class App\RoutingDispatcher located in
E:Xampp/htdocs/Wondra/app\routing\RoutingDispatcher.php does not comply with psr-4 autoloading standard. Skipping.
Generated optimized autoload files containing 508 classes
How To Solve The Error “BaseController.php does not comply with psr-4 autoloading standard. Skipping”
Option 1: Be careful with namespace
There’s nothing to be concerned about, but the PSR-4 standard needs case sensitivity for files and folders and PascalCase for classes and namespaces.
The file must be positioned in the following namespace, according to the error Log For BaseController class:
app/Controllers/BaseController.php
As a resupace, you need to be careful whenever you use a namespace.
Option 2: Examine the composer’s version
The composer version can cause this issue. Examine the version of your composer utilizing:
composer -V
Install a new version with this:
composer self-update 1.6.3
Next, remove the vendor folder from the project. You can utilize the command below:
composer install
composer update
composer dump-autoload
Option 3: Move the file or alter the namespace of the class.
Another way to solve the error “BaseController.php does not comply with psr-4 autoloading standard. Skipping” is moving the file or altering the namespace of the class.
There must be a directory with the same name for every namespace that follows the top level namespace.
You have a class called AppRoutingDispatcher that belongs in the file app/RoutingDispatcher.php, but the file app/routing/RoutingDispatcher.php corresponds to a class called AppRoutingRoutingDispatcher.
Therefore, you have to either move the file or alter the namespace of the class.
Make sure to give the app/routing directory a new name that starts with an uppercase letter if you decide to modify the namespace.
After you doing that, your error will be completely resolved.
Conclusion
We hope our blog post on solving the error “BaseController.php does not comply with psr-4 autoloading standard. Skipping” was useful. With this information, you should be able to handle this annoyance and a slew of other concerns when you design your application. Please leave a comment if you want to learn more about the topic or if you have any questions or ideas to share. Thank you for taking the time to read this!
Leave a comment