Search code examples
windowssymfonycygwincomposer-php

How do I install Symfony in Cygwin?


Symfony provides a wrapper/install, or you can use Composer. Is there a way to get the installer to run in Cygwin?


Solution

  • The easiest way I found to complete this was to install a Cygwin package manager, either apt-cyg or Sage (I'm using Sage since apt-cyg is no longer being actively worked on).

    $ lynx -source rawgit.com/svnpenn/sage/master/sage > sage
    $ install sage /bin
    

    Next we will install the packages required for both the Composer route and the Installer route.

    $ sage update
    $ sage install wget curl sed
    $ sage install php php-json php-phar php-mbstring php-iconv php-zlib php-ctype php-tokenizer php-simplexml
    

    We should now have enough for Composer.

    $ mkdir -p ~/tmp
    $ cd ~/tmp
    $ wget https://getcomposer.org/installer
    

    We can double check by asking the Installer.

    $ php installer --check
    

    If all is good, proceed

    $ php installer
    $ rm installer
    $ chmod a+x composer.phar
    

    Install Composer globally (put it in PATH)

    $ mv composer.phar /usr/local/bin/composer
    

    If you want to use the alternate Symfony install via Composer, you should now be able to do that.


    If we want to use the Symfony Installer, we'll need to grab it.

    $ curl -L https://symfony.com/installer -o /usr/local/bin/symfony
    $ chmod a+x /usr/local/bin/symfony
    

    If you don't have a timezone set in your php.ini, you should set it before trying to run the Symfony Installer or else it will complain.

    $ sed -i -e 's/;date.timezone/date.timezone = "America\/Toronto"/g' /etc/php5/php.ini
    

    An explanation for the sed command is available in this answer. Set your own timezone as appropriate based on your location.

    You should now be able to run the Symfony Installer to create your project

    $ symfony new my_project_name lts
    

    Where the lts part is for your version. Currently lts is 2.8.4. If you leave that part off you'll get the most current stable.

    I hope this helps you (and perhaps me, next time I have to do this) save a bit of time.