Class 'Laravel\Passport\Passport' not found on Laravel 5.7 - laravel

I just cloned a repo with a Laravel 5.7 project, and I am having some troubles to run it on my machine.
When I make a composer install, I get this error:
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
Nothing to install or update
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> #php artisan package:discover
In AuthServiceProvider.php line 35:
Class 'Laravel\Passport\Passport' not found
Script #php artisan package:discover handling the post-autoload-dump event returned with error code 1
What can I do to solve this error? I dont know where to start.
This is the project's composer.json file:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": "^7.1.3",
"designmynight/laravel-mongodb-passport": "^1.1",
"fideloper/proxy": "^4.0",
"guzzlehttp/guzzle": "^6.3",
"jenssegers/mongodb": "^3.4",
"laravel/framework": "5.7.*",
"laravel/passport": "^7.0",
"laravel/tinker": "^1.0"
},
"require-dev": {
"beyondcode/laravel-dump-server": "^1.0",
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^2.0",
"phpunit/phpunit": "^7.0"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"dont-discover": [
]
}
},
"scripts": {
"post-root-package-install": [
"#php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"#php artisan key:generate"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"#php artisan package:discover"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
},
"minimum-stability": "dev",
"prefer-stable": true
}

Although composer update did the trick depending on situation it might not be the best solution.
First of all - when running composer install packages are installed based on versions that are in composer.lock if it's included in repository (it should be).
And in your case when you look carefully at console output you had:
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
So it's quite possible that someone added Laravel Passport package to composer.json but haven't run composer install or forgot to commit updated composer.lock file.
Now remember when running composer update you update all the packages. Sometimes it's fine (only on localhost) but sometimes it's not because not always you want to update all packages. So when you need to update single package you could try in this case also composer update laravel/passport just to force updating/installing just Laravel Passport without touching other packages.

It looks like you need to do
composer update
instead of install?

Related

Laravel 9 found illuminate/contracts but these were not loaded, likely because it conflicts with another require

I have a blank Laravel 9 install. The only extensions added are jetstream and livewire. I am trying to install spatie/laravel-comments package, but I get the following error.
Your requirements could not be resolved to an installable set of
packages.
Problem 1
- Root composer.json requires spatie/laravel-comments ^0.0.2 -> satisfiable by spatie/laravel-comments[0.0.2].
- spatie/laravel-comments 0.0.2 requires illuminate/contracts ^8.73 -> found illuminate/contracts[v8.73.0, ..., 8.x-dev] but these
were not loaded, likely because it conflicts with another require.
You can also try re-running composer require with an explicit version
constraint, e.g. "composer require spatie/laravel-comments:*" to
figure out if any version is installable, or "composer require
spatie/laravel-comments:^2.1" if you know which you need.
Installation failed, reverting ./composer.json and ./composer.lock to
their original content.
The same error occurs if I specify a version to install or leave it open for latest. I have tried removing the composer.lock file and reinstalling everything, my composer.json looks like.
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"php": "^8.0.2",
"guzzlehttp/guzzle": "^7.2",
"laravel/framework": "^9.11",
"laravel/jetstream": "^2.8",
"laravel/sanctum": "^2.14.1",
"laravel/tinker": "^2.7",
"livewire/livewire": "^2.10"
},
"require-dev": {
"fakerphp/faker": "^1.9.1",
"laravel/sail": "^1.0.1",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^6.1",
"phpunit/phpunit": "^9.5.10",
"spatie/laravel-ignition": "^1.0"
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"#php artisan package:discover --ansi"
],
"post-update-cmd": [
"#php artisan vendor:publish --tag=laravel-assets --ansi --force"
],
"post-root-package-install": [
"#php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"#php artisan key:generate --ansi"
]
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
Versions I'm using are:
composer -v = 2.4
php -v 8.1.3
and I'm on Windows
I've faced this issue once, and i think you need to run this command only
composer update
Hope this will fix.
and for Spatie installation you can find everything here SPATIE Installation
As you can see on the package's packagist overview, the package is not compatible with Laravel 9. But that is not the largest problem of that package: it is no longer available on Github, so downloading the code might fail.
You should use any other package that suits your needs, or contact the maintainers. Maybe Spatie will re-publish it, and make it compatible with Laravel 9?

Class "Symfony\Component\Mailer\Bridge\Mailgun\Transport\MailgunTransportFactory" not found on Laravel 9

