vendredi 29 janvier 2021

How to load another Console/Kernel.php in Laravel project?

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 Illuminate\Support\ServiceProvider;

class SecondAppServiceProvider extends ServiceProvider
{
    /**
     * Register services.
     *
     * @return void
     */
    public function register()
    {
        include __DIR__ . '/routes/web.php';
        include __DIR__ . '/routes/api.php';

        $this->app->register('SecondApp\App\Providers\AppServiceProvider');
        $this->app->register('SecondApp\App\Providers\AuthServiceProvider');
        $this->app->register('SecondApp\App\Providers\BroadcastServiceProvider');
        $this->app->register('SecondApp\App\Providers\EventServiceProvider');
        $this->app->register('SecondApp\App\Providers\JobServiceProvider');
        $this->app->register('SecondApp\App\Providers\MailerServiceProvider');
        $this->app->register('SecondApp\App\Providers\RouteServiceProvider');
        $this->app->register('SecondApp\App\Providers\StorageServiceProvider');
    }

    /**
     * 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.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3ckDXAU
via IFTTT

Aucun commentaire:

Enregistrer un commentaire