




Although Symfony documentation and tutorials are generallly very good for they take the learners by the hand and guide them through their first Symfony projects, the beginners might still have difficulties installing it. At the very beginning the learners are confronted with such command (CLI) as:
A lot of users, especially windows users, might not remember what this means any longer. To simplify the life of every developper Symfony makes an extended use of the command line interface. If the CLI works natively in Windows, very often PHP is not configured to work with it. In these line, I want to explain how to setup a local server and how to configure your environment correctly for php to work with the CLI.
First of all, we need to install a local server. We tend to favor WAMP because this package allows to install many versions of Apache, PHP or MySQL which is quite useful when you test your code for compatibility. There are, of course, other alternatives such as XAMP. You can download WAMP here.
Double click on the WAMP file you have just downloaded and it will get installed by itself. Set the options that you prefer, default options are also fine. After the installation, click on the WAMP icon and the server should start. A white half round icon should appear by the clock..

If it is red or orange it means that the server cannot fully start. A program like Skype might use the same port (80). We can correct this easily. Go to :
Skype > Tools > Options > Advanced > Connexion
Uncheck the option “use ports 80 and 443 alternatively.” Exit Skype and restart WAMP. This time everything should be fine. You can now restart Skype. In order to work correctly, Symfony needs to have the rewrite_module and PHP_XSL turned on. Left click on the WAMP icon by the clock, a dialogue box opens. Click on:
Apache > Apache modules
Click on the rewrite_module. WAMP will automatically restart.Then you need to go to:
PHP > PHP extensions
Click on PHP_XSL and WAMP will restart one more time.
That is it! WAMP is now correctly installed and you are ready to work with Symfony
Your computer needs to take into consideration the newly installed components: PHP and MySQL. If it is not the case, you will not be able to use the command line interface. In order to do that we need to add environment variables in PATH that you can find in:
Start >right click on "My computer" > Properties > advanced tab > button « environment variables »
Click on PATH, then edit. A dialog box opens. Add the following line ;C:\wamp\www\bin\php\phpYourVersion;C:\wamp\www\bin\mysql\mysqlYourVersion\bin at the end of the line. Do not forget to put a semi-colon ";" at the begining.
Save.
The CLI for PHP commands should work.
Now, go to :
Start > Run
Type "cmd" and click "ok".The command line interface opens. Type:
Your PHP version should be displayed.
PEAR is a framework and a system of reusable PHP components. We need it because PEAR will allow us to download and install Symfony with the CLI. In the folder wamp/php/phpYourVersion click on go-pear.bat and follow the instructions. The default configuration works well for symfony, so you can answer the questions following this pattern : [enter], [enter], Y [enter] (oui pour modifier le fichier php.ini), [enter], [enter]
Find the PEAR_ENV.reg.file in your folder and run it. Your PATH variable will be automatically modified and it will to add PEAR to your environment.
If the installation does not work you can use an alternative way. Create a .php file(e.g. go-pear.php) and copy everything from this source: PEAR. Save it in your PHP folder.
Open your PHP folder within your command line interface and run the file you have just created. Then run PEAR_ENV.reg
In your command line interface type :
If everything goes well you should see the following message :
Adding Channel “pear.symfony-project.com” succeeded
Discovery of channel “pear.symfony-project.com”succeeded
Now we can install Symfony. With PEAR,everything is automatic. Type in your CLI :
That's it, Symfony is installed and your environment is configured. You can now follow Symfony tutorials.
|
|
Add comment