Answer the question
In order to leave comments, you need to log in
What's wrong with facades?
In the article about the disadvantages of laravel , there is such a point:
Facades and statics, they are everywhere, even at the beginning of the project you already have Route::get in routes.php and this is in the presence of good DI, which allows you to abandon this and get a normal autocomplete in the IDE. And so it is necessary to put IDE Helper. For some reason, commentators pounced on this point, began to insult and teach me, but there is an unfinished facade out of the box, it’s not my fault.
Answer the question
In order to leave comments, you need to log in
Actually, only the lack of auto-completion out of the box.
In general, I don’t see anything wrong with using them, however, I myself always use the app ('class') or app ()->make ('class') function - it more clearly displays that I take the object not from somewhere but from IOC, then while a facade can be confused with a regular static class.
Although you can completely pervert and write Container::getInstance()->make('class', []); but I do not recommend it, who knows when Taylor will rewrite the app helper =)
Who will say that static is evil - look at the laravel sources
if (! function_exists('app')) {
/**
* Get the available container instance.
*
* @param string $make
* @param array $parameters
* @return mixed|\Laravel\Lumen\Application
*/
function app($make = null, $parameters = [])
{
if (is_null($make)) {
return Container::getInstance();
}
return Container::getInstance()->make($make, $parameters);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question