I have a running Laravel application which has the default Console/Kernel.php
where all my scheduled commands are defined as usual.
But now I have another Laravel application that I am trying to merge with this existing application, and I have created a folder inside the existing Laravel application and I am using a Service Provider to load all the things. This way I can keep the code of the two projects separate but at the same time all features under the same repository.
<?php
namespace SecondApp;
use IlluminateSupportServiceProvider;
class SecondAppServiceProvider extends ServiceProvider
{
/**
* Register services.
*
* @return void
*/
public function register()
{
include __DIR__ . '/routes/web.php';
include __DIR__ . '/routes/api.php';
$this->app->register('SecondAppAppProvidersAppServiceProvider');
$this->app->register('SecondAppAppProvidersAuthServiceProvider');
$this->app->register('SecondAppAppProvidersBroadcastServiceProvider');
$this->app->register('SecondAppAppProvidersEventServiceProvider');
$this->app->register('SecondAppAppProvidersJobServiceProvider');
$this->app->register('SecondAppAppProvidersMailerServiceProvider');
$this->app->register('SecondAppAppProvidersRouteServiceProvider');
$this->app->register('SecondAppAppProvidersStorageServiceProvider');
}
/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
$this->loadMigrationsFrom(__DIR__ . '/database/migrations/');
$this->publishes([
__DIR__ . '/config/' => config_path()
], 'second-app-config');
$this->publishes([
__DIR__ . '/resources/' => base_path('resources')
], 'second-app-resources');
}
}
This is what my service somewhat looks like. Everything else seems to work well, roues, migrations, registering service providers and so on, but this second project now also has Console/Kernel.php
file. And those commands are not being called yet, obviously because laravel doesn't know about it. So I am wondering how can I tell Laravel to look at that as well? Is this possible, or will I have merge the code into one main Kernel.php
?
I have the same question about Http/Kernel.php
as well, but I am sure if someone can suggest how to make one work, I can make the other work as well.
question from:
https://stackoverflow.com/questions/65951569/how-to-load-another-console-kernel-php-in-laravel-project 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…