This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

Path to CSS and images is wrong on app_dev.php

Discuss installing Symfony 2 here

Path to CSS and images is wrong on app_dev.php

by Tom123 » Sat Jan 18, 2014 5:20 pm

Hello,

I'm trying to follow the "Quick Tour": http://symfony.com/doc/2.3/quick_tour/t ... cture.html

I've downloaded Symfony 2.4.1 (with vendors), and created a vhost:
Code: Select all
<VirtualHost 127.0.0.1:80>
    DocumentRoot C:/web/vhosts/Symfony/web
    ServerName symfony2.local
    <Directory "C:/web/vhosts/Symfony/web">
      AllowOverride All
      Options Indexes
      Require all granted
   </Directory>
</VirtualHost>


I'm using Apache 2.4.7 and PHP 5.5.7.

The "config.php" page (http://symfony2.local/config.php) works fine, including CSS and images, and I fixed what it told me to fix.
The path to the CSS looks like this:
Code: Select all
bundles/framework/css/body.css


However, when I click "Bypass configuration and go to the Welcome page", as instructed in the tutorial, it gets me to the "app_dev.php" page (http://symfony2.local/app_dev.php/), but the CSS and images don't show up.
The path to the CSS and images is wrong, and it looks like this:
Code: Select all
/C:/bundles/framework/css/body.css


Why is that?
Tom123
Junior Member
 
Posts: 2
Joined: Fri Jan 17, 2014 7:25 pm

Re: Path to CSS and images is wrong on app_dev.php

by Tom123 » Tue Jan 21, 2014 7:45 pm

I noticed the value of $_SERVER['SCRIPT_NAME'] was wrong ("C:/app_dev.php"), and that was the reason the path to the assets was wrong.

I still don't know why this value was wrong, but here's the workaround I used to make it work:

I used to load PHP using mod_fgcid, now I load PHP as an Apache module. And now it works.

The value of $_SERVER['SCRIPT_NAME'] is now "/app_dev.php" and the path to the assets is now similar to:
Code: Select all
/bundles/framework/css/body.css
Tom123
Junior Member
 
Posts: 2
Joined: Fri Jan 17, 2014 7:25 pm