0

我开发了一个 Symfony2 项目(v2.2.2),它在本地运行良好。

当我在我的服务器上部署它时,我遇到了 2 个问题:

  • 文件夹 /bin 不通过 Filezilla 传输(无法开始传输)
  • 尝试在调试模式下访问 web/app.php/ 时遇到解析错误(见下文)

首先,我不明白为什么它会在本地工作而不是在生产环境中工作。我也猜到了这些错误链接,但我不知道 /bin 用于什么(仅包含 2 个文件教义和教义.php),如果我在本地删除它,它会继续工作......

解析错误如下:

“FatalErrorException:解析:语法错误,/home/colocall/twinkler/src/Tk/ExpenseBundle/Services/Expenses.php 第 21 行中的意外 '['”

费用.php 第 15->25 行:

public function getAllExpenses($member, $group)

{
    $all_expenses_col = $group->getExpenses();
    $all_expenses = array();

    foreach($all_expenses_col as $expense){
        $all_expenses[] = [$expense, $this->forYou($member, $expense)];
    }

    return $all_expenses;
}

也许链接到:当我尝试通过 ssh 连接更新我的数据库时,也会发生解析错误。

如果有人知道我无法使其正常工作的原因,那将挽救我已经失去的一天...

提前谢谢你,朱尔斯

4

1 回答 1

1

Your error is produced by using the short array syntax [] in your code.

It is not available in PHP 5.3.10 aka on your production server. The short syntax was introduced in PHP 5.4 which explains why your code is working in your dev-environment.

change ...

$all_expenses[] = [$expense, $this->forYou($member, $expense)];

...to

$all_expenses[] = array($expense, $this->forYou($member, $expense));

... or update your server's php version and it will work :)

于 2013-06-14T17:46:55.800 回答