The error you’re seeing:
PHP Fatal error: Type of Carbon\CarbonPeriod::EXCLUDE_START_DATE must be compatible with DatePeriod::EXCLUDE_START_DATE of type int in /home/ralvez/Code/PHP/careyalvezart/vendor/nesbot/carbon/src/Carbon/CarbonPeriod.php on line 184
usually happens because of a mismatch between your PHP version and the version of the nesbot/carbon package installed in your project.
Why this happens:
- Newer versions of PHP (especially PHP 8.2+) introduced stricter type compatibility for class constants and properties.
- If your project’s
vendordirectory orcomposer.lockreferences an older version of Carbon, it may not be compatible with your current PHP version.
How to fix:
-
Delete
vendorandcomposer.lock
Remove your current dependencies and lock file to force Composer to resolve compatible versions.rm -rf vendor composer.lock -
Check your PHP version
Make sure you know which PHP version you’re running:php -v -
Update Composer dependencies
Run:composer installThis will install the versions specified in your
composer.jsonthat are compatible with your PHP version. -
If you still get errors, explicitly require the latest Carbon:
composer require nesbot/carbonThis will ensure you have the latest version compatible with your PHP version.
-
If you get a lot of errors during
composer installorcomposer require, try updating Composer itself:composer self-update
Summary:
This is a common issue after a system re-install if your PHP version changes. The key is to clear out old dependencies and let Composer resolve new, compatible versions.
If you still have issues, please post the output of php -v and your composer.json so we can help further!