8

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.

Mark Theunissen
  • 2,406
  • 2
  • 17
  • 14
Adirelle
  • 148
  • 6
  • Can you please show the code aroung the BaseJobeetJob.class.php on line 144 ? Maybe the doctrine:task didn't work properly. – Clement Herreman Jun 17 '11 at 09:55
  • Actually, "php5 -l /var/www/appli/lib/model/doctrine/base/BaseJobeetJob.class.php" tells me "No syntax errors detected". Moreover, if I try to build the SQL from another virtual machine with PHP 5.2.6 (from the model created with 5.3.3), everything is fine. – Adirelle Jun 17 '11 at 11:54
  • Hum. I guess you have a real WTF here. I feel sorry for you. – Clement Herreman Jun 17 '11 at 13:17
  • What is your host OS? Is it Windows? – Omid Kamangar Jun 17 '11 at 22:06
  • On a sidenote, I finally switched to VirtualBox that does not have this issue. However, Apache sometimes fails at properly sending files that have been modified. I discovered I could fix it by disabling file memory mapping (EnableMMAP Off) and kernel sendfile support (EnableSendFile Off) for files in the shared folders. – Adirelle Jul 26 '11 at 08:30
  • Is this the solution that you continued to use or were you able to find a fix for VMWare? I am having the same issue. – user543936 Jun 17 '12 at 00:21

6 Answers6

8

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.

Mark Theunissen
  • 2,406
  • 2
  • 17
  • 14
  • @binaryLV, agreed. However I do not know how to forcefully refresh the cache, beside unmount/remounting, which is pretty unhandy. – Adirelle Jul 26 '11 at 08:27
3

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.

tail of bad file

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.

php syntax highlighting of bad file

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.

Mark E. Haase
  • 25,965
  • 11
  • 66
  • 72
1

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

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.

0

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
sqren
  • 22,833
  • 7
  • 52
  • 36
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.

Omid Kamangar
  • 5,768
  • 9
  • 40
  • 69
  • Thanks for your answer but unfortunately I have to use Debian Squeeze for the server as it is was we will be used in production. Moreover, I have to keep my source files in the host filesytem. – Adirelle Jun 20 '11 at 08:04