Skip to content

Commit

Permalink
rewrite package auto-discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jun 1, 2017
1 parent 924a7e0 commit a5a0f3e
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 150 deletions.
9 changes: 8 additions & 1 deletion src/Illuminate/Foundation/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Illuminate\Filesystem\Filesystem;
use Illuminate\Log\LogServiceProvider;
use Illuminate\Support\ServiceProvider;
use Illuminate\Foundation\PackageManifest;
use Illuminate\Events\EventServiceProvider;
use Illuminate\Routing\RoutingServiceProvider;
use Symfony\Component\HttpKernel\HttpKernelInterface;
Expand Down Expand Up @@ -176,6 +177,10 @@ protected function registerBaseBindings()
$this->instance('app', $this);

$this->instance(Container::class, $this);

$this->instance(PackageManifest::class, new PackageManifest(
new Filesystem, $this->basePath(), $this->getCachedPackagesPath()
));
}

/**
Expand Down Expand Up @@ -545,8 +550,10 @@ public function runningUnitTests()
*/
public function registerConfiguredProviders()
{
$providers = $this->make(PackageManifest::class)->providers();

(new ProviderRepository($this, new Filesystem, $this->getCachedServicesPath()))
->load($this->config['app.providers']);
->load(array_merge($this->config['app.providers'], $providers));
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/Illuminate/Foundation/Bootstrap/RegisterFacades.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Foundation\AliasLoader;
use Illuminate\Support\Facades\Facade;
use Illuminate\Foundation\PackageManifest;
use Illuminate\Contracts\Foundation\Application;

class RegisterFacades
Expand All @@ -20,6 +21,9 @@ public function bootstrap(Application $app)

Facade::setFacadeApplication($app);

AliasLoader::getInstance($app->make('config')->get('app.aliases', []))->register();
AliasLoader::getInstance(array_merge(
$app->make('config')->get('app.aliases', []),
$app->make(PackageManifest::class)->aliases()
))->register();
}
}
31 changes: 0 additions & 31 deletions src/Illuminate/Foundation/Bootstrap/RegisterPackageProviders.php

This file was deleted.

13 changes: 13 additions & 0 deletions src/Illuminate/Foundation/ComposerScripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ public static function postUpdate(Event $event)
static::clearCompiled();
}

/**
* Handle the post-autoload-dump Composer event.
*
* @param \Composer\Script\Event $event
* @return void
*/
public static function postAutoloadDump(Event $event)
{
require_once $event->getComposer()->getConfig()->get('vendor-dir').'/autoload.php';

static::clearCompiled();
}

/**
* Clear the cached Laravel bootstrapping files.
*
Expand Down
1 change: 0 additions & 1 deletion src/Illuminate/Foundation/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class Kernel implements KernelContract
\Illuminate\Foundation\Bootstrap\RegisterFacades::class,
\Illuminate\Foundation\Bootstrap\SetRequestForConsole::class,
\Illuminate\Foundation\Bootstrap\RegisterProviders::class,
\Illuminate\Foundation\Bootstrap\RegisterPackageProviders::class,
\Illuminate\Foundation\Bootstrap\BootProviders::class,
];

Expand Down
32 changes: 2 additions & 30 deletions src/Illuminate/Foundation/Console/OptimizeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,7 @@ class OptimizeCommand extends Command
*
* @var string
*/
protected $description = 'Optimize the framework for better performance';

/**
* The composer instance.
*
* @var \Illuminate\Support\Composer
*/
protected $composer;

/**
* Create a new optimize command instance.
*
* @param \Illuminate\Support\Composer $composer
* @return void
*/
public function __construct(Composer $composer)
{
parent::__construct();

$this->composer = $composer;
}
protected $description = 'Optimize the framework for better performance (deprecated)';

/**
* Execute the console command.
Expand All @@ -49,15 +29,7 @@ public function __construct(Composer $composer)
*/
public function fire()
{
$this->info('Generating optimized class loader');

if ($this->option('psr')) {
$this->composer->dumpAutoloads();
} else {
$this->composer->dumpOptimized();
}

$this->call('clear-compiled');
//
}

/**
Expand Down
12 changes: 8 additions & 4 deletions src/Illuminate/Foundation/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,14 @@ protected function shouldntReport(Exception $e)
*/
protected function context()
{
return array_filter([
'userId' => Auth::id(),
'email' => Auth::user()->email ?? null,
]);
try {
return array_filter([
'userId' => Auth::id(),
'email' => Auth::user() ? Auth::user()->email : null,
]);
} catch (Exception $e) {
return [];
}
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/Illuminate/Foundation/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class Kernel implements KernelContract
\Illuminate\Foundation\Bootstrap\HandleExceptions::class,
\Illuminate\Foundation\Bootstrap\RegisterFacades::class,
\Illuminate\Foundation\Bootstrap\RegisterProviders::class,
\Illuminate\Foundation\Bootstrap\RegisterPackageProviders::class,
\Illuminate\Foundation\Bootstrap\BootProviders::class,
];

Expand Down
81 changes: 0 additions & 81 deletions src/Illuminate/Foundation/PackageAssetLoader.php

This file was deleted.

14 changes: 14 additions & 0 deletions src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
use Illuminate\Foundation\Console\VendorPublishCommand;
use Illuminate\Console\Scheduling\ScheduleFinishCommand;
use Illuminate\Database\Console\Seeds\SeederMakeCommand;
use Illuminate\Foundation\Console\PackageDiscoverCommand;
use Illuminate\Database\Console\Migrations\MigrateCommand;
use Illuminate\Foundation\Console\NotificationMakeCommand;
use Illuminate\Database\Console\Factories\FactoryMakeCommand;
Expand Down Expand Up @@ -96,6 +97,7 @@ class ArtisanServiceProvider extends ServiceProvider
'MigrateRollback' => 'command.migrate.rollback',
'MigrateStatus' => 'command.migrate.status',
'Optimize' => 'command.optimize',
'PackageDiscover' => 'command.package.discover',
'Preset' => 'command.preset',
'QueueFailed' => 'command.queue.failed',
'QueueFlush' => 'command.queue.flush',
Expand Down Expand Up @@ -567,6 +569,18 @@ protected function registerOptimizeCommand()
});
}

/**
* Register the command.
*
* @return void
*/
protected function registerPackageDiscoverCommand()
{
$this->app->singleton('command.package.discover', function ($app) {
return new PackageDiscoverCommand;
});
}

/**
* Register the command.
*
Expand Down

0 comments on commit a5a0f3e

Please sign in to comment.