【问题标题】:Laravel blade template is not working - Call to undefined function Illuminate\View\Compilers\token_get_all()Laravel 刀片模板不起作用 - 调用未定义的函数 Illuminate\View\Compilers\token_get_all()
【发布时间】:2014-07-29 23:55:47
【问题描述】:

我刚安装了 Laravel 4.2.7,开始编译刀片模板时遇到了一些问题。

所以Laravel在HomeController中自带了这个功能

public function showWelcome()
{
    return View::make('hello');
}

我决定通过添加以下内容将一些变量添加到 hello 视图中:

public function showWelcome()
{
    $data['test'] = 'hello world!';
    return View::make('hello', $data);
}

并且...将文件名从hello.php 更改为hello.blade.php,因为我想打印出变量test

一旦我刷新了 Laravel 附带的“你已经到达”页面的默认页面,它就会给我一个异常:

Symfony\Component\Debug\Exception\FatalErrorException thrown with message "Call to undefined function Illuminate\View\Compilers\token_get_all()"

Stacktrace:
#1 Symfony\Component\Debug\Exception\FatalErrorException in /Applications/AMPPS/www/weinternship/laravel/vendor/laravel/framework/src/Illuminate/View/Compilers/BladeCompiler.php:118
#0 Illuminate\Exception\Handler:handleShutdown in <#unknown>:0

我使用过 Laravel 4.1.28,之前从未遇到过这个问题。我做错了什么?

编辑

在我的 hello.blade.php 内容中

我刚刚在 &lt;div class="welcome'&gt;&lt;/div&gt; 中插入了 {{$test}}

【问题讨论】:

  • hello.blade.php的内容添加到问题中
  • 你运行的是什么版本的 PHP?
  • 试过运行 PHP 5.4 和 5.5 还是不行

标签: php laravel laravel-4


【解决方案1】:

您的 php 版本没有使用 tokenizer 编译。

http://us.php.net/manual/en/ref.tokenizer.php

您可能正在运行旧版本的 PHP。这些函数是在 PHP 4.2.0 中引入的:

http://php.net/manual/en/function.token-get-all.php

【讨论】:

  • PHP 5.4 和 5.5 都试过了,还是不行 :(
  • 尝试运行 function_exists('token_get_all') 如果它返回 false 那是你的问题并且你的 php 安装有问题
  • 看来您需要重新安装 php.ini 文件。如果您使用的是 Mac,我建议您使用 Homebrew:brew.sh 如果您使用的是 Windows,我建议您使用包管理器
【解决方案2】:

我遇到了同样的错误,在打开 php.ini 文件时,我发现标记器扩展被禁用。

extension=tokenizer.so

启用它,重新启动 apache,它就可以工作了。

P.S 我也遇到了 Open ssl 错误,我也启用了该扩展:

extension=openssl.so 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-08-24
    • 2014-11-15
    • 2016-03-11
    • 2013-06-04
    • 1970-01-01
    • 1970-01-01
    • 2013-02-03
    • 2018-05-28
    相关资源
    最近更新 更多