我有以下PHP文件。它在开发中工作。它们具有相同的命名空间和相同的PHP版本。当我部署到Heroku时,会出现一个错误。你知道为什么吗?
Product.php
namespace app\models;
class Product extends \yii\db\ActiveRecord
public function getEbay() {
return $this->hasOne(Ebay::className(), ['product_id' => 'id'])->inverseOf('product'); # line 56Ebay.php
namespace app\models;
class Ebay extends \yii\db\ActiveRecord2015-03-25T02:00:01.003508+00:00appweb.1:25-2015 02:00 UTC PHP致命错误:类‘app\model\Ebay’在第56行/app/model/Product.php中找不到
>heroku run php --version
Running `php --version` attached to terminal... up, run.5360
PHP 5.6.6 (cli) (built: Feb 19 2015 10:11:22)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2015, by Zend Technologies本地:
$ php --version
PHP 5.6.6 (cli) (built: Feb 25 2015 13:54:50)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies好的,我甚至把use放在index.php中,它仍然失败。
C:\Users\Chloe\workspace\project>heroku run cat web/index.php
Running `cat web/index.php` attached to terminal... up, run.3679
<?php
// comment out the following two lines when deployed to production
if ($_SERVER['SERVER_NAME'] == 'localhost' || $_SERVER['SERVER_NAME'] == '127.0.0.1') {
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');
}
require(__DIR__ . '/../vendor/autoload.php');
require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php');
$config = require(__DIR__ . '/../config/web.php');
use app\models; Ebay::className();
(new yii\web\Application($config))->run();
C:\Users\Chloe\workspace\project>heroku logs
...
2015-03-26T17:10:13.590855+00:00 app[web.1]: [26-Mar-2015 17:10:13 UTC] PHP Fatal error: Class 'Ebay' not found in /app/web/index.php on line 14发布于 2015-03-26 17:31:37
好吧我找到了。这是因为该文件在Git和Heroku中被命名为EBay.php,但在Windows文件系统上却被命名为Ebay.php。诅咒你,吉特!这解决了问题。
git mv -f models/EBay.php models/Ebay.php这个命令失败了,所以我不得不进一步调查:
heroku run ls models/Ebay.phphttps://stackoverflow.com/questions/29246487
复制相似问题