laravellaravel-artisanlaravel-package

Artisan:call is not working for package command


I am using Artisan::call to call a command from a package (that I have created) but its not finding that command and showing error "message": "The command \"sync:reloadly\" does not exist.", "exception": "Symfony\\Component\\Console\\Exception\\CommandNotFoundException", "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Application.php", "line": 182,

This command is working on console but not in PHP code


Solution

  • If this command is working fine on console but not working in PHP code then you need to look inside package code (service provider) where that command is registered. If its registered using

    $this->app->runningInConsole()

    then you need to remove that and try running it again. Hope this will work.

    OR

    You can add that command in Kernel yourself Path: app/Console/Kernel.php

    protected $commands = [
        \Package\Path\Console\CommandName::class,
    ];
    

    Credit: https://laracasts.com/discuss/channels/general-discussion/artisan-command-from-package-not-recognized-when-calling-from-php