Skip to content

Commit

Permalink
Merge pull request laravel#1 from laravel/5.7
Browse files Browse the repository at this point in the history
Merge 5.7
  • Loading branch information
jensdenies authored Sep 14, 2018
2 parents e6f6343 + e6f8fa3 commit 9806d00
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 37 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ Laravel Lumen is a stunningly fast PHP micro-framework for building web applicat

## Official Documentation

Documentation for the framework can be found on the [Lumen website](http://lumen.laravel.com/docs).
Documentation for the framework can be found on the [Lumen website](https://lumen.laravel.com/docs).

## Security Vulnerabilities

If you discover a security vulnerability within Lumen, please send an e-mail to Taylor Otwell at taylor@laravel.com. All security vulnerabilities will be promptly addressed.

## License

The Lumen framework is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).
The Lumen framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
60 changes: 30 additions & 30 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,39 @@
],
"require": {
"php": "^7.1.3",
"illuminate/auth": "5.6.*",
"illuminate/broadcasting": "5.6.*",
"illuminate/bus": "5.6.*",
"illuminate/cache": "5.6.*",
"illuminate/config": "5.6.*",
"illuminate/container": "5.6.*",
"illuminate/contracts": "5.6.*",
"illuminate/database": "5.6.*",
"illuminate/encryption": "5.6.*",
"illuminate/events": "5.6.*",
"illuminate/filesystem": "5.6.*",
"illuminate/hashing": "5.6.*",
"illuminate/http": "5.6.*",
"illuminate/pagination": "5.6.*",
"illuminate/pipeline": "5.6.*",
"illuminate/queue": "5.6.*",
"illuminate/support": "5.6.*",
"illuminate/translation": "5.6.*",
"illuminate/validation": "5.6.*",
"illuminate/view": "5.6.*",
"illuminate/log": "5.6.*",
"dragonmantank/cron-expression": "~2.0",
"nikic/fast-route": "~1.2",
"symfony/http-kernel": "~4.0",
"symfony/http-foundation": "~4.0"
"illuminate/auth": "5.7.*",
"illuminate/broadcasting": "5.7.*",
"illuminate/bus": "5.7.*",
"illuminate/cache": "5.7.*",
"illuminate/config": "5.7.*",
"illuminate/container": "5.7.*",
"illuminate/contracts": "5.7.*",
"illuminate/database": "5.7.*",
"illuminate/encryption": "5.7.*",
"illuminate/events": "5.7.*",
"illuminate/filesystem": "5.7.*",
"illuminate/hashing": "5.7.*",
"illuminate/http": "5.7.*",
"illuminate/pagination": "5.7.*",
"illuminate/pipeline": "5.7.*",
"illuminate/queue": "5.7.*",
"illuminate/support": "5.7.*",
"illuminate/translation": "5.7.*",
"illuminate/validation": "5.7.*",
"illuminate/view": "5.7.*",
"illuminate/log": "5.7.*",
"dragonmantank/cron-expression": "^2.0",
"nikic/fast-route": "^1.3",
"symfony/http-kernel": "^4.1",
"symfony/http-foundation": "^4.1"
},
"require-dev": {
"mockery/mockery": "~1.0",
"phpunit/phpunit": "~7.0"
"mockery/mockery": "^1.0",
"phpunit/phpunit": "^7.0"
},
"suggest": {
"laravel/tinker": "Required to use the tinker console command (~1.0).",
"vlucas/phpdotenv": "Required to use .env files (~2.2)."
"laravel/tinker": "Required to use the tinker console command (^1.0).",
"vlucas/phpdotenv": "Required to use .env files (^2.2)."
},
"autoload": {
"psr-4": {
Expand All @@ -60,7 +60,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "5.6-dev"
"dev-master": "5.7-dev"
}
},
"minimum-stability": "dev",
Expand Down
2 changes: 2 additions & 0 deletions config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@

