简体   繁体   中英

OS independent vendor path in Symfony

I'm developing a Symfony 2.7 application on a Windows machine. I'm using a vagrant VM running Ubuntu Linux (Apache) to run the code. The code is mounted as a synced folder into the Linux system.

When I access my application on the linux host it looks like Symfony is trying to use the Windows path to find the vendor directory:

ContextErrorException in /var/www/project/vendor/twig/twig/lib/Twig/Loader/Filesystem.php line 131:

Warning: file_get_contents(D:\workspace\project\vendor\symfony\symfony\src\Symfony
\Bundle\TwigBundle/Resources/views/Exception/exception_full.html.twig): failed to open
stream: No such file or directory

I don't think this is specific to vagrant, It looks like the problem would be the same for anybody working on a remote drive.

How did you guys make this work?

I'm fairly new to Symfony, any help would be greatly appreciated, thank you.

I found the issue myself. This worked for me...

Add this to your composer.json:

"config": {
    [...]
    "vendor-dir": "vendor"
},

Update composer and clear Symfony cache.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM