為什麼 composer.json 需要 PHP 7.4 但服務器正在運行 PHP 7.3 不會中斷部署? (Why composer.json requires PHP 7.4 but server is running PHP 7.3 doesn't break in deployment?)


問題描述

為什麼 composer.json 需要 PHP 7.4 但服務器正在運行 PHP 7.3 不會中斷部署? (Why composer.json requires PHP 7.4 but server is running PHP 7.3 doesn't break in deployment?)

我們的服務器正在運行 PHP 7.3,但 composer.json 文件需要 PHP 7.4。我們不小心部署到服務器上,但它沒有中斷。我們想知道這是緩存問題還是其他問題?有人可以在這里分享一些燈嗎?我們想知道哪些潛在部件可以防止服務器崩潰。

我們無法手動運行 composer install or update 來做一些實驗,因為它在生產服務器上。但是,我們嘗試在本地重現,但是當我們運行 composer install 時它總是會中斷。

注意:我們正在使用 Forge 進行部署

這是我們的部署腳本

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

這是我們的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”
        ]
    }
}

參考解法

方法 1:

If you have older viersion of PHP in server it dosn't mean it always break the program. But if Your program or Your dependencies used any new features or any removed features it will break. in here you can see the differences between 7.3 and 7.4

方法 2:

You should use PHP 7.4 if composer.json requires this. If you don't want or not able to run composer install in the production server then at first try this in local and then deploy the source code to production.

Initially, your application may not throw any exception but there are lots of possibilities there are some features that will not work in PHP 7.3

(by cjyharshasoysaEmtiaz Zahid)

參考文件

  1. Why composer.json requires PHP 7.4 but server is running PHP 7.3 doesn't break in deployment? (CC BY‑SA 2.5/3.0/4.0)

#forge #composer-php #Laravel #PHP #server






相關問題

forge.facebook.authorize 不重定向網站 (forge.facebook.authorize not redirecting for website)

iOS6 和 XCode 4.5 - 無法將應用上傳到應用商店 (iOS6 and XCode 4.5 - Unable to upload app to app store)

trigger.io facebook аўтарызаваць «нечаканы збой» з iphone 5 (trigger.io facebook authorize "unexpected failure" with iphone 5)

Đóng ứng dụng di động Trigger.io forge qua javascript (Android / iOS) - để áp dụng Tải lại (Closing a Trigger.io forge mobile app via javascript (Android / iOS) - in order to apply Reload)

為什麼@inject 方法在實時服務器上不起作用 (why @inject method is not working on the live server)

在 GForge、LDAP 身份驗證中,如何設置屬性 authenticatedBind 的值? (In GForge, LDAP Authentication, how do I set the value for the property authenticatedBind?)

創建一個類對象列表以將它們與另一個類對象進行比較 (creating a list of class objects to compare them with another class object)

Autodesk Forge 如何保存和顯示標記 (Autodesk Forge how to save and show Markups)

如何在 Forge Laravel 網站上進行 404 錯誤的高級調試 (How to do advanced debugging of 404 Error on Forge Laravel Website)

Forge:選擇單個零件:無法在零件之間切換 (Forge: Select a single part: cant switch between parts)

為什麼 composer.json 需要 PHP 7.4 但服務器正在運行 PHP 7.3 不會中斷部署? (Why composer.json requires PHP 7.4 but server is running PHP 7.3 doesn't break in deployment?)

是否可以通過從外部網頁接收特定 ID 來實現 Forge Viewer 中的突出顯示功能? (Is it possible to implement the highlight function in Forge Viewer by receiving a specific ID from an external web page?)







留言討論