Laravel 5 - recurring use claims

Is there a central place where I can use 'use' statements so I don't have to keep doing things like this with every single controller I create?

<?php namespace App/Http/Controllers

use Session;
use Auth;
use Input;
use Log;
use Carbon;
use Response;
use Illuminate\Routing\Controller;

class BlaBlaController extends Controller {}

      

It just seems to break DRY and seem ineffective.

+3


source to share


1 answer


Short answer: No.

The 'use' statements allow namespaces for this file, so you cannot inherit from other files. It doesn't violate DRY because there really isn't any logic that repeats itself.

Now, if you don't want to include this use statement in every controller, you can simply allow the appearance from the global scope whenever you use it. For example, the following will work from any namespace without the need for an operator.



\Input::all();

      

It looks a little cleaner in my opinion to just include the instruction of use, but either will work.

+1


source







All Articles