Search code examples
phpsymfonysyntaxvendor

Symfony2 Syntax Errors (in vendor files)


To maintain code integrity across our servers we'd like to keep the /vendor/* directory under source control, rather than use composer to download files each time we roll out onto another server - i.e. we can be certain that the /vendor/* files are identical.

We run a syntax checker against all files committed to source control and run across the following error:

File '/vendor/sensio/generator-bundle/Sensio/Bundle/GeneratorBundle/Resources/skeleton/bundle/Bundle.php' failed the PHP syntax check with the following error:
PHP Parse error:  syntax error, unexpected '}', expecting T_NS_SEPARATOR in /vendor/sensio/generator-bundle/Sensio/Bundle/GeneratorBundle/Resources/skeleton/bundle/Bundle.php on line 3

Is the "error" in this file intentional ? Any help appreciated. File contents below:

<?php
namespace {{ namespace }};

use Symfony\Component\HttpKernel\Bundle\Bundle;

class {{ bundle }} extends Bundle
{
}

Solution

  • Yes, the "error" in this file is intentional as it is not really to be proceed by php "as is". It is a template used by the command app/console generate:bundle to generate a bundle.

    So {{ namespace }} will be replaced by a real namespace and {{ bundle }} by the bundle name you choose when you generate the bundle.