成功构建错误空白屏幕后,将Symfony2从TravisCI部署到Heroku

时间:2014-11-25 14:58:46

标签: php symfony heroku travis-ci

我得到一个空白屏幕,但这是错误日志的结果。它似乎是预先挂起的/ tmp / build_xxxx ...

dev& amp;刺激在当地工作。

代码在这里...... https://github.com/TransformCore/dial-tone-frontend

  

2014-11-25T14:43:27.388147 + 00:00 heroku [router]:at = info method = GET path =" /css/bootstrap.css" host = dial-tone-frontend.herokuapp.com request_id = 1bdcc1f4-4d8b-42b0-a85d-8b265d2665bd fwd =" 80.5.64.178" dyno = web.1 connect = 1ms service = 8ms status = 500 bytes = 208   2014-11-25T14:43:27.388931 + 00:00 app [web.1]:[2014-11-25 14:43:27] request.CRITICAL:未捕获PHP异常InvalidArgumentException:"文件&#34 ; /tmp/build_23552b1c8333d8e8b9b475444451531c/app/config/routing.yml"不存在。"在/app/app/cache/prod/classes.php第1575行{"例外":" [对象](InvalidArgumentException:文件\" / tmp / build_23552b1c8333d8e8b9b475444451531c / app / config /routing.yml \"不存在。在/app/app/cache/prod/classes.php:1575)"} []   2014-11-25T14:43:27.390315 + 00:00 app [web.1]:[25-Nov-2014 14:43:27 UTC] PHP致命错误:未捕获异常' InvalidArgumentException'消息'文件" /tmp/build_23552b1c8333d8e8b9b475444451531c/app/config/routing.yml"不存在。'在/app/app/cache/prod/classes.php:1575   2014-11-25T14:43:27.390355 + 00:00 app [web.1]:堆栈跟踪:   2014-11-25T14:43:27.390525 + 00:00 app [web.1]:#0 /app/app/cache/prod/classes.php(2301):Symfony \ Component \ Config \ FileLocator-> locate( ' / tmp / build_2355 ...',NULL,true)   2014-11-25T14:43:27.390779 + 00:00 app [web.1]:#1 /app/vendor/symfony/symfony/src/Symfony/Component/Routing/Loader/YamlFileLoader.php(49):Symfony \部件\ HttpKernel \配置\ FileLocator->定位(' / TMP / build_2355 ...')   2014-11-25T14:43:27.391220 + 00:00 app [web.1]:#3 /app/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php(58):Symfony \ Component \ Config \ Loader \ DelegatingLoader-> load(' / tmp / build_2355 ...',NULL)   2014-11-25T14:43:27.391369 + 00:00 app [web.1]:#4 /app/app/cache/prod/classes.php(1502):symfony \ Bundle \ FrameworkBundle \ Routing \ DelegatingLoader->加载(' / tmp / build_2355 ...',NULL)   2014-11-25T14:43:27.391484 + 00:00 app [web.1]:#5 /app/app/cache/prod/classes.php(在/app/app/cache/prod/classes.php上线) 1575   2014-11-25T14:43:27.391759 + 00:00 app [web.1]:10.36.138.222 - - [25 / Nov / 2014:14:43:27 +0000]" GET / css / bootstrap。 css HTTP / 1.1" 500 - " - " " Mozilla / 5.0(Macintosh; Intel Mac OS X 10_10_0)AppleWebKit / 537.36(KHTML,与Gecko一样)Chrome / 38.0.2125.122 Safari / 537.36"   2014-11-25T14:43:27.389956 + 00:00 app [web.1]:[2014-11-25 14:43:27] request.CRITICAL:处理异常时抛出异常(Twig_Error_Loader:" / tmp / build_23552b1c8333d8e8b9b475444451531c / vendor / symfony / symfony / src / Symfony / Bundle / FrameworkBundle / Resources / views"目录不存在。){" exception":" [object](InvalidArgumentException :文件\" /tmp/build_23552b1c8333d8e8b9b475444451531c/app/config/routing.yml \"不存在。在/app/app/cache/prod/classes.php:1575)"} []   2014-11-25T14:43:27.390994 + 00:00 app [web.1]:#2 /app/vendor/symfony/symfony/src/Symfony/Component/Config/Loader/DelegatingLoader.php(45):Symfony \ Component \ Routing \ Loader \ YamlFileLoader-> load(' / tmp / build_2355 ...',NULL)

1 个答案:

答案 0 :(得分:1)

我认为问题在于,在生产环境中使用的是'%kernel.root_dir%'的缓存版本。

Heroku在像' / tmp / build ...'这样的目录中构建了一个slug。但是在目录/ app。中运行它。

我找到的唯一解决方法是更改​​用于计算根目录的逻辑。

我改变了我的应用程序/ AppKernel.php'添加此方法:

public function getRootDir()
{
  if (isset($_ENV['SYMFONY_ENV']) && $_ENV['SYMFONY_ENV'] == 'prod') {
    // Workaround to avoid problem with the slug of heroku
    return '/app/app';
  }
  return parent::getRootDir();
}