Laravel alias avoidance

I am wondering if there are any advantages or disadvantages of using Laravel's alias functions. The only advantage I can think of is that it preserves typing. The downside is that most IDEs won't be able to intellisense aliases without the ide-helper package.

Instead of using aliases:

use Session;
use Request;
use Input;

      

Enter the full path:

use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\Request;
use Illuminate\Support\Facades\Input;

      

Edit:

As a convention, I decided to use a Laravel alias by evaluating it directly:

\ Session :: get () \ Request :: get () \ Input :: get () etc.

This way, I don't put the use statements on top of every class.

+3


source to share


1 answer


In fact, there are no advantages. Aliases are created anyway (unless you delete them) and therefore you can just use them.



As for autocomplete, importing a facade by its full name doesn't help much. Facades themselves do not contain methods that can be called on them. You will need the ide-helper package anyway ...

+5


source







All Articles