将 PHP Laravel 4.2 部署到 Heroku 失败


Deploying PHP Laravel 4.2 to Heroku fails

我有一个简单的Laravel 4.2应用程序,可以在我当地的Homestead机器上运行。 我正在运行OSX Yosemite,带有VirtualBox。

但是,我无法将其部署到Heroku。 我有一个基本的Procfile:

web: vendor/bin/heroku-php-apache2 public/

我还使用

heroku buildpacks:set heroku/php

这是我从 mac 终端运行以下命令时获得的输出:

git push heroku master

输出:

Counting objects: 4305, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (4100/4100), done.
Writing objects: 100% (4305/4305), 4.18 MiB | 93.00 KiB/s, done.
Total 4305 (delta 1298), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Using set buildpack heroku/php
remote: -----> PHP app detected
remote: -----> Bootstrapping...
remote: -----> Installing system packages...
remote:        NOTICE: No runtime required in composer.json; requirements
remote:        from dependencies in composer.lock will be used for selection
remote:        - php (7.0.3)
remote:        - Apache (2.4.16)
remote:        - Nginx (1.8.0)
remote: -----> Enabling PHP extensions...
remote:        - ext-zend-opcache (automatic)
remote: -----> Installing dependencies...
remote:        Composer version 1.0.0-alpha11 2015-11-14 16:21:07
remote:        Loading composer repositories with package information
remote:        Installing dependencies from lock file
remote:          - Installing guzzlehttp/streams (2.1.0)
remote:            Downloading: 100%
remote:        
remote:          - Installing guzzlehttp/guzzle (4.2.3)
remote:            Downloading: 100%
remote:        
remote:          - Installing symfony/translation (v2.5.12)
remote:            Downloading: 100%
remote:        
remote:          - Installing symfony/security-core (v2.5.12)
remote:            Downloading: 100%
remote:        
remote:          - Installing symfony/routing (v2.5.12)
remote:            Downloading: 100%
remote:        
remote:          - Installing symfony/process (v2.5.12)
remote:            Downloading: 100%
remote:        
remote:          - Installing symfony/http-foundation (v2.5.12)
remote:            Downloading: 100%
remote:        
remote:          - Installing symfony/event-dispatcher (v2.8.2)
remote:            Downloading: 100%
remote:        
remote:          - Installing symfony/debug (v2.5.12)
remote:            Downloading: 100%
remote:        
remote:          - Installing psr/log (1.0.0)
remote:            Downloading: 100%
remote:        
remote:          - Installing symfony/http-kernel (v2.5.12)
remote:            Downloading: 100%
remote:        
remote:          - Installing symfony/finder (v2.5.12)
remote:            Downloading: 100%
remote:        
remote:          - Installing symfony/dom-crawler (v2.5.12)
remote:            Downloading: 100%
remote:        
remote:          - Installing symfony/css-selector (v2.5.12)
remote:            Downloading: 100%
remote:        
remote:          - Installing symfony/console (v2.5.12)
remote:            Downloading: 100%
remote:        
remote:          - Installing symfony/browser-kit (v2.5.12)
remote:            Downloading: 100%
remote:        
remote:          - Installing swiftmailer/swiftmailer (v5.4.1)
remote:            Downloading: 100%
remote:        
remote:          - Installing stack/builder (v1.0.3)
remote:            Downloading: 100%
remote:        
remote:          - Installing predis/predis (v0.8.7)
remote:            Downloading: 100%
remote:        
remote:          - Installing phpseclib/phpseclib (0.3.10)
remote:            Downloading: 100%
remote:        
remote:          - Installing patchwork/utf8 (v1.3.0)
remote:            Downloading: 100%
remote:        
remote:          - Installing nesbot/carbon (1.17.0)
remote:            Downloading: 100%
remote:        
remote:          - Installing monolog/monolog (1.17.2)
remote:            Downloading: 100%
remote:        
remote:          - Installing nikic/php-parser (v0.9.5)
remote:            Downloading: 100%
remote:        
remote:          - Installing jeremeamia/superclosure (1.0.2)
remote:            Downloading: 100%
remote:        
remote:          - Installing ircmaxell/password-compat (v1.0.4)
remote:            Downloading: 100%
remote:        
remote:          - Installing filp/whoops (1.1.10)
remote:            Downloading: 100%
remote:        
remote:          - Installing d11wtq/boris (v1.0.8)
remote:            Downloading: 100%
remote:        
remote:          - Installing symfony/filesystem (v2.8.2)
remote:            Downloading: 100%
remote:        
remote:          - Installing classpreloader/classpreloader (1.0.2)
remote:            Downloading: 100%
remote:        
remote:          - Installing laravel/framework (v4.2.19)
remote:            Downloading: 100%
remote:        
remote:        Generating optimized autoload files
remote:        > php artisan clear-compiled
remote:        Mcrypt PHP extension required.
remote:        Script php artisan clear-compiled handling the post-install-cmd event returned with an error
remote:        
remote:        
remote:                              
remote:          [RuntimeException]  
remote:          Error Output:       
remote:                              
remote:        
remote:        
remote:        install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-plugins] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--ignore-platform-reqs] [--] [<packages>]...
remote:        
remote:        
remote: 
remote:  !     Push rejected, failed to compile PHP app
remote: 
remote: Verifying deploy....
remote: 
remote: !   Push rejected to agile-wildwood-99938.
remote: 
To https://git.heroku.com/agile-wildwood-99938.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/agile-wildwood-     99938.git'

在我的本地机器上值得注意的是,当我运行(从我的 laravel 项目根文件夹)时

php artisan

我收到一条类似于 Heroku 部署输出的消息,即

Mcrypt PHP extension required.

我不知道这是否相关? 我的本地机器上没有 Mcrypt 会影响 Heroku 部署,还是 Heroku 输出完全指的是 Heroku 服务器?

我在这里有点挣扎。将不胜感激。

谢谢查理

如果您的应用程序需要 MCrypt 扩展,则需要通过将exr-mcrypt作为要求添加到您的composer.json来启用它。见 https://devcenter.heroku.com/articles/php-support#extensions