Forum

Laravel 5 Error on Installation.

I'm trying to create a new Laravel project via "laravel new project_name" however it stays on crafting the application for a minute or two and then it shows this error:

Crafting application...

Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T
_STRING) or variable (T_VARIABLE) or '{' or '$' in I:\PP\artisan on line 31
Script php artisan clear-compiled handling the post-install-cmd event returned w
ith an error

[RuntimeException]
Error Output:

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

Application ready! Build something amazing.

Furthermore, when I go to check the installation in my web browser I'm thrown this error:

Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in I:\PP\public\index.php on line 50

Is anyone else facing this error? I've updated my Composer installation as well as the installer for Laravel.

xxyxxyz
xxyxxyz
  • 1 year ago

What version of PHP are you using ?

harikt said:

What version of PHP are you using ?

PHP version is 5.4.16.

kayyyy
Solution

xxyxxyz said:

harikt said:

What version of PHP are you using ?

PHP version is 5.4.16.

Installation

Server Requirements

The Laravel framework has a few system requirements. Of course, all of these requirements are satisfied by the Laravel Homestead virtual machine:

PHP >= 5.5.9 OpenSSL PHP Extension Mbstring PHP Extension Tokenizer PHP Extension

chris said:

xxyxxyz said:

harikt said:

What version of PHP are you using ?

PHP version is 5.4.16.

Installation

Server Requirements

The Laravel framework has a few system requirements. Of course, all of these requirements are satisfied by the Laravel Homestead virtual machine:

PHP >= 5.5.9 OpenSSL PHP Extension Mbstring PHP Extension Tokenizer PHP Extension

I see. Thanks, was this changed recently as I had no problems beforehand when making a new Laravel project.

Yep, it was changed 12 days ago, see https://github.com/laravel/framework/commit/8349040e7381d083868fa40bd7dcaf301f0347e3

It's same problem on PHP V5.6.15

PHP Parse error: syntax error, unexpected T_CLASS, expecting T_STRING or T_VARIABLE or '$' in /opt/lampp/htdocs/laravel_demo/artisan on line 31

I have same problem, check your php version run on shell. In my case the phpinfo shows me 7.0.7 and in my shell runs 5.3.10.... Update php version and i belive it works.

Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /home/mydomain/public/index.php on line 50

-> PHP 5.6.29 (cli) (built: Dec 14 2016 14:03:32) Copyright (c) 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies with the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured) v6.0.5, Copyright (c) 2002-2016, by ionCube Ltd. with Zend Guard Loader v3.3, Copyright (c) 1998-2014, by Zend Technologies

-> Composer version 1.3.1 2017-01-07 18:08:51

-> Laravel Framework version 5.2.45

bigwelly said: Have the same problem with quite the same config :-(