开发者

Weird PHP Parse/Syntax errors with VMWare 6.5 + PHP 5.3.3 + Symfony 1.4

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:

  • VM software : VMWare Workstation 6.5.5 / VirtualBox 4.0.8
  • PHP version: 5.3.3 / 5.2.6,
  • Mount type : vmhgfs (or vboxsf with VirtualBox) / ext4 (local) / cifs (aka Windows share).

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.


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:

  1. 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.

  2. 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 {} \;
    
  3. 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.

Weird PHP Parse/Syntax errors with VMWare 6.5 + PHP 5.3.3 + Symfony 1.4

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.

Weird PHP Parse/Syntax errors with VMWare 6.5 + PHP 5.3.3 + Symfony 1.4

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.


Same problem here. I confirm that it is a vmhgfs problem. A workaround is to use a NFS share instead of vmware shared folders:

Linux env

apt-get install portmap nfs-common nfs-kernel-server

mkdir /nfs-share1
echo "/nfs-share1 192.168.2.1(rw,sync)" >> /etc/exports

/etc/init.d/portmap start
/etc/init.d/nfs-kernel-server start
/etc/init.d/nfs-common start

usermod -u 501 paolo
find / -user paolo -exec chown paolo {} \;

OS X env

showmount -e 192.168.2.129

mkdir /Users/paolo/netshare1
mount -t nfs -o resvport,soft,intr,rsize=8192,wsize=8192,timeo=900,retrans=3,proto=tcp 192.168.2.129:/nfs-share1 /Users/paolo/netshare1/


Ugh! Finally I figured it out. I'm using VMware Fusion (4.0.2) on Mac OS X Lion (10.7.2) and I've been pulling my hair out trying to figure this out.

Upgrade your VMware Tools!

So far, so good: Haven't encountered the problem again. The latest release at this time is VMware Tools 8.0.0.


Well, this might be off topic, but I hope it helps:
I am working on the same book, and I have done this (I think you'd better do something like me):

  • Installed Ubuntu Server inside VirtualBox
  • Installed LAMP Server on Ubuntu
  • Installed vsftpd, for ftp access on Ubuntu
  • Installed SSH server on Ubuntu.

Now, if I am on Linux host, I use Aptana Studio with ftp access for editing files and SSH to run commands, and if I am on Windows, I use Aptana Studio and Putty for SSH access.

If you do something similar, you will probably have no trouble. Hope it helps.


I am also experiencing this problem in regards to Wordpress and Laravel. To fix the problem, I have to remount the mounted folder from the guest.

For instance, all my source files are located on the host (OSX) and shared to Ubuntu (guest) with vmhgfs. The mount point is /mnt/hgfs/www. To remount:

sudo mount /mnt/hgfs/www
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