dingling136 2014-12-21 20:27:42 9589次浏览 4条回复 1 0 0

执行CMD命令init

Parse error: syntax error, unexpected '[' in <div style="color:#ff00000;">项目路径</div>\yii\init on line 75
PHP Parse error: syntax error, unexpected '[' in /home/wwwroot/yii/init on line 75

第75--80行代码如下:

$callbacks = ['setCookieValidationKey', 'setWritable', 'setExecutable'];
foreach ($callbacks as $callback) {
    if (!empty($env[$callback])) {
        $callback($root, $env[$callback]);
    }
}

好像是密钥之类 请问如何解决

将相关中括号都改成php中数组形式的括号,包括environments目录下index.php文件都修改,提示如下:

Which environment do you want the application to be initialized in?

[0] Development
[1] Production

Your choice [0-1, or "q" to quit] 1

Initialize the application under 'Production' environment? [yes|no] yes

Start initialization ...

generate backend/config/main-local.php
generate backend/config/params-local.php
generate backend/web/index.php
generate common/config/main-local.php
generate common/config/params-local.php
generate console/config/main-local.php
generate console/config/params-local.php
generate frontend/config/main-local.php
generate frontend/config/params-local.php
generate frontend/web/index.php
generate yii
generate cookie validation key in backend/config/main-local.php
generate cookie validation key in frontend/config/main-local.php

  chmod 0777 backend/runtime
  chmod 0777 backend/web/assets
  chmod 0777 frontend/runtime
  chmod 0777 frontend/web/assets
  chmod 0755 yii
... initialization completed.

但是还是没有生成入口文件啊

  • 回复于 2014-12-21 20:30 举报

    PHP Parse error: syntax error, unexpected '[' in /home/wwwroot/yii/init on line 75

  • 回复于 2014-12-21 20:41 举报

    将相关中括号都改成php中数组形式的括号,包括environments目录下index.php文件都修改,提示如下:

    Which environment do you want the application to be initialized in?
    
      [0] Development
      [1] Production
    
      Your choice [0-1, or "q" to quit] 1
    
      Initialize the application under 'Production' environment? [yes|no] yes
    
      Start initialization ...
    
       generate backend/config/main-local.php
       generate backend/config/params-local.php
       generate backend/web/index.php
       generate common/config/main-local.php
       generate common/config/params-local.php
       generate console/config/main-local.php
       generate console/config/params-local.php
       generate frontend/config/main-local.php
       generate frontend/config/params-local.php
       generate frontend/web/index.php
       generate yii
       generate cookie validation key in backend/config/main-local.php
       generate cookie validation key in frontend/config/main-local.php
          chmod 0777 backend/runtime
          chmod 0777 backend/web/assets
          chmod 0777 frontend/runtime
          chmod 0777 frontend/web/assets
          chmod 0755 yii
    
      ... initialization completed.
    

    但是还是没有生成入口文件啊

  • 回复于 2014-12-22 11:07 举报

    PHP Parse error: syntax error, unexpected '[' in /home/wwwroot/yii/init on line 75

    php 版本的问题,yii2 最低要求 php5.4

    generate backend/web/index.php
    ...
    generate frontend/web/index.php
    

    这个不是已经生成入口文件了么?

  • 回复于 2014-12-22 12:35 举报

    Yii2 要求 php 版本为 5.4 以上,在 PHP 新版本中数组的写法由 $array = array('1', '2', '3') 变为了 $array = ['1', '2', '3']

您需要登录后才可以回复。登录 | 立即注册