Skip to content

Instantly share code, notes, and snippets.

@wataruoguchi
Last active November 19, 2015 04:39
Show Gist options
  • Select an option

  • Save wataruoguchi/1ad9ed3948b67d26395a to your computer and use it in GitHub Desktop.

Select an option

Save wataruoguchi/1ad9ed3948b67d26395a to your computer and use it in GitHub Desktop.

Getting start with Symfony2

Reference

0. Development Environment

  • OS X 10.11
  • MAMP
  • Atom editor

1. Install Symfony

$ sudo curl -LsS http://symfony.com/installer -o /usr/local/bin/symfony
$ sudo chmod a+x /usr/local/bin/symfony

http://symfony.com/download

2. Build new project

$ symfony new myproject

Result

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in phar:///usr/local/bin/symfony/src/Symfony/Installer/NewCommand.php on line 262
 ✕  Symfony 2.7.5 was successfully installed but your system doesn't meet its
     technical requirements! Fix the following issues before executing
     your Symfony application:

 * date.timezone setting must be set
   > Set the "date.timezone" setting in php.ini* (like Europe/Paris).

 After fixing these issues, re-check Symfony requirements executing this command:

   php myproject/app/check.php

 Then, you can:

    * Change your current directory to /Applications/MAMP/htdocs/my/directory/myproject

    * Configure your application in app/config/parameters.yml file.

    * Run your application:
        1. Execute the php app/console server:run command.
        2. Browse to the http://localhost:8000 URL.

    * Read the documentation at http://symfony.com/doc

Set timezone

# timezone = "America/Vancouver"
$ vi /Applications/MAMP/bin/php/php5.5.14/conf/php.ini

Check environment

$ /Applications/MAMP/bin/php/php5.5.14/bin/php myproject/app/check.php

Result


Symfony2 Requirements Checker
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> PHP is using the following php.ini file:
  /Applications/MAMP/bin/php/php5.5.14/conf/php.ini

> Checking Symfony requirements:
  ................................WW.....


 [OK]                                          
 Your system is ready to run Symfony2 projects


Optional recommendations to improve your setup
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 * a PHP accelerator should be installed
   > Install and/or enable a PHP accelerator (highly recommended).

 * short_open_tag should be disabled in php.ini
   > Set short_open_tag to off in php.ini*.


Note  The command console could use a different php.ini file
~~~~  than the one used with your web server. To be on the
      safe side, please check the requirements from your web
      server using the web/config.php script.

Enable PHP accelerator

# extension=apcu.so
$ vi /Applications/MAMP/bin/php/php5.5.14/conf/php.ini

Disable short_open_tag

# short_open_tag=Off
$ vi /Applications/MAMP/bin/php/php5.5.14/conf/php.ini

Re-Check environment

Result

Symfony2 Requirements Checker
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> PHP is using the following php.ini file:
  /Applications/MAMP/bin/php/php5.5.14/conf/php.ini

> Checking Symfony requirements:
  ........................................


 [OK]                                          
 Your system is ready to run Symfony2 projects


Note  The command console could use a different php.ini file
~~~~  than the one used with your web server. To be on the
      safe side, please check the requirements from your web
      server using the web/config.php script.

3. Launch the project

MAMP is ready to open the project

Access the URL by your browser

http://localhost:8888/my/directory/myproject/web/

You must see Symfony's Welcome message. I would create git initial branch in this point.

$ cd /Applications/MAMP/htdocs/my/directory/myproject
$ git init
$ git add .
$ git commit -m "Init"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment