Yada
Yada

Reputation: 31265

Avoiding Laravel's alias

I'm wondering if there is any advantages or disadvantage of using Laravel's alias functionality. The only advantage I can think of is that it saves typing. The disadvantage is that most IDE won't be able to intellisense the aliases without the ide-helper package.

Instead of using aliases:

use Session;
use Request;
use Input;

Type out the full paths:

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

Edit:

As a convention I've decided to Laravel alias by assessing it directly with:

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

That way I don't litter the use statements on top of each class.

Upvotes: 4

Views: 490

Answers (1)

lukasgeiter
lukasgeiter

Reputation: 153140

There aren't any advantages really. The alias are created anyways (unless you would remove them) and so you might as well just use them.

Regarding autocomplete, importing the facade by its full name doesn't help much with that. The facades itself don't contain the methods that are callable on them. You'll need the ide-helper package anyways...

Upvotes: 5

Related Questions