I’m building a PHP app using Laravel Framework. I need to read some session values on every request and use this values on my controller methods.
How can I achieve this? Where to put this code?
I would like something like the Zend Framework Bootstrap class.
Advertisement
Answer
So, you can create a file named, for instance, BaseController.php
which extends Controller
. Then put your logic in the __construct()
Then, all of your other controllers can extend BaseController
and in their __construct()
they can perform a parent::__construct();
to make that fire.