Symfony

     

    NOTE: This guide uses /opt/bitnami to refer to the installation directory for the Bitnami Stack. This is the default installation directory for Bitnami Cloud Hosting, Google Cloud Platform and Microsoft Azure servers and for virtual servers. If you're using a native installer and have installed the Bitnami Stack to a different folder, replace /opt/bitnami in the examples below with your actual installation directory.

    Overview

    The Symfony framework is installed in the frameworks/symfony directory in the installation directory. This directory includes an example application. Application code is in the app/ directory, application configuration files are in the conf/ directory and public files, such as HTML pages, CSS and JavaScript files, images and other media assets are stored in the web/ directory.

    Activation and Testing

    To enable the example application, edit the Apache configuration file at  /opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf and uncomment the following line

    Include "/opt/bitnami/frameworks/symfony/conf/httpd-prefix.conf"

    Then, restart the Apache server.

    $ sudo /opt/bitnami/ctlscript.sh restart apache
    

    NOTE: If you are using a cloud server under Bitnami Cloud Hosting, Microsoft Azure or the Google Cloud Platform, the Symfony application is configured by default to only allow requests originating from ‘localhost’ for security reasons. As a result, you will see a message like ‘You are not allowed to access this file. Check app_dev.php for more information’ when you try to access the example application on these platform.

    To allow access to the example application from hosts other than ‘localhost’, edit the file /opt/bitnami/frameworks/symfony/web/app_dev.php and within it, disable the IP address check at the top of the file by commenting out the relevant lines. After modification, the relevant section of the file should look like this:

    // 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 (isset($_SERVER['HTTP_CLIENT_IP'])
        || isset($_SERVER['HTTP_X_FORWARDED_FOR'])
        || !(in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', 'fe80::1', '::1')) || php_sapi_name() === 'cli-server')
    ) {
        header('HTTP/1.0 403 Forbidden');
        exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
    }
    */
    

    You can now verify that the example application is working by visiting its URL using your browser. Select your platform below.

    Bitnami Cloud Hosting

    Access the example application via your browser at http://[server-IP-address]/symfony/app_dev.php

    Microsoft Azure / Google Cloud Platform

    Access the example application via your browser at http://[server-IP-address]/symfony/app_dev.php


    Virtual Machine

    Access the example application via your browser at http://[virtual-server-IP-address]/symfony/app_dev.php

    Native Installer

    Access the example application via your browser at http://localhost/symfony/app_dev.php(Windows) or http://localhost:8080/symfony/app_dev.php (Mac OS X and Linux).

    Tabs end

    Here is an example of what you might see:

    symfony.png


    Configuration

    Before using the example application, here are a few important points to consider:

    1. If your application will use a database, edit the database settings in the app/config/parameters.yml file.

    parameters:
        database_driver: pdo_mysql
        database_host: 127.0.0.1
        database_port: 3306
        database_name: database_name
        database_user: user
        database_password: pass
    

    MySQL support is already available by default. If you plan to use PostgreSQL, enable the php_pdo_pgsql extension in the /opt/bitnami/php/etc/php.ini file.

    extension=php_pdo_pgsql
    

    To obtain access credentials for the MySQL database, use user 'root'. For the MySQL password, follow the steps below:

    Bitnami Cloud Hosting

    Google Cloud Platform

    • Browse to the Bitnami Launchpad for Google Cloud Platform dashboard and sign in if required using your Bitnami account.
    • Select the "Virtual Machines" menu item.
    • Select your Bitnami Stack server from the resulting list.
    • Obtain the password by selecting "Show" under "Credentials".


    Microsoft Azure

    To log in, use default password 'bitnami'.

    Virtual Machine

    To log in, use default password 'bitnami'.

    Native Installer

    The password is the one specified by you during the Bitnami Stack installation process.

    Tabs end

    2. To move the Symfonyexample application such that it is available at the root URL of the server (without the /symfony URL suffix), follow these steps:

    • Edit the /opt/bitnami/frameworks/symfony/conf/httpd-prefix.conf file so that it looks like this:
    DocumentRoot "/opt/bitnami/frameworks/symfony/web/"
    #Alias /symfony/ "/opt/bitnami/frameworks/symfony/web/"
    #Alias /symfony "/opt/bitnami/frameworks/symfony/web"
    Include "/opt/bitnami/frameworks/symfony/conf/httpd-app.conf"
    • Edit the /opt/bitnami/frameworks/symfony/conf/httpd-app.conf file and replace the AllowOverride None directive with the AllowOverride All directive:
    AllowOverride All
    • c. Restart the Apache server:
    $ sudo /opt/bitnami/ctlscript.sh restart apache
    

    You should now be able to access the example application at the root URL of your server.

    Upgrading Symfony 2.x

    If your Bitnami stack currently uses Symfony 2.x and you would like to upgrade to the latest 2.x release, follow these steps:
     

    NOTE: The steps below assume that you have already activated the Symfony example application, as described here.
    1. Log in to your server console.
    2. If you are using a native installer only, load the Bitnami environment:
      $ cd /opt/bitnami
      $ ./use_lampstack
      
    3. Update the framework by executing the following commands:
      $ cd /opt/bitnami/frameworks/symfony
      $ sudo composer self-update
      $ sudo composer update
      
    4. Change the permissions of the app/cache directory so that it is writable by the Web server:
      $ cd /opt/bitnami/frameworks/symfony/app
      $ sudo chown -R bitnami:daemon cache
      $ sudo chmod -R 775 cache
      

    You should now be able to access the example application and verify that it is using the latest version of Symfony, as shown below:

    symfony-upgrade.png

    More Information

    Learn more about developing applications with Symfony at http://symfony.com/doc/current/.

    Tag page (Edit tags)
    • No tags
    Pages that link here
    Page statistics
    134850 view(s), 12 edit(s) and 9992 character(s)

    Comments

    You must login to post a comment.

    Attach file

    Attachments