O'Reilly logo

Laravel Design Patterns and Best Practices by H. İbrahim YILMAZ, Arda Kılıçdağı

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Advanced practices

In this subsection, we will see various design patterns' usage in Laravel. If you test the custom classes that include the design patterns, which are provided within the book, they should be autoloaded in your application. This can be done either by adding them to the ClassLoader::addDirectories() array of the global.php file (which can be found by navigating to app/start) or the start.php file in the bootstrap folder. Alternatively, we can add a psr-0 autoload in composer.json.

To add directories from app/start/global.php, first find the following code:

ClassLoader::addDirectories(array(

   app_path().'/commands',
   app_path().'/controllers',
   app_path().'/models',
   app_path().'/database/seeds',

));

Then add your folders below. The resulting ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required