Making Your Local Symfony2 Project Available Externally

Published on Author craigzearfossLeave a comment

Sometimes you’ll want to test the code that is on your local machine on an external device before pushing it to your server. For example, when you want to test something out on your phone or tablet. It’s easy to do this by making the following small edits on the routing.yml and app_dev.php files.

routing.yml

Set the host parameter for each route to the ip address of your machine. This is shown with ###.###.###.###.

my_route_name:
    path: /
    host: ###.###.###.###

app_dev.php

Comment out the lines that prevent access to debug the front controller.

if (isset($_SERVER['HTTP_CLIENT_IP'])
    || isset($_SERVER['HTTP_X_FORWARDED_FOR'])
    || !in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', 'fe80::1', '::1'))
) {
//    header('HTTP/1.0 403 Forbidden');
//    exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}

* Remember to revert the changes when you are finished testing.

Leave a Reply

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