'redis' => [

'client' => 'predis',

'cluster' => env('REDIS_CLUSTER', false),

'default' => [
Expand Down
44 changes: 40 additions & 4 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ class Application extends Container
*/
protected $loadedConfigurations = [];

/**
* Indicates if the application has "booted".
*
* @var bool
*/
protected $booted = false;

/**
* The loaded service providers.
*
Expand Down Expand Up @@ -126,7 +133,7 @@ public function bootstrapRouter()
*/
public function version()
{
return 'Lumen (5.6.4) (Laravel Components 5.6.*)';
return 'Lumen (5.7.0) (Laravel Components 5.7.*)';
}

/**
Expand Down Expand Up @@ -180,14 +187,14 @@ public function register($provider)
return;
}

$this->loadedProviders[$providerName] = true;
$this->loadedProviders[$providerName] = $provider;

if (method_exists($provider, 'register')) {
$provider->register();
}

if (method_exists($provider, 'boot')) {
return $this->call([$provider, 'boot']);
if ($this->booted) {
$this->bootProvider($provider);
}
}

Expand All @@ -202,6 +209,35 @@ public function registerDeferredProvider($provider)
return $this->register($provider);
}

/**
* Boots the registered providers.
*/
public function boot()
{
if ($this->booted) {
return;
}

array_walk($this->loadedProviders, function ($p) {
$this->bootProvider($p);
});

$this->booted = true;
}

/**
* Boot the given service provider.
*
* @param \Illuminate\Support\ServiceProvider $provider
* @return mixed
*/
protected function bootProvider(ServiceProvider $provider)
{
if (method_exists($provider, 'boot')) {
return $this->call([$provider, 'boot']);
}
}

/**
* Resolve the given type from the container.
*
Expand Down
2 changes: 2 additions & 0 deletions src/Concerns/RoutesRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ public function dispatch($request = null)
list($method, $pathInfo) = $this->parseIncomingRequest($request);

try {
$this->boot();

return $this->sendThroughPipeline($this->middleware, function () use ($method, $pathInfo) {
if (isset($this->router->getRoutes()[$method.$pathInfo])) {
return $this->handleFoundRoute([true, $this->router->getRoutes()[$method.$pathInfo]['action'], []]);
Expand Down
4 changes: 3 additions & 1 deletion src/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function __construct(Application $app)
{
$this->app = $app;

if (! $this->app->bound('request')) {
if ($this->app->runningInConsole()) {
$this->setRequestForConsole($this->app);
}

Expand Down Expand Up @@ -111,6 +111,8 @@ protected function defineConsoleSchedule()
public function handle($input, $output = null)
{
try {
$this->app->boot();

return $this->getArtisan()->run($input, $output);
} catch (Exception $e) {
$this->reportException($e);
Expand Down
58 changes: 58 additions & 0 deletions tests/FullApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,54 @@ public function testRegisterServiceProvider()
$this->assertTrue(true);
}

public function testApplicationBootsServiceProvidersOnBoot()
{
$app = new Application();

$provider = new LumenBootableTestServiceProvider($app);
$app->register($provider);

$this->assertFalse($provider->booted);
$app->boot();
$this->assertTrue($provider->booted);
}

public function testRegisterServiceProviderAfterBoot()
{
$app = new Application();
$provider = new LumenBootableTestServiceProvider($app);
$app->boot();
$app->register($provider);
$this->assertTrue($provider->booted);
}

public function testApplicationBootsOnlyOnce()
{
$app = new Application();
$provider = new class($app) extends \Illuminate\Support\ServiceProvider {
public $bootCount = 0;

public function boot()
{
$this->bootCount += 1;
}
};

$app->register($provider);
$app->boot();
$app->boot();
$this->assertEquals(1, $provider->bootCount);
}

public function testApplicationBootsWhenRequestIsDispatched()
{
$app = new Application();
$provider = new LumenBootableTestServiceProvider($app);
$app->register($provider);
$resp = $app->dispatch();
$this->assertTrue($provider->booted);
}

public function testUsingCustomDispatcher()
{
$routes = new FastRoute\RouteCollector(new FastRoute\RouteParser\Std, new FastRoute\DataGenerator\GroupCountBased);
Expand Down Expand Up @@ -631,6 +679,16 @@ public function register()
}
}

class LumenBootableTestServiceProvider extends Illuminate\Support\ServiceProvider
{
public $booted = false;

public function boot()
{
$this->booted = true;
}
}

class LumenTestController
{
public function __construct(LumenTestService $service)
Expand Down

0 comments on commit 9806d00

Please sign in to comment.