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

Controllers in Laravel

In Laravel 4, the Controllers are simple PHP classes with their filenames and classnames ending with the suffix Controller (not forced, but highly recommended; it's a standard between developers), which extends the class BaseController, and are stored in the folder app/controllers as default. This folder structure is defined in the composer.json file's classmap key and is not forced. Thanks to the Composer, as long as you define where the Controllers are stored in your application's structure, you can put them in any folder you like.

The following is a very simple Controller for Laravel 4:

<?php class UserController extends BaseController { public function showProfile($id) { $user = User::find($id); return View::make('user.profile', ...

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