如何在heroku上成功安装Firebase?

时间:2018-10-26 07:02:14

标签: php firebase heroku firebase-realtime-database

我有以下代码可以在本地计算机上正常运行。

 <?php

header("Content-Type:application/json");


require __DIR__.'/vendor/autoload.php';

use Kreait\Firebase\Factory;
use Kreait\Firebase\ServiceAccount;


// This assumes that you have placed the Firebase credentials in the same directory
// as this PHP file.
$serviceAccount = ServiceAccount::fromJsonFile(__DIR__.'/xxxx-xxxxx-xxxxxxxxxxxxx.json');

$firebase = (new Factory)
    ->withServiceAccount($serviceAccount)
    ->create();

$database = $firebase->getDatabase();

$newPost = $database
    ->getReference('blog/posts')
    ->push([
        'title' => 'Post title',
        'body' => 'This should probably be longer.'
    ]);

echo($newPost->getKey());

 echo '{"ResultCode":0,"ResultDesc":"Confirmation received successfully"}';
?>

但是当我将相同的代码上传到heroku应用并尝试运行文件url时,出现500http错误 我会忘记什么。因为香港专业教育学院试图在线寻找解决方案,但没有一个真正的帮助。香港专业教育学院试图重新安装依赖关系,但仍然有同样的问题。

当我今天早晨尝试运行该应用程序时,以下是我的heroku日志错误。

2018-10-27T05:15:35.613487+00:00 heroku[web.1]: Unidling
2018-10-27T05:15:35.613848+00:00 heroku[web.1]: State changed from down to starting
2018-10-27T05:15:37.230016+00:00 heroku[web.1]: Starting process with command `heroku-php-apache2`
2018-10-27T05:15:39.635790+00:00 app[web.1]: Optimizing defaults for 1X dyno...
2018-10-27T05:15:39.776372+00:00 app[web.1]: 4 processes at 128MB memory limit.
2018-10-27T05:15:39.781273+00:00 app[web.1]: Starting php-fpm...
2018-10-27T05:15:41.783183+00:00 app[web.1]: Starting httpd...
2018-10-27T05:15:41.925232+00:00 heroku[web.1]: State changed from starting to up
2018-10-27T05:15:43.694660+00:00 heroku[router]: at=info method=GET path="/rGU7qCmigsrVL4SuYNS01/conf                                                                                           irmation.php" host=cryptic-forest-94367.herokuapp.com request_id=cda944ce-b0ea-4cda-92f9-cba7c9b1c3e5                                                                                            fwd="196.207.150.137" dyno=web.1 connect=0ms service=6ms status=500 bytes=161 protocol=https
2018-10-27T05:15:43.694391+00:00 app[web.1]: [27-Oct-2018 05:15:43 UTC] PHP Warning:  require(/app/rG                                                                                           U7qCmigsrVL4SuYNS01/vendor/composer/../guzzlehttp/psr7/src/functions_include.php): failed to open str                                                                                           eam: No such file or directory in /app/rGU7qCmigsrVL4SuYNS01/vendor/composer/autoload_real.php on lin                                                                                           e 66
2018-10-27T05:15:43.695104+00:00 app[web.1]: [27-Oct-2018 05:15:43 UTC] PHP Fatal error:  require():                                                                                            Failed opening required '/app/rGU7qCmigsrVL4SuYNS01/vendor/composer/../guzzlehttp/psr7/src/functions_                                                                                           include.php' (include_path='.:/app/.heroku/php/lib/php') in /app/rGU7qCmigsrVL4SuYNS01/vendor/compose                                                                                           r/autoload_real.php on line 66
2018-10-27T05:15:43.695646+00:00 app[web.1]: 10.5.165.56 - - [27/Oct/2018:05:15:43 +0000] "GET /rGU7q                                                                                           CmigsrVL4SuYNS01/confirmation.php HTTP/1.1" 500 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Appl                                                                                   eWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36

0 个答案:

没有答案