Laravel 5.5项目安装laravel/cashier v7.0.5依赖报错求助
Hey there, let's break down how to fix this dependency issue you're facing. First off, installing php-curl isn't resolving the problem because this is a composer version constraint conflict, not a missing PHP extension issue (though we'll double-check that too just in case).
Root Cause
Laravel Cashier v7.0.5 has a strict requirement for stripe/stripe-php ~4.0 — meaning it only works with Stripe PHP SDK versions from 4.0.x up to (but not including) 5.0. If your composer.json specifies a higher version of the Stripe SDK (like ^5.0 or newer), Composer will throw a conflict error.
Step-by-Step Fixes
1. Adjust Stripe SDK Version in composer.json
First, open your project's composer.json file and locate the stripe/stripe-php entry in the require section. Update its version constraint to match what Cashier requires:
"require": { // ... other dependencies "laravel/cashier": "v7.0.5", "stripe/stripe-php": "~4.0" }
- The
~4.0constraint tells Composer to install the latest compatible version of the Stripe SDK in the 4.x branch.
2. Run Composer Update
Save the changes to composer.json, then run this command in your terminal to update just the relevant packages (avoid updating all dependencies unnecessarily):
composer update laravel/cashier stripe/stripe-php
If you run into any issues, you can try clearing Composer's cache first:
composer clear-cache
3. Verify PHP Curl Extension is Enabled (Just to Be Safe)
Even though this wasn't the root cause here, let's confirm the curl extension is active for your CLI PHP environment (since Composer uses CLI PHP):
Run this command to check:
php -m | grep curl
If curl doesn't show up, you may need to:
- Restart your PHP-FPM service (if using it) or web server
- Ensure the curl extension is enabled in your CLI-specific
php.inifile (sometimes there's a separate ini for CLI vs web)
Example composer.json Snippet
For reference, here's how the relevant section of your composer.json should look after adjustment:
"require": { "laravel/framework": "5.5.*", "laravel/cashier": "~7.0", "stripe/stripe-php": "~4.0", // ... other dependencies }
内容的提问来源于stack exchange,提问作者ltdev

