当前位置: 动力学知识库 > 问答 > 编程问答 >

php - Parse error in Artisan when running "laravel new appName"

问题描述:

I recently decided to use Laravel and tried to create a test application to see how it works. I ran

laravel new appName

and got this error:

Parse error: parse error, expecting "identifier (T_STRING)"' or `"variable

(T_VARIABLE)"' or `'{'' or `'$'' in /Users/ramibazzi/testApp/artisan on line 31

Script php artisan clear-compiled handling the post-install-cmd event returned

with an error

[RuntimeException]

Error Output:

run-script [--dev] [--no-dev] [-l|--list] [script] [args1] ... [argsN]

Here's a screenshot:

What is this error and how can I fix it?

网友答案:

You're running a version of PHP below 5.5. The line the parse error is occurring on reads:

$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);

This is illegal in PHP 5.4. The feature being used here, classname resolution via ::class, was added in PHP 5.5; prior to that, trying to use class as a static property was a syntax error.

At the time of writing, the Laravel installation docs list the minimum version of PHP required to run Laravel as 5.5.9. Upgrade PHP to version 5.5.9 or later, and try again.

分享给朋友:
您可能感兴趣的文章:
随机阅读: