我有一个使用Heroku设置的应用,设置正确Procfile
并从composer.lock
移除.gitignore
。该应用程序是Laravel 4.2安装,带有自定义artisan命令,每周五发送一封电子邮件;它很简单,没什么复杂的。
该命令位于app/commands
,类(sendEmail)在app/start/artisan.php
中注册。我不知道是否需要使用composer.json来自动加载该类,但我觉得它已经包含在内,因为app/
中的任何类都已经自动加载了。
这是我推送到Heroku后发生的事情:
vagrant@homestead:~/Code/email-schedule/email-schedule$ git push heroku master
Enter passphrase for key '/home/vagrant/.ssh/id_rsa':
Initializing repository, done.
Counting objects: 76, done.
Compressing objects: 100% (63/63), done.
Writing objects: 100% (76/76), 33.09 KiB | 0 bytes/s, done.
Total 76 (delta 2), reused 0 (delta 0)
-----> PHP app detected
-----> No runtime requirements in composer.json, defaulting to PHP 5.6.0.
-----> Installing system packages...
- PHP 5.6.0
- Apache 2.4.10
- Nginx 1.6.0
-----> Installing PHP extensions...
- zend-opcache (automatic; bundled, using 'ext-zend-opcache.ini')
-----> Installing dependencies...
Composer version 69afedb49c48239e4bb7219ec1bc2e1ee5b83595 2014-09-24 18:19:25
Loading composer repositories with package information
Installing dependencies from lock file
- Installing guzzlehttp/streams (2.1.0)
Downloading: 100%
- Installing guzzlehttp/guzzle (4.2.2)
Downloading: 100%
- Installing symfony/translation (v2.5.4)
Downloading: 100%
- Installing symfony/security-core (v2.5.4)
Downloading: 100%
- Installing symfony/routing (v2.5.4)
Downloading: 100%
- Installing symfony/process (v2.5.4)
Downloading: 100%
- Installing symfony/http-foundation (v2.5.4)
Downloading: 100%
- Installing symfony/event-dispatcher (v2.5.4)
Downloading: 100%
- Installing symfony/debug (v2.5.4)
Downloading: 100%
- Installing psr/log (1.0.0)
Downloading: 100%
- Installing symfony/http-kernel (v2.5.4)
Downloading: 100%
- Installing symfony/finder (v2.5.4)
Downloading: 100%
- Installing symfony/dom-crawler (v2.5.4)
Downloading: 100%
- Installing symfony/css-selector (v2.5.4)
Downloading: 100%
- Installing symfony/console (v2.5.4)
Downloading: 100%
- Installing symfony/browser-kit (v2.5.4)
Downloading: 100%
- Installing swiftmailer/swiftmailer (v5.2.2)
Downloading: 100%
- Installing stack/builder (v1.0.2)
Downloading: 100%
- Installing predis/predis (v0.8.7)
Downloading: 100%
- Installing phpseclib/phpseclib (0.3.8)
Downloading: 100%
- Installing patchwork/utf8 (v1.1.25)
Downloading: 100%
- Installing nesbot/carbon (1.12.0)
Downloading: 100%
- Installing monolog/monolog (1.10.0)
Downloading: 100%
- Installing nikic/php-parser (v0.9.5)
Downloading: 100%
- Installing jeremeamia/superclosure (1.0.1)
Downloading: 100%
- Installing ircmaxell/password-compat (1.0.3)
Downloading: 100%
- Installing filp/whoops (1.1.2)
Downloading: 100%
- Installing d11wtq/boris (v1.0.8)
Downloading: 100%
- Installing symfony/filesystem (v2.5.4)
Downloading: 100%
- Installing classpreloader/classpreloader (1.0.2)
Downloading: 100%
- Installing laravel/framework (v4.2.9)
Downloading: 100%
Generating optimized autoload files
PHP Fatal error: Class 'sendEmail' not found in /tmp/build_69f41eb6-2466-44d0-9930-452a65fa422a/app/start/artisa
n.php on line 14
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Class 'sendEmail' not fou
nd","file":"\/tmp\/build_69f41eb6-2466-44d0-9930-452a65fa422a\/app\/start\/artisan.php","line":14}}Script php artisan cl
ear-compiled handling the post-install-cmd event returned with an error
[RuntimeException]
Error Output: PHP Fatal error: Class 'sendEmail' not found in /tmp/build_69f41eb6-2466-44d0-9930-452a65fa422a/app/sta
rt/artisan.php on line 14
install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-plugins] [--no-custom-installers] [--no-s
cripts] [--no-progress] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [packages1] ... [packagesN]
! Push rejected, failed to compile PHP app
To git@heroku.com:xxxx.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:xxxx.git'
我尝试了各种各样的事情,例如artisan optimize
,composer dump-autoload
,artisan clear-compiled
,但没有任何效果。看起来Artisan在某处缓存了我的自定义命令类,而Heroku正试图访问它,但我并不完全确定。如何修复缺少的类错误?