While following the "Practical Symfony" course, I have run in a strange error.
I have installed a Debian Squeeze in a VMWare 6.5.5 machine. It comes with PHP 5.3.3 and I am using Symfony 1.4. The source files are on the host, I am accessing them using the shared folder feature (vmhgfs mount).
Now, when I try the following commands, I get an error:
php symfony doctrine:build --model
php symfony doctrine:build --sql
Error:
PHP Parse error: syntax error, unexpected ')' in /var/www/appli/lib/model/doctrine/base/BaseJobeetJob.class.php on line 144
What is funny is that when I : - do the same thing without the shared folders (e.g. on a ext3 partition), it works, - convert the VM to VirtualBox and do the same thing on a shared folder, it works, - downgrade the PHP to 5.2.6 (from lenny), it works.
I remember having the same kind of issue some time ago with the PHP code generated by Smarty. As it was automatically generated PHP and could be regenerated at will, I had it generated in a local direcorty. But I do not think this is applicable to Doctrine generated files.
Does anyone have any clue of what is happening and how I could fix it ?
EDIT: here is the code around line 144:
public function setUp()
{
parent::setUp();
$this->hasOne('JobeetCategory', array(
'local' => 'category_id',
'foreign' => 'id',
'onDelete' => 'CASCADE'));
$timestampable0 = new Doctrine_Template_Timestampable();
$this->actAs($timestampable0);
}
} // Line 144 here.
It is actually the end of the file...
EDIT #2: to make it clear I have tested the following combinations in order to narrow down the issue:
In every case I am using the very same source files (but for ext4 because I had no other choice than to copy them). I have a failure when combining the bold items. If I change any one of them, everything goes fine. I also tried to use the open-vm-modules in place of the provided vmware tools and to build a Debian installation from scratch instead of using my own automated script but neither has changed anything.
A parse error: syntax error, unexpected appears when the PHP interpreter detects a missing element. Most of the time, it is caused by a missing curly bracket “}”. To solve this, it will require you to scan the entire file to find the source of the error.
If the PHP code contains a syntax error, the PHP parser cannot interpret the code and stops working. For example, a syntax error can be a forgotten quotation mark, a missing semicolon at the end of a line, missing parenthesis, or extra characters.
This seems to be a bug in vmhgfs - I have the same issue working with Drupal PHP code. It also seems to only happen when the files are added to the host from the guest, for example using git to clone a repository in the Linux VM.
There are three workarounds:
Copy the files into their desired location, then disable shared folders in VMWare settings for the virtual machine, refresh the web page so you get 'Not found', then re-enable shared folders.
On the host machine, run the following command which updates the file access / modified timestamps for every file, thus causing the VMWare driver to reload the file, fixing the issue:
find . -exec touch {} \;
Open the affected file from the host machine, modify it, and save it back. This may be useful if you're on a Windows machine.
The errors range from PHP Parse errors to others, normally flagging the last line of the file.
I have the same problem on OpenSUSE 11.4 with PHP 5.3.5 using vmhgfs (on a Mac). I am also using doctrine, however I am using it without the full symfony project.
Initially vmhgfs didn't work at all, so I downloaded the open-vm-tools and compiled/installed that. That solved my problem for a few weeks, but it came back today.
The issue appears to be php reading past the end of the file. If I read the file with cat, less, or tail, then the end of the file looks fine.
But if I do php -s bad_file.php > bad_file.php.html
and look at the html output, I can see at the end of the file there is some extra garbage that I don't see with with cat, less, or vim.
You can see that php sees "array (" at the end of the file, while other tools do not see that.
The only solution I've found is to manually add a new, blank line at the end of each problematic file. For some reason it only affects 1-2 files out of about 40.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With