doujiao4710 2014-06-02 20:42
浏览 166
已采纳

Laravel 4.2无法正确渲染Blade视图

Running on Ubuntu 12.04 using HHVM 3.1.0 (the latest release). I've just recently tried updating from Laravel 4.1 to 4.2, and am having a really strange issue with Blade views not compiling correctly. There were no errors in the Laravel logs, so I checked out the HHVM logs. Turns out when trying to load a stored view using blade, HHVM was having compile errors. I opened up the stored view, and found that different uses of Blade aren't compiling correctly.

Original Blade Code:

<head>
  @include('layouts.partials._favicon')
</head>

<body id="signup-rotate">
  @include('layouts.partials._flash-messages')
...

Incorrect Compilation:

<head>
 <?php echo $__env->make(, array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>('layouts.partials._favicon')
</head>

<body id="signup-rotate">
  <?php echo $__env->make('layouts.partials._flash-messages', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
...

As you can see, the code in the header is for some reason not adding the view to be included into the function, and is appending it to the end. This is obviously causing HHVM to not be able to compile the code, and an error is thrown. It seems strange to me that most of these includes are working, but others aren't.

Is this a known issue with Laravel 4.2, or is there something unique in my case that would cause this? It seems like Blade is also missing some tags, and so I'll have random blade syntax in my view files when they display (I can provide some code examples if requested).

Update This is actually a known issue and has been reported both in the Laravel and HHVM git repositories. It has apparently been fixed in HHVM nightlies, and will be working properly in the next release.

https://github.com/facebook/hhvm/issues/2841

  • 写回答

1条回答 默认 最新

  • doudao1282 2014-08-07 17:28
    关注

    As this comes up pretty high on search results, it is probably worth noting that this is indeed fixed as of the HHVM 3.2.0 release.

    If you are still stuck on a release < 3.2.0 for whatever reason, I was able to deal with it by finding the line on which HHVM threw the error (check the log files) and adding in a {{ "" }}. The GitHub issue you mentioned explains this in greater detail, but it seems that the Blade parsing was causing some statements to fall on an array boundary -- the "fix" I mentioned just pushes your Blade code onto the next array. It's not pretty, but it works if you need it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?