Taziri Herrera Arocha Taziri Herrera Arocha - 1 year ago 134
PHP Question

Symfony 2.8 on Ubuntu with 2 projects only load the firth

I have two project, and two virtualhost. If i load A first, B show:

ClassNotFoundException in AppKernel.php line 19:Attempted to load class "UserBundle" from namespace "B"

Did you forget a "use" statement for another namespace?

else if I reset apache and load first B all ok, but A show the same:

ClassNotFoundException in AppKernel.php line 20:Attempted to load class "UserBundle" from namespace "A"

Did you forget a "use" statement for another namespace?

and I use this apache configuration for virtualhost ( project a with a and project b with b ):

<VirtualHost *:80>

ServerName localhost.a

DocumentRoot "/var/www/A/web"
DirectoryIndex app_dev.php

<Directory "/var/www/A/web">
AllowOverride None
Allow from All

<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app_dev.php [QSA,L]

CustomLog /var/log/httpd/a-access.log combined

KeepAlive On
MaxKeepAliveRequests 200
KeepAliveTimeout 5

<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE "application/atom+xml" \
"application/javascript" \
"application/json" \
"application/rss+xml" \
"application/x-javascript" \
"application/xhtml+xml" \
"application/xml" \
"image/svg+xml" \
"text/css" \
"text/html" \
"text/javascript" \
"text/plain" \

<IfModule mod_headers.c>
Header append Vary User-Agent env=!dont-vary

ExpiresActive On
ExpiresDefault "now plus 1 week"
ExpiresByType image/x-icon "now plus 1 month"
ExpiresByType image/gif "now plus 1 month"
ExpiresByType image/png "now plus 1 month"
ExpiresByType image/jpeg "now plus 1 month"

symfony seems to work fine but i dont understand because only work first symfony

my apache:
Server version: Apache/2.4.18 (Ubuntu)
Server built: 2016-01-05T00:00:00

Answer Source

I faced the same problem using Symfony 2.8.x and Apache 2.4.x.

After some days of battling with my Apache configuration, I gave up and did some searches on Stack. I found this thread : How to configure more than one Symfony2 projects on the same server

As strange as it seems, the modification fixes the problem.

Basically, Angel suggested to uncomment the line : opcache.enable = 0 in the php.ini.

Don't forget to restart your server.

Update 26/10/2016 :

In fact, the core of the issue lies in the use of xcache, maybe because I don't know to configure it properly (I tried many, many parameters and combination). I disable xcache (I remove it from the module loaded by my Apache server) and it solves the problem.

Now, I can also use opcache, for instance, I need it for Drupal 8.2.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download