Reputation: 117
i write composer require laravel/horizon to composer but it give this error :
Your requirements could not be resolved to an installable set of packages.
Problem 1 - Root composer.json requires laravel/horizon ^0.1.0 -> satisfiable by laravel/horizon[v0.1.0]. - laravel/horizon v0.1.0 requires illuminate/contracts ~5.4 -> found illuminate/contracts[v5.4.0, ..., 5.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 laravel/horizon:*" to figure out if any version is installable, or "composer require laravel/horizon:^2.1" if you know which you need.
Installation failed, reverting ./composer.json and ./composer.lock to their original content.
my composer.json
:
"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/sanctum": "^2.14.1",
"laravel/tinker": "^2.7"
},
"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
}
Upvotes: 3
Views: 2518
Reputation: 117
I solved that with this code :
composer require laravel/horizon:^v5.9.7 --ignore-platform-req=ext-pcntl --ignore-platform-req=ext-posix
Upvotes: 4
Reputation: 1655
I'm using docker . I did not install predis
also my system was missing ext-pcntl
. I added both and the error gone
Upvotes: 0
Reputation: 1186
When using composer require
without a version constraint. It will automatically pick the highest compatible package version for you. Because your PHP installation does not contain the pctnl
extension, the latest version that you "can" install is v0.1.0. You can see the extension getting added in v0.2.0 (Commit)
Using the --ignore-platform-reqs
flag is a bad practice most of the time. Sure, it will install the package for you. But these extensions are crucial when running Laravel Horizon properly. Ignoring the error is not the correct option here. Please look for a way to install/enable the missing extensions on your system.
The latest laravel/horizon
version requires 3 PHP extensions: json
, pcntl
& posix
. I normally
You can check which extensions are installed with the following command:
php -m
Alternatively, you can also check if the extensions are installed by pasting those requirements in the composer.json
file and just run composer update
to see if you are missing any extensions:
{
"require": {
"ext-json": "*",
"ext-pcntl": "*",
"ext-posix": "*",
// Other requirements ...
}
}
Upvotes: 0