John Davidson

laravel - Why composer.json requires PHP 7.4 but server is running PHP 7.3 doesn't break in deployment?

0 comments
Message:


Our server is running PHP 7.3 but composer.json file requires PHP 7.4. We accidentally deployed to the server but it didn’t break. We are wondering if this is a cache issue or something else? Can somebody share some lights here? We would like to know which potential parts prevent server crashing.


We are not able to run composer install or update manually to do some experiments because it is on production server. However, we have tried to reproduce in our local but it always break when we run composer install.


NOTE: We are using Forge to do deployment


Here is our deployment script


date
cd /home/forge/default
git pull origin master
composer install --no-dev --prefer-dist
php artisan migrate --force
npm install
npm run production
echo “” | sudo -S service php7.3-fpm reload

Here is our composer.json


{
“name”: “laravel/laravel”,
“type”: “project”,
“description”: “The Laravel Framework.“,
“keywords”: [
“framework”,
“laravel”
],
“license”: “MIT”,
“require”: {
“php”: “^7.4|^8.0",
“algolia/algoliasearch-client-php”: “^2.7",
“algolia/scout-extended”: “^1.10",
“backup-manager/laravel”: “^2.0",
“ckfinder/ckfinder-laravel-package”: “v3.5.1.6",
“cviebrock/eloquent-sluggable”: “^7.0",
“davejamesmiller/laravel-breadcrumbs”: “^5.3",
“doctrine/dbal”: “^2.11",
“fideloper/proxy”: “^4.4",
“fruitcake/laravel-cors”: “^2.0",
“geoip2/geoip2”: “^2.9",
“graham-campbell/markdown”: “^13.1",
“guzzlehttp/guzzle”: “^6.3.1|^7.0.1",
“intervention/image”: “^2.5",
“jenssegers/agent”: “^2.6",
“jordanmiguel/laravel-popular”: “^1.0",
“kyslik/column-sortable”: “^6.3",
“laracasts/presenter”: “^0.2.1",
“laravel/framework”: “^7.29",
“laravel/passport”: “^9.3",
“laravel/scout”: “^8.3",
“laravel/tinker”: “^2.5",
“laravel/ui”: “^2.0",
“laravelcollective/html”: “^6.2",
“laravelium/sitemap”: “^7.0",
“league/flysystem-aws-s3-v3”: “^1.0",
“mtownsend/read-time”: “^1.1",
“otisz/laravel-imgix”: “^3.0",
“renatomarinho/laravel-page-speed”: “^1.8",
“sentry/sentry-laravel”: “^2.1",
“spatie/dns”: “^1.4",
“spatie/laravel-csp”: “^2.6",
“spatie/laravel-permission”: “^3.17",
“themsaid/forge-sdk”: “^2.2",
“toin0u/geocoder-laravel”: “^4.1",
“torann/geoip”: “^1.2",
“tucker-eric/eloquentfilter”: “^2.3",
“unisharp/laravel-filemanager”: “dev-master”
},
“require-dev”: {
“barryvdh/laravel-debugbar”: “^3.5”,
“laravel/dusk”: “^6.11”,
“laravel/telescope”: “^3.5”,
“laravel/tinker”: “^2.5”,
“mockery/mockery”: “^1.3.1”,
“nunomaduro/collision”: “^4.3”,
“phpunit/phpunit”: “^8.5.8|^9.3.3”,
“fakerphp/faker”: “^1.9.1”,
“facade/ignition”: “^2.0”
},
“config”: {
“optimize-autoloader”: true,
“preferred-install”: “dist”,
“sort-packages”: true,
“platform”: {
“php”: “7.4”
}
},
“extra”: {
“laravel”: {
“dont-discover”: [
“laravel/telescope”
]
}
},
“autoload”: {
“psr-4”: {
“App\\“: “app/“,
“Mpociot\\Versionable\\“: “packages/mpociot/versionable/src/Mpociot/Versionable/“,
“CKSource\\CKFinderBridge\\“: “packages/ckfinder/ckfinder-laravel-package/src/“,
“CKSource\\CKFinder\\“: “packages/ckfinder/ckfinder-laravel-package/_connector/”
},
“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”
]
}
}


My Answer:
If your server is running PHP 7.3 but your Laravel project requires PHP 7.4, you have a few options to resolve this issue:

1. Upgrade your server to PHP 7.4: If possible, you can upgrade your server to PHP 7.4 to match the requirements of your Laravel project. This will ensure that your project runs smoothly without any compatibility issues.

2. Modify composer.json: If upgrading your server is not an option, you can try modifying the composer.json file of your Laravel project to specify PHP 7.3 as the required PHP version. However, keep in mind that this may not be recommended if your project relies on features or improvements introduced in PHP 7.4.

3. Use a local development environment: If you are unable to upgrade your server or modify the composer.json file, you can set up a local development environment with PHP 7.4 to work on your Laravel project. Once you have completed your work, you can deploy the project to your server.

It is important to ensure that your server environment matches the requirements of your Laravel project to avoid any compatibility issues and ensure smooth operation.

Rate this post

3 of 5 based on 1868 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us