I just wanted to use Mailgun to send E-mail from my Laravel project and followed this steps from official document: https://laravel.com/docs/9.x/mail#mailgun-driver
composer require symfony/mailgun-mailer symfony/http-client
When I try to send password reset e-mail to test it, it throws an excepiton:
Class "Symfony\Component\Mailer\Bridge\Mailgun\Transport\MailgunTransportFactory" not found
Here is the full stack trace: https://flareapp.io/share/oPRKqyZ7#share
I don't know but maybe it's because this project started as a Laravel 8 project and I updated it to Laravel 9 one week ago. Is it trying to find something comes with Laravel 9 into app directory or something but my project doesn't have that? I didn't understand.
By the way if it helps; this project uses Jetstream with Inertia.js and Vue.js. So the composer.json looks like this now:
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"php": "^8.0.2",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.2",
"inertiajs/inertia-laravel": "^0.5.4",
"laravel/framework": "^9.2",
"laravel/jetstream": "^2.4",
"laravel/octane": "^1.0",
"laravel/sanctum": "^2.14.1",
"laravel/tinker": "^2.7",
"sentry/sentry-laravel": "^2.11",
"symfony/http-client": "^6.0",
"symfony/mailgun-mailer": "^6.0",
"tightenco/ziggy": "^1.0"
},
"require-dev": {
"spatie/laravel-ignition": "^1.0",
"fakerphp/faker": "^1.9.1",
"laravel/sail": "^1.12",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^6.1",
"phpunit/phpunit": "^9.5.10"
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"#php artisan package:discover --ansi"
],
"post-update-cmd": [
"#php artisan vendor:publish --tag=laravel-assets --ansi"
],
"post-root-package-install": [
"#php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"#php artisan key:generate --ansi"
]
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
From the upgrade guide:
To continue using the Mailgun transport, your application should require the symfony/mailgun-mailer and symfony/http-client Composer packages:
so use:
composer require symfony/mailgun-mailer symfony/http-client
More information here Upgrade to laravel 9
Apparently it was something with Laravel Octane which I use on my project. I already ran composer require symfony/mailgun-mailer symfony/http-client and composer auto-dump etc and restart my processes on Supervisor but nothing changed. In the and I killed all processes (including supervisor, which keeps Laravel Octane alive) and then restarted them.
I think Laravel Octane wasn't able to load renewed composer autoload files. When everything stopped and restarted, they just worked well.

Jetstream Installation Failed: could not be resolved to an installable set of packages

I'm getting this error while installing Laravel Jetstream:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- laravel/jetstream[v2.3.0, ..., 2.x-dev] require league/commonmark ^1.3 -> found league/commonmark[1.3.0, ..., 1.6.x-dev] but the package is fixed to 2.0.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
- Root composer.json requires laravel/jetstream ^2.3 -> satisfiable by laravel/jetstream[v2.3.0, ..., 2.x-dev].
Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
Installation failed, reverting ./composer.json and ./composer.lock to their original content.
it's a fresh installed Laravel Framework 8.51.0
I try these answers but it does not work for me, so I try this one.
first, should install Jetstream in a new Laravel application (read this doc from Jetstream laravel :https://jetstream.laravel.com/2.x/installation.html).
first step:
install new laravel project version 8
composer require laravel/jetstream:*
and it's done
continue the installation for the jetstream
The Laravel 8 docs not clear. You can fix it by following commands:
php artisan jetstream:install livewire
npm install && npm run dev
Reference:
https://github.com/laravel/jetstream#installation
https://laracasts.com/discuss/channels/inertia/laravel-8-jetstream-livewire-inertia-error
This command:
composer require laravel/jetstream
also generated the same errors as you for me, but this other command works fine:
composer require laravel/jetstream:*
I try to install fresh laravel (specific laravel project like this):
composer create-project --prefer-dist laravel/laravel:^8.0 olshop-larafel
then inside into this project
cd olshop-larafel
And install laravel/jetstream:
composer require laravel/jetstream
All works fine. Have you tried to install laravel 8.0 specific version?
Or maybe this article will help you
Information, this is my composer.json file:
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.3",
"fideloper/proxy": "^4.2",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"laravel/framework": "^8.0",
"laravel/jetstream": "^2.3",
"laravel/tinker": "^2.0"
},
"require-dev": {
"facade/ignition": "^2.3.6",
"fzaninotto/faker": "^1.9.1",
"mockery/mockery": "^1.3.1",
"nunomaduro/collision": "^5.0",
"phpunit/phpunit": "^9.3"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"#php artisan package:discover --ansi"
],
"post-root-package-install": [
"#php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"#php artisan key:generate --ansi"
]
}
}

