Question

I have developed a Symfony2 project (v2.2.2) and it was working all fine locally.

When I deploy it on my server I meet 2 issues:

  • the folder /bin does not transfer through Filezilla (impossible to start transfer)
  • i encounter a parse error when trying to access web/app.php/ in debug mode (see below)

First I do not understand why it would work in local but not on production. I also guessed these errors where linked but I do not know what is /bin used for (contains only 2 files doctrine and doctrine.php) and if I remove it locally it keeps working ...

Parse error is the following :

"FatalErrorException: Parse: syntax error, unexpected '[' in /home/colocall/twinkler/src/Tk/ExpenseBundle/Services/Expenses.php line 21"

Expenses.php line 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;
}

Maybe linked to : The parse error also happen when i try to update my database through ssh connection.

If someone would know the reason why I can't make it working it would save my day that i have already lost ...

Thank you in advance, Jules

Was it helpful?

Solution

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 :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top