Skip to content

Symfony and My Network Configuration

I’ve been trying to learn the Symfony framework on my local test environment. Symfony provides a lot of the same skeletal generation of code in PHP as Rails does to Ruby, thus making the process of coding a bit faster. Plus, it creates a cleaner, easier-to-read alternative to straight PHP coding.

When trying to test my pages in the Symfony’s development environment, I get the following error: You are not allowed to access this file. Check app_dev.php for more information.

After some research I found the problem had to do with my network configuration. In my case my test server is not on my workstation, but a separate test server that I had set up on my network. The default code generated by Symfony only allows individuals to access the development environment pages from locally on the server. Since I’m accessing my web server from an outside machine on my network, Symfony will not let that fly. At least not with the code it has generated.

To remedy the situation I had to to edit my app_dev.php file underneath the web folder. The IP address of my workstation is 192.168.1.100 and I added it to the script like so:

// this check prevents access to debug front controllers that are deployed by accident to production servers.
// feel free to remove this, extend it or make something more sophisticated.
if (!in_array(@$_SERVER[‘REMOTE_ADDR’], array(‘127.0.0.1’, ‘::1’, ‘192.168.1.100’)))
{
die(‘You are not allowed to access this file. Check ‘.basename(__FILE__).’ for more information.’);
}

require_once(dirname(__FILE__).’/../config/ProjectConfiguration.class.php’);

$configuration = ProjectConfiguration::getApplicationConfiguration(‘app’, ‘dev’, true);
sfContext::createInstance($configuration)->dispatch();

Published inThoughts

4 Comments

  1. Karl Holodnick Karl Holodnick

    Stefan, WTF???

  2. xeVi xeVi

    Nice job! I had the same problem and i was fighting with file permissions! Thanks!

  3. You’re welcome. I’m glad this could be of help to you.

  4. Lucas Lucas

    Thanks (:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.