Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

athenagraphics's avatar

Session and Input facades

So, in laravel 5, we are moving away from facades, and towards Contracts, so what do we do with eg: the Session and Input facades? There doesnt seem to be a contract for these. Do we continue to use the facade or is there another way to go about it?

0 likes
2 replies
bart's avatar

You can use facades as well, no problem at all. Contracts and facades are the same imo. Both are interface you have to bind your final implementation to. Last but not least you can replace the input facade by form requests or plain Illuminate\Http\Request.

We have an episode about form requests here on Laracasts: https://laracasts.com/series/whats-new-in-laravel-5/episodes/3 as well as a good introduction by Matt Stauffer: http://mattstauffer.co/blog/laravel-5.0-form-requests

usman's avatar

In addition to @bart's answer you can inject the session store in your controllers/methods like this:

use Illuminate\Routing\Controller;
use Symfony\Component\HttpFoundation\Session\SessionInterface as SessionContract;

class AwesomeController extends Controller {

    protected $session;

    public function __construct(SessionContract $session)
    {
        $this->session = $session;
    }

}

I hope this helps.

Please or to participate in this conversation.