I have just realised in Laravel 4, we have the commands directory added to app/start/global.php. The directory contains nothing in it. Does this directory replace libraries in Laravel 3? I guess my classes will still work if I placed them in there, but would I be using it for the wrong purpose?
1 Answer
The Laravel 4 commands directory, is like the Laravel 3 tasks directory. So it is not the ideal place for your libraries. What is the recommended way to go? If your libraries classes are database models it should be place under app/models, otherwise you could create a new directory like app/libraries then modify: app/start/global.php and add the new directory path to the array in ClassLoader::addDirectories(...) method call.
Extra information above related to Laravel 4 Commands:
The main differences (advantages) of Laravel 4 Commands over Laravel 3 Tasks are:
- Start writing a command is just matter of typing:
php artisan command:make MyCommand. - Commands can have a set of arguments and options.
- Commands need to be registered in Artisan.
For more information read the docs about Commands.
appfolder then add it toapp/start/global.phpinClassLoader::addDirectories.