I rummaged through the core of Laravel because I wanted to understand how this works. But I came up with a method that I just canβt envelop in my head even after 3 days. In start.php, the application binds to itself. So far, so good. But when I check the $ app-> share method, I get lost.
public function share(Closure $closure) { return function($container) use ($closure) {
This method returns an anonymous function, which, when executed, returns an instance of the application. Am I seeing it right? Why is this? Why do you want to return a closure, not just an instance. This seems odd, but I'm pretty sure there is a reason;)
UPDATE String in start.php:
$app['app'] = $app->share(function($app) { return $app; });
So, I think $ app ['app'] is a closing object. However, if I do get_class, the Illuminate \ Foundation \ Application class. In addition, there is also no way to execute it, since $ app'app 'will not work explicitly.
source share