ErrorException When Registering with Laravel 8 Jetstream

I started a project on Laravel 7 just before the launch of Laravel 8, I am still learning this framework, so I updated to that version using this steps, and I am aware of this new scaffolding library call Jetstream that I installed with these steps:
composer require laravel/jetstream
php artisan jetstream:install livewire --teams
npm install && npm run dev
php artisan migrate
After working on my views and models I am proceeding to implement sessions functionalities, but when I tried to register with the project at localhost:8000/register, and having my data validated I get this error
Trying to get property 'id' of non-object (View: \path-to\my-project\resources\views\navigation-dropdown.blade.php) (View: \path-to\my-project\resources\views\navigation-dropdown.blade.php) (View: \path-to\my-project\resources\views\navigation-dropdown.blade.php)
http://localhost:8000/dashboard
This is the section of view that is throwing the exception
navigation-dropdown.blade.php line 169 this is the vanilla file
<!-- Team Settings -->
<x-jet-responsive-nav-link href="{{ route('teams.show', Auth::user()->currentTeam->id) }}" :active="request()->routeIs('teams.show')">
{{ __('Team Settings') }}
</x-jet-responsive-nav-link>
The data introduced in the register form gets stored in the database, but the error happens
I checked this other question Laravel Jetstream + Livewire + Teams FeatureTest problems when authenticate but it seems that answer apply to a different context since it is dealing with tests, no the vanilla register functions.
This is my current composer.json
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.3.0",
"fideloper/proxy": "^4.2",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"laravel/framework": "^8.0",
"laravel/jetstream": "^1.0",
"laravel/sanctum": "^2.6",
"laravel/tinker": "^2.0",
"livewire/livewire": "^2.0"
},
"require-dev": {
"facade/ignition": "^2.3.6",
"fzaninotto/faker": "^1.9.1",
"mockery/mockery": "^1.3.1",
"nunomaduro/collision": "^5.0",
"phpunit/phpunit": "^8.5"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"#php artisan package:discover --ansi"
],
"post-root-package-install": [
"#php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"#php artisan key:generate --ansi"
]
}
}
I tried installing to test a fresh Laravel project with Jetstream, and this worked as it should, that let me confused as to what happened with my current project.
In the end, what worked for me was create a new fresh project with jetstream, then in my original project deleted the vendor and node_modules folder then copying the files of the new fresh project unto my original project and now it works as expected
Answer added on behalf of OP.
The user was not created with a team assigned, see users table and column current_team_id is null.
The navigation-menu.blade.php checks only for TeamFeatures but not if a team is really assigned.
#if (Laravel\Jetstream\Jetstream::hasTeamFeatures())
#if (Laravel\Jetstream\Jetstream::hasTeamFeatures() && Auth::user()->current_team_id)
For details here is the issue trying to get property of non-object

Updating laravel to laravel 5.5 from laravel 5.4

I'm trying update a laravel from 5.4 version to 5.5. I have done everything with instruction from laravel guide:
https://laravel.com/docs/master/upgrade
When I'm trying use command:
composer update
the result is:
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package laravel/framework 5.5.* is satisfiable by laravel/framework[5.5.x-dev] but these conflict with your requirements or minimum-stability.
Below I show composer.json file:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.6.4",
"doctrine/dbal": "^2.5",
"intervention/image": "^2.3",
"laravel/framework": "5.5.*",
"laravel/tinker": "~1.0",
"laravelcollective/html": "^5.4.0",
"unisharp/laravel-filemanager": "^1.7"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~6.0"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"artSite\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-root-package-install": [
"php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true
}
}
I would be greateful for help. Best regards
as stated in the error message Laravel 5.5 is still in dev, meaning there's no stable release and by default Composer limits you to downloading only stable numbered releases to avoid you downloading any packages that are in active development and may contain breaking changes.
You can circumvent this by adding the following two lines to your composer.json file
"minimum-stability": "dev",
"prefer-stable": true,
This way it prefers stable releases wherever it can find them but it will allow you to download dev packages if nothing else is available.
I think you should update the PHP version as well. If you check the official doc, it says the minimum PHP requirement 7.0.0.

Resources