Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing Yii 2 demo application

Tags:

php

yii

yii2

i am trying to install yii 2 and to run the basic or advanced application.

i have tried the steps given here Setting up preview of Yii2 to do this.

the steps i followed,

1 - Installed the composer
2 - Use composer to install the app alongwith dependencies(Yii): php path/to/composer.phar create-project --stability=dev yiisoft/yii2-app-basic my_yii2_trial
3 - Access app from http://localhost/my_yii2_trial/web

The problem is, i am getting this syntax error.

Parse error: syntax error, unexpected '[', expecting ')' in D:\xampp\htdocs\my_yii2_trial\vendor\yiisoft\yii2\yii\Yii.php on line 25 

can any body help to resolver this issue pls

like image 642
dev1234 Avatar asked Nov 02 '13 11:11

dev1234


2 Answers

Yii2 has started using PHP 5.4's Short array syntax. Your error creeps up because of:

spl_autoload_register(['Yii', 'autoload'], true, true);

in Yii.php, which is the new short array syntax. As you have already figured out, you need to install PHP 5.4 now to run Yii2 apps.


The commit which made the changes to short array syntax.

The docs and composer details that have been changed.

The discussion where the decision to move to PHP 5.4 was made.


As Yii2 is still in heavy development, its requirements are also changing. So be sure to read the readme thoroughly before installing.


See also the Backward Incompatible changes list for PHP 5.4, to make changes to your existing code.

like image 173
bool.dev Avatar answered Sep 26 '22 14:09

bool.dev


Install PHP 5.4 to resolve this issue.

like image 37
dev1234 Avatar answered Sep 24 '22 14:09

dev1234