Artisan::call not seeing passport commands even it work from ssh command line
i have new laravel 5.6 project with passport installed
if i run php artisan you can see passport command appear and work
but if its called from Artisan::call within route like this willget error
There are no commands defined in the "passport" namespace.
Route::any('/passportprepeare', function () {
Artisan::call('passport:install --force', ['--force' => true]);
});
even the db migrate if called from command line will include passport tables if called through Artisan::call passport tables not migrated
Artisan::call('migrate:refresh', ['--force' => true]);
Route::any('/migrateDB', function () {
Artisan::call('migrate:refresh', ['--force' => true]);
});
if u need commands need to be registered in boot provider as laravel code check
if ($this->app->runningInConsole()) {
}
$this->commands([
Console\InstallCommand::class,
Console\ClientCommand::class,
Console\KeysCommand::class,
]);
if u need migration
Artisan::call('migrate', [
'--path' => 'vendor/laravel/passport/database/migrations',
'--force' => true,
]);
This code works with no error for installing passport on shared hosting
shell_exec('php ../artisan passport:install');
shell_exec('php ../artisan passport:install');
It worked for me too, thanks
Better Option
You can make everything work fine if you configure you app/Providers/AppServiceProvider.php file like below
use Laravel\Passport\Console\ClientCommand;
use Laravel\Passport\Console\InstallCommand;
use Laravel\Passport\Console\KeysCommand;
public function boot()
{
//
$this->commands([
InstallCommand::class,
ClientCommand::class,
KeysCommand::class,
]);
}
The Passport install command should work perfectly.
This code works with no error for installing passport on shared hosting
shell_exec('php ../artisan passport:install');
where the code is placed?
Most helpful comment
Better Option
You can make everything work fine if you configure you app/Providers/AppServiceProvider.php file like below
use Laravel\Passport\Console\ClientCommand;use Laravel\Passport\Console\InstallCommand;use Laravel\Passport\Console\KeysCommand;public function boot(){//$this->commands([InstallCommand::class,ClientCommand::class,KeysCommand::class,]);}The Passport install command should work perfectly.