2017-02-18 111 views
1

我是Heroku的新手,我知道很多類似的問題已經在stackoverflow上詢問過,但我找不到適用於我的任何解決方案。Heroku Laravel 4.2需要Mcrypt PHP擴展

嘗試部署我laravel 4.2的應用程序時,我得到了以下問題:

remote:  > php artisan clear-compiled 
remote:  Mcrypt PHP extension required. 
remote:  Script php artisan clear-compiled handling the post-install-cmd event returned with error code 1 
remote: !  Push rejected, failed to compile PHP app. 

我試圖用heroku run bash命令連接到Heroku的環境,但不能得到mcrypt擴展的狀態,因爲沒有根權限授予我。

還嘗試將heroku buildpacks:set https://github.com/heroku/heroku-buildpack-php設置爲buildpack。但沒有成功。

這是我composer.json

{ 
    "name": "laravel/laravel", 
    "description": "The Laravel Framework.", 
    "keywords": ["framework", "laravel"], 
    "license": "MIT", 
    "require": { 
     "laravel/framework": "4.2.*" 
    }, 
    "autoload": { 
     "classmap": [ 
      "app/commands", 
      "app/library", 
      "app/controllers", 
      "app/models", 
      "app/Lib.php", 
      "app/database/migrations", 
      "app/database/seeds", 
      "app/tests/TestCase.php" 
     ] 
    }, 
    "scripts": { 
     "post-install-cmd": [ 
      "php artisan clear-compiled", 
      "php artisan optimize" 
     ], 
     "post-update-cmd": [ 
      "php artisan clear-compiled", 
      "php artisan optimize" 
     ], 
     "post-create-project-cmd": [ 
      "php artisan key:generate" 
     ] 
    }, 
    "config": { 
     "preferred-install": "dist" 
    }, 
    "minimum-stability": "stable" 
} 

任何幫助深表感謝。

+0

請編輯你的問題並添加你的'composer.json'。 – Chris

+0

@ Chris,更新了composer.json的問題 – meen

回答

3

您還沒有在您的composer.jsonmcrypt擴展中指定PHP版本或依賴項。

開始由依賴於PHP的特定版本:

composer require php ~7.1.0 

您可以~7.0.0~5.6.0更換~7.1.0如果你喜歡。

Heroku includes mcrypt by default如果您使用PHP 5.6。但是,如果你正在使用7.0或7.1,你會need to add it

composer require ext-mcrypt 

然後通過運行composer updatecomposer.lock更新。確保本地所有內容仍按預期工作,然後提交更新的composer.jsoncomposer.lock文件並再次推送到Heroku。

請注意,the mcrypt extension has been deprecated as of PHP 7.1。可能值得考慮升級Laravel 5.1或更高版本,其中replaces mcrypt with openssl,尤其是如果您使用PHP 7.1。

+0

這個回答在我的書中值得+20的聲望。花了幾個小時才找到這個解決方案。非常感謝克里斯! :-) –