Reputation: 63619
I am migrating a working production L3 site to use L4. When a controller calls a library class (app/libraries/adminthing.php
), I get the error Error: Class 'adminthing' not found in /var/www/l4/app/controllers/AdminController.php line 15
start/global.php
ClassLoader::addDirectories(array(
app_path().'/controllers',
app_path().'/models',
app_path().'/database/seeds',
app_path().'/libraries',
));
I have also done composer dumpautoload
after adding the library class. What else did I miss out?
Upvotes: 3
Views: 6779
Reputation: 5797
You can autoload folders from composer.json. If you have some custom classes in a folder under /app you can add the folder to composer.json, and after this the classes are auto loaded.
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php",
"app/customlib" <-- add this
]
},
Then composer dump-autoload, and you can use the classes!
Upvotes: 10