Start your Symfony webapp


    This guide is going to help you start developing your Symfony applications at SourceLair and make the most out of SourceLair's capabilities.

    This guide assumes that you already have a SourceLair account.


    Symfony is a PHP framework so first of all you need to create a new PHP project. When you create a PHP project, SourceLair launches an Apache web server to serve applications from the root directory of the project. In order to start coding your Symfony app you need to install Symfony and configure your server in SourceLair.

    Delete default files

    Symfony starts with its own skeleton, so it's better to delete the default files that come with the PHP project type in SourceLair. To delete everything except .git directory run the following command in your terminal:

    $ rm -r !(.git) 2>/dev/null

    Install a Symfony application

    Composer is pre-installed into your server and so you can use its commands from your fully featured terminal.

    The composer create-project command is one of the ways you can bootstrap a new project based on the Symfony standard application skeleton. The command below sets it up in a directory named my_symfony using the latest version of the framework.

    $ composer create-project symfony/framework-standard-edition:^3.0 my_symfony

    You will be asked about your database credentials, you can either press Enter and don't connect any database to your project or complete your database credentials from here.

    After downloading ​all the required dependencies and running a few hooks, Composer will ​have​ set up a fully functional project in the directory you specified (my_symfony in our case).​ Since the Git repository is already initialized in the root directory, we'll have to move the contents of the new Symfony project one level up with the following command:

    $ shopt -s dotglob && mv my_symfony/* . && shopt -u dotglob

    and remove the existing folder:

    $ rmdir my_symfony

    Configure server command

    By default, your Apache server runs the apache2ctl -DFOREGROUND command serving the content of the root directory (/mnt/project) of your project. In Symfony your server command should be php bin/console server: startso you need to create a that configures your server:

    $ echo "web: php bin/console server:start" >

    After creating the your server is going to restart automatically in order to run following the file.

    Fix app_dev.php

    In order not to face the error "You are not allowed to access this file. Check app_dev.php for more information", you will need to open the app_dev.php file in the /web folder of your application (Ctrl/Cmd + Shift + O and then the filename) and comment out the following block of code:

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

    Preview your application

    SourceLair provides you with a Public URL in order to help you test and showcase your work. There are 2 ways to see the public URL of your project:

    • Click on the eye icon in the sidebar
    • Open the Command Palette (Ctrl/Cmd + Shift + P) and use the Server: Open Public URL command.


    The recommended way to deploy your application to production is via Heroku. SourceLair's integration with Heroku toolbelt makes things pretty simple as you can deploy your app without even leaving from SourceLair.

    Before you start setting up our deployment workflow, check out that you have:

    Create a Procfile

    At the setup step you have already created a file to customise your server commands during development. Now you need to create a Procfile file that will give the appropriate instructions to Heroku about our server commands in production.

    $ echo 'web: $(composer config bin-dir)/heroku-php-apache2 web/' > Procfile

    After creating the Procfile don't forget to commit this new file.

    Set up Heroku workflow

    SourceLair terminal is integrated with Heroku toolbelt thus you are able to use all Heroku commands via SourceLair. Initially, you need to login to Heroku filling in your Heroku credentials

    $ heroku login

    Then, you need to create a new Heroku application that you can push to.

    $ heroku create

    If you don’t explicitly configure the environment (dev, prod etc) to use, Symfony will, by default, use the dev environment in console commands and at runtime. For Symfony to know it needs to use the prod environment at all times, it reads from the SYMFONY_ENV environment variable. Otherwise, you can simply run the following command in order to let Heroku handle the production configuration:

    $ heroku config:set SYMFONY_ENV=prod


    Everything should be set up, so you need deploy your app from SourceLair to Heroku. To do so use the Command Palette command Heroku: Deploy.

    Now every time you want to push something new to production, all you have to do is commit your changes and deploy to Heroku.

    Extras - Tips to code faster

    SourceLair provides you with some great features in order to help you develop faster your website being focused on the creative part of programming.


    When you write your PHP, HTML or CSS files, SourceLair's editor automatically place your cursor at the correct indentation level so that you don't have to worry about it. Although, when you break down your format you can select the number of lines you want to "auto-format" and press Shift + Tab.

    Command Palette

    Command Palette is a free text search tool which helps you use most of SourceLair's features really fast. You can open it by pressing Ctrl/Cmd + Shift + P.


    Quickopen is a fast and time saving way to navigate through your filesystem in order to find and open any file you want using your keyboard.

    You can open the Quickopen prompt using its shortcut Ctrl/Cmd + Shift + O.

    Find in files

    Find in files is a simple and easy way to search for something in your entire project at once, with quick file navigation from the results.

    You can trigger the Find in files prompt using its shortcut Ctrl/Cmd + Shift + F.