How to install symfony with composer?

26,440

Solution 1

To downloads symfony, you need to download symfony.phar (a small file PHP) from this link.

  • Then, you have to move in your usual Web directory C:\wamp\www on windows and /var/www on Linux ;

  • Execute php symfony.phar new project_name_and_version for example : symfony.phar new symfony2.8 to download Symfony 2.8.

    Then, you can :

  • Change your current directory to /var/www/html/project_name on Linux or C:\wamp\www on windows;

  • Configure your application in app/config/parameters.yml file ;

  • And (always) read the documentation at http://symfony.com/doc.

Good luck ^^ !

Update:

In Symfony 4 the symfony installer is abandoned. So, to create a new Symfony application you need:

  • to have PHP 7.1 (or higher)
  • to run php composer.phar create-project symfony/skeleton my-project "3.4.*" in your terminal.

Solution 2

You need to install composer before. From your command line:

php -r "readfile('https://getcomposer.org/installer');" > composer-setup.php
php -r "if (hash('SHA384', file_get_contents('composer-setup.php')) === '7228c001f88bee97506740ef0888240bd8a760b046ee16db8f4095c0d8d525f2367663f22a46b48d072c816e7fe19959') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

Instructions got from here:

https://getcomposer.org/download/

Solution 3

The recommanded way to install Symfony is through a command, named symfony.

Read the docs from the official symfony website: http://symfony.com/doc/current/book/installation.html, for more info.

So,

Then you can install composer, as the official docs says, and use it for installing packages inside your Symfony project.

Happy coding!

Solution 4

I tried this one:

php symfony.phar new symfony2.8

The results is this

[RuntimeException]
The Symfony Installer is not compatible with Symfony 4.x or newer versions.
Run this other command to install Symfony using Composer instead:
composer create-project symfony/skeleton symfony2.8

I tried the suggested command and it start download and install automatically

composer create-project symfony/skeleton symfony2.8

enter image description here

Share:
26,440
KorozCo
Author by

KorozCo

Updated on June 16, 2020

Comments

  • KorozCo
    KorozCo almost 4 years

    I am using Windows 10 When I install symfony2 with:

    composer create-project symfony/framework-standard-edition my_project_name
    

    Error:

    bash: composer: command not found
    
  • KorozCo
    KorozCo about 8 years
    When i tried php -r "readfile('getcomposer.org/installer');" > composer-setup.php Error: bash: composer-setup.php: Permission denied
  • kkochanski
    kkochanski about 8 years
    Because you run this command in place when you don't have proper privileges. Please do it in /home/user_name or use 'sudo' before used command.
  • Marcos Labad
    Marcos Labad about 8 years
    Try the command from your project's root directory (the one containing the app, vendor, src and web directories).
  • Cameron
    Cameron over 5 years
    To install a version 3 symfony, you can persevere with your original command by putting the version on the end - "symfony new my_first_app 3.4"