Simon
Simon

Reputation: 1190

Laravel Passport - command not defined

I've been stuggeling with this problem now for days: Installting Laravel passport. I did all accoring to the tutorial. What I did

composer require laravel/passport

Added Laravel\Passport\PassportServiceProvider::class, to the config/app.php

run php artisan migrate and then php artisan passport:install The crasy thing is this works on my local machine. But when I upload this to my webspace via ftp and run php artisan passport:install it gets me this Error:

Uncaught exception - 'There are no commands defined in the "passport" namespace.'

Full error (see on pastbin)

PHP Fatal error:  Uncaught exception 'Symfony\Component\Console\Exception\CommandNotFoundException' with message 'There are no commands defined in the "passport" namespace.' in /mnt/web102/d0/25/58432925/htdocs/www/vendor/symfony/console/Application.php:533
Stack trace:
#0 /mnt/web102/d0/25/58432925/htdocs/www/vendor/symfony/console/Application.php(565): Symfony\Component\Console\Application->findNamespace('passport')
#1 /mnt/web102/d0/25/58432925/htdocs/www/vendor/symfony/console/Application.php(204): Symfony\Component\Console\Application->find('passport:instal...')
#2 /mnt/web102/d0/25/58432925/htdocs/www/vendor/symfony/console/Application.php(130): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /mnt/web102/d0/25/58432925/htdocs/www/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Comp in /mnt/web102/d0/25/58432925/htdocs/www/vendor/symfony/console/Application.php on line 533
PHP Fatal error:  Uncaught exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Uncaught exception 'Symfony\Component\Console\Exception\CommandNotFoundException' with message 'There are no commands defined in the "passport" namespace.' in /mnt/web102/d0/25/58432925/htdocs/www/vendor/symfony/console/Application.php:533
Stack trace:
#0 /mnt/web102/d0/25/58432925/htdocs/www/vendor/symfony/console/Application.php(565): Symfony\Component\Console\Application->findNamespace('passport')
#1 /mnt/web102/d0/25/58432925/htdocs/www/vendor/symfony/console/Application.php(204): Symfony\Component\Console\Application->find('passport:instal...')
#2 /mnt/web102/d0/25/58432925/htdocs/www/vendor/symfony/console/Application.php(130): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /mnt/web102/d0/25/58432925/htdocs/www/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): Symfony\Component\Consol in /mnt/web102/d0/25/58432925/htdocs/www/vendor/symfony/console/Application.php on line 533
Status: 500 Internal Server Error
X-Powered-By: PHP/5.6.30
Content-type: text/html

What I did.

  1. uploaded all my code without the ./vendor and composer.lock
  2. (uploaded the server .env)
  3. php composer.phar clearcace
  4. php composer.phar update
  5. php artisan cache:clear
  6. php artisan config:cache
  7. php artisan migrate
  8. php artisan passport:install

And then the error happens...

If did php composer.phar require laravel/passport and can see via ftp that in the /vendor/laravel/ the passport folder is there!

Upvotes: 2

Views: 7946

Answers (5)

Sajjad Aljileezi
Sajjad Aljileezi

Reputation: 794

I had the same problem and i it worked after i did this

Composer update php artisan config:cache php artisan migrate php artisan passport:install

Upvotes: 0

KuLi
KuLi

Reputation: 76

If you run on shared hosting try

export APP_RUNNING_IN_CONSOLE=true

After that you can run php artisan passport:install

Laravel's runningInConsole method check if that environment is set or the output php_sapi_name() is cli or phpdbg. At a shared host it can be cgi-fcgi

Upvotes: 4

Simon
Simon

Reputation: 1190

What I have done to do solve the problem!

Inside \vendor\laravel\passport\src\PassportServiceProvider.php if deleted the

if ($this->app->runningInConsole()) {

in line 37. After uploading this to my webspace if could have full use of laravel:passport
Thanks for all the other help!

Upvotes: 4

Aseliot
Aseliot

Reputation: 97

Have you tried using:

php artisan config:clear

Instead of config:cache. It seems to have worked for me, which makes sense as you register the passport class in config/app.

Clearing all the cache also fixed me not being able to use "artisan migrate", where it previously said "nothing to migrate". The migrations don't seem to appear in database/migrations.

Upvotes: 0

erashdan
erashdan

Reputation: 152

I guess you have problem that passport not installed, if you are working via FTP do these steps:

  1. Upload your code without vendor and composer.lock
  2. Make sure that .env exist or fill 'key' in app.php
  3. Run composer dumpautoload
  4. Run this command composer update --no-scripts
  5. Try to run php artisan just to list all commands, if you got all commands then you can run php artisan passport:install

Hope this will work.

Upvotes: 0

Related Questions