Installing Symfony 2.3.x LTS from scratch

posted in: Architecture, PHP, Standards, Symfony | 0

Before you start reading this, make sure you click here and read the article on the ITE platform, just so that you get the required context and then continue 🙂

There are 2 ways to install Symfony 2.3.x LTS, an offline and online approach. Both are equally effective, however the online approach causes some issues on Linux and MacOS, so we will go with the offline approach (check here for the Symfony documentation regarding installation).

Our process for installing Symfony is thus as follow:

  1. Download Symfony 2.3.13 here
  2. Extract the zip file in your working directory
  3. Navigate to your working directory in the terminal/command line and cd into the extracted Symfony installation.
  4. Run the following command (this just cleans the setup of the downloaded Symfony installation and corrects any dependencies that might be of the wrong versions) :
    composer update
  5. After step 4 is done, run the following command (which starts a php server on localhost port 8000):
    app/console server:run
  6. Now click here and you should get a screen that looks like this:SymfonyWelcomeScreen
  7. What you have now is a stock standard out-of-the-box installation of Symfony 2.3.13 LTS that WORKS!!!!
  8. However, for what we want to do with Symfony, we need a few more dependencies, so replace the content of your current ‘composer.json’ file with this:
    {
        "name": "symfony/framework-standard-edition",
        "license": "MIT",
        "type": "project",
        "description": "The \"Symfony Standard Edition\" distribution",
        "autoload": {
            "psr-0": { "": "src/" }
        },
        "require": {
            "php": ">=5.3.3",
            "symfony/symfony": "2.3.*",
            "doctrine/orm": "~2.2,>=2.2.3",
            "doctrine/doctrine-bundle": "1.2.*",
            "twig/extensions": "1.0.*",
            "symfony/assetic-bundle": "2.3.*",
            "symfony/swiftmailer-bundle": "2.3.*",
            "symfony/monolog-bundle": "2.3.*",
            "sensio/distribution-bundle": "2.3.*",
            "sensio/framework-extra-bundle": "2.3.*",
            "sensio/generator-bundle": "2.3.*",
            "incenteev/composer-parameter-handler": "~2.0",
            "cedriclombardot/twig-generator": "1.0.*",
            "jms/di-extra-bundle": "dev-master",
            "jms/command-bundle": "dev-master",
            "jms/security-extra-bundle": "dev-master",
            "jms/cg": "dev-master"
        },
        "require-dev": {
            "doctrine/doctrine-fixtures-bundle": "@dev",
            "phpunit/phpunit": "3.7.*",
            "liip/functional-test-bundle":"@dev",
            "guzzle/plugin": "3.7.*",
            "behat/behat": "2.4.*@stable",
            "behat/mink": "1.5.*@stable",
            "behat/mink-goutte-driver": "*",
            "behat/mink-extension": "*",
            "behat/mink-selenium2-driver": "*"
        },
        "scripts": {
            "post-install-cmd": [
                "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
                "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
                "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
                "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
                "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
            ],
            "post-update-cmd": [
                "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
                "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
                "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
                "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
                "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
            ]
        },
        "config": {
            "bin-dir": "bin"
        },
        "minimum-stability": "stable",
        "extra": {
            "symfony-app-dir": "app",
            "symfony-web-dir": "web",
            "incenteev-parameters": {
                "file": "app/config/parameters.yml"
            },
            "branch-alias": {
                "dev-master": "2.3-dev"
            }
        }
    }
    
  9. Run this again:
    composer update
  10. Next you need to edit the parameters.yml file, located in the Symfony directory under app/config/. Depending on what your requirements are you’ll need to edit it to suite your needs. It may look something like this:
    parameters:
        database_driver: pdo_mysql
        database_host: 127.0.0.1
        database_port: 3306
        database_name: symfony
        database_user: root
        database_password: null
        mailer_transport: smtp
        mailer_host: 127.0.0.1
        mailer_user: null
        mailer_password: null
        locale: en
        secret: SomeOrOtherSecretToken
    

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Leave a Reply