Skip to content

Commit

Permalink
fix service load order
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammad-Alavi committed Sep 27, 2021
1 parent 858132d commit f718a3e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
24 changes: 15 additions & 9 deletions Loaders/AutoLoaderTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,30 @@ trait AutoLoaderTrait
*/
public function runLoadersBoot(): void
{
// The config files should be loaded first from all the directories in their own loop
$this->loadConfigsFromShip();
$this->loadLocalsFromShip();
$this->loadMigrationsFromShip();
$this->loadLocalsFromShip();
$this->loadViewsFromShip();
$this->loadConsolesFromShip();
$this->loadHelpersFromShip();
$this->loadOnlyShipProviderFromShip();

// Iterate over all the containers folders and autoload most of the components
foreach (Apiato::getAllContainerPaths() as $containerPath) {
$this->loadConfigsFromContainers($containerPath);
$this->loadLocalsFromContainers($containerPath);
$this->loadOnlyMainProvidersFromContainers($containerPath);
$this->loadMigrationsFromContainers($containerPath);
$this->loadConsolesFromContainers($containerPath);
$this->loadLocalsFromContainers($containerPath);
$this->loadViewsFromContainers($containerPath);
$this->loadConsolesFromContainers($containerPath);
$this->loadHelpersFromContainers($containerPath);
}
}
}

public function runLoaderRegister(): void
{
$this->loadConfigsFromShip();
$this->loadOnlyShipProviderFromShip();

foreach (Apiato::getAllContainerPaths() as $containerPath) {
$this->loadConfigsFromContainers($containerPath);
$this->loadOnlyMainProvidersFromContainers($containerPath);
}
}
}
13 changes: 8 additions & 5 deletions Providers/ApiatoProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public function boot(): void
{
parent::boot();

$this->app->bind('Apiato', Apiato::class);
// Autoload most of the Containers and Ship Components
$this->runLoadersBoot();

// Solves the "specified key was too long" error, introduced in L5.4
Schema::defaultStringLength(191);
Expand All @@ -31,17 +32,19 @@ public function boot(): void

public function register(): void
{
parent::register();
// NOTE: function order of this calls bellow are important. Do not change it.

$this->app->bind('Apiato', Apiato::class);
// Register Core Facade Classes, should not be registered in the $aliases property, since they are used
// by the auto-loading scripts, before the $aliases property is executed.
$this->app->alias(Apiato::class, 'Apiato');

// Autoload most of the Containers and Ship Components
$this->runLoadersBoot();
// parent::register() should be called AFTER we bind 'Apiato'
parent::register();

$this->overrideLaravelBaseProviders();
$this->runLoaderRegister();

$this->overrideLaravelBaseProviders();
}

/**
Expand Down

0 comments on commit f718a3e

Please sign in to comment.