php/laravel -- php artisan serve -- opensuse 15.0 error - composer-php

So I am new to php/laravel and am trying to set up my environment here with composer on opensuse 15.0.
When I try to run php artisan migrate
I get this error:
PHP Warning: require(/home/mattyo/FirstLaravelProject/matt-project-laravel/vendor/autoload.php): failed to open stream: No such file or directory in /home/mattyo/FirstLaravelProject/matt-project-laravel/artisan on line 18
PHP Fatal error: require(): Failed opening required '/home/mattyo/FirstLaravelProject/matt-project-laravel/vendor/autoload.php' (include_path='.:/usr/share/php7:/usr/share/php7/PEAR') in /home/mattyo/FirstLaravelProject/matt-project-laravel/artisan on line 18
I get the same error when trying to run php artisan serve.
I have tried to run composer update along with composer install composer update --no-scripts and had no luck.
Any help would be greatly appreciated.
here's my composer.json
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.2.5|^8.0",
"fideloper/proxy": "^4.4",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^6.3.1|^7.0.1",
"laravel/framework": "^7.29",
"laravel/tinker": "^2.5"
},
"require-dev": {
"facade/ignition": "^2.0",
"fakerphp/faker": "^1.9.1",
"mockery/mockery": "^1.3.1",
"nunomaduro/collision": "^4.3",
"phpunit/phpunit": "^8.5.8|^9.3.3"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\\": "app/"
},
"classmap": [
"database/seeds",
"database/factories"
]
},
"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"
]
}
}
After running composer global require laravel/installer I received the following error message:
Changed current directory to /home/mattyo/.config/composer
Using version ^3.0 for laravel/installer
./composer.json has been updated
Running composer update laravel/installer
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- laravel/installer[v3.0.0, ..., v3.0.1] require ext-zip * -> it is missing from your system. Install or enable PHP's zip extension.
- laravel/installer[v3.1.0, ..., v3.2.0] require php ^7.2.9 -> your php version (7.2.5) does not satisfy that requirement.
- Root composer.json requires laravel/installer ^3.0 -> satisfiable by laravel/installer[v3.0.0, v3.0.1, v3.1.0, v3.2.0].
To enable extensions, verify that they are enabled in your .ini files:
- /etc/php7/cli/php.ini
- /etc/php7/conf.d/ctype.ini
- /etc/php7/conf.d/dom.ini
- /etc/php7/conf.d/iconv.ini
- /etc/php7/conf.d/json.ini
- /etc/php7/conf.d/mbstring.ini
- /etc/php7/conf.d/openssl.ini
- /etc/php7/conf.d/pdo.ini
- /etc/php7/conf.d/pdo_sqlite.ini
- /etc/php7/conf.d/phar.ini
- /etc/php7/conf.d/sqlite3.ini
- /etc/php7/conf.d/tokenizer.ini
- /etc/php7/conf.d/xmlreader.ini
- /etc/php7/conf.d/xmlwriter.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
Installation failed, reverting ./composer.json to its original content.

It seems the autoload.php file wasn't created by Composer for some reason. try composer dump-autoload and see if it works by running php artisan in the terminal.
If this issue still exists, remove the ./vendor directory with rm -rf vendor/* and remove composer cache composer clearcache. Then run composer install again
If none of the above solved the problem, Check if the composer.json file contains wrong or missing dependencies.

Related

I got symfony/console errors when installed botman/botman into new laravel app?

I try to add botman/botman into my new laravel app, which I created with command :
laravel new LrBtmn
But I got error :
master#master-at-home:/_wwwroot/lar/LrBtmn$ php artisan --version
Laravel Framework 9.47.0
master#master-at-home:/_wwwroot/lar/LrBtmn$ composer global require "botman/installer"
Changed current directory to /home/master/.config/composer
Using version ^1.0 for botman/installer
./composer.json has been updated
Running composer update botman/installer
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- botman/installer[1.0.0, ..., 1.0.3] require symfony/console ~2.3|~3.0 -> found symfony/console[v2.3.0, ..., v2.8.52, v3.0.0, ..., v3.4.47] but the package is fixed to v6.2.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.
- botman/installer 1.0.4 requires symfony/console ~2.3|~3.0|~4.0 -> found symfony/console[v2.3.0, ..., v2.8.52, v3.0.0, ..., v3.4.47, v4.0.0, ..., v4.4.49] but the package is fixed to v6.2.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 botman/installer ^1.0 -> satisfiable by botman/installer[1.0.0, ..., 1.0.4].
Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
You can also try re-running composer require with an explicit version constraint, e.g. "composer require botman/installer:*" to figure out if any version is installable, or "composer require botman/installer:^2.1" if you know which you need.
Installation failed, reverting ./composer.json and ./composer.lock to their original content.
I tried to add "-W" key :
master#master-at-home:/_wwwroot/lar/LrBtmn$ composer global require "botman/installer" -W
Changed current directory to /home/master/.config/composer
Info from https://repo.packagist.org: #StandWithUkraine
Using version ^1.0 for botman/installer
./composer.json has been updated
Running composer update botman/installer --with-all-dependencies
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- botman/installer[1.0.0, ..., 1.0.3] require symfony/console ~2.3|~3.0 -> found symfony/console[v2.3.0, ..., v2.8.52, v3.0.0, ..., v3.4.47] but these were not loaded, likely because it conflicts with another require.
- botman/installer 1.0.4 requires symfony/console ~2.3|~3.0|~4.0 -> found symfony/console[v2.3.0, ..., v2.8.52, v3.0.0, ..., v3.4.47, v4.0.0, ..., v4.4.49] but these were not loaded, likely because it conflicts with another require.
- Root composer.json requires botman/installer ^1.0 -> satisfiable by botman/installer[1.0.0, ..., 1.0.4].
You can also try re-running composer require with an explicit version constraint, e.g. "composer require botman/installer:*" to figure out if any version is installable, or "composer require botman/installer:^2.1" if you know which you need.
In composer.json of new project there are no any "symfony/console" packages:
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"php": "^8.0.2",
"botman/botman": "^2.7",
"guzzlehttp/guzzle": "^7.2",
"laravel/framework": "^9.19",
"laravel/sanctum": "^3.0",
"laravel/tinker": "^2.7"
},
"require-dev": {
"fakerphp/faker": "^1.9.1",
"laravel/pint": "^1.0",
"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,
"allow-plugins": {
"pestphp/pest-plugin": true
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
Which steps have I to take to run this app?
Thanks!

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?

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"
]
}
}

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

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?

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