Symfony 1 - Set up - A new project

In this tutorial of Symfony 1, we will set up a project from scratch.

Let's start it by downloading the project that you can find on the official web page of Symfony: http://www.symfony-project.org/installation

This tutorial will use the 1.4.12 version.

Once done, come back there.

Just before starting, do not forget that for Windows, you have to use a SLASH (/) and for GNU/Linux a BACKSLAH (\) for you PATH.
And of course, replace yourProjectName by yours.

OK, let's continue.
PHP has to be added to your enviromnent variables. It will be then possible to execute scripts of Symfony with a command line easily.
You can download and install Cygwin for Windows platform, a great tool, as well instead of your classic Windows command line.

Or simply use a Linux distribution.

We admit that your project PATH is:

C:\www\yourProjectName

Dezip your symfony framework in this directory.

We have then to download a test file from a symfony website: http://sf-to.org/1.4/check.php

Place it in your directory.

Open a command line from this directory and write this:

$  php check_configuration.php

Several lines appear preceded by OK or WARNING.

OK means that requirements is OK.
WARNING means that requirements are not OK.

It is up to you to change these settings or not.

Of course the more elements are OK, the more your framework will work correctly.

I suggest to you to fix all except posix_isatty() and PHP accelerator (for a local using, it is not important).
And for Windows, posix_isatty() just does not exist!

To test your symfony version:

$ php data/bin/symfony -V

You can now generate your project:

$ php data/bin/symfony generate:project yourProjectName

It will generate all files and directories needed.

Then create the frontend of your application:

$ php symfony generate:app frontend

Let's configure now the httpd-vhosts.conf file of Apache HTTP for a Windows platform example:

# symfony 1.4.12 / yourProjectName
<VirtualHost *:80>
  ServerName yourProjectName
  DocumentRoot "C:/www/yourProjectName/web"
  DirectoryIndex index.php
  <Directory "C:/www/yourProjectName/web">
    AllowOverride All
    Allow from All
  </Directory>

  Alias /sf "C:/www/yourProjectName/data/web/sf"
  <Directory "C:/www/yourProjectName/data/web/sf">
    AllowOverride All
    Allow from All
  </Directory>
</VirtualHost>

To finish it, go until this adress:

C:\Windows\System32\drivers\etc

And open the hosts file with a text editor.
Add a line:

127.0.0.1 yourProjectName

Do not forget to restart your Apache HTTP server and that's all!

Try this: http://yourProjectName/

You should normally see the congratulations Symfony home page.

You are now ready to fight the devil! angry

Comments

Comment: 

i have read about 10 to 11 articles for installing symfony but not succeded but after reading this my job worked. thank you very much for this easy installation process.

one question. i have read in many websites that they are first of installing pear, what this pear ???? i have configured symfony in xampp. should i need to install pear for that????????

Comment: 

Hello Hardik smiley

Thank you for your comment.

PEAR is an installer of packages for PHP.
Packages are components that can be installed directly in your PHP projects.
You can find them on the official website: http://pear.php.net/packages.php.

But Symfony packages are on the Symfony website (more than 1000!) and they are called plugins.

PEAR will be then able to download, install and update a package (or a plugin) just with one single command line.
But you can download and install it by hand as well.

So you do not need PEAR if you do not plan to install a package with a command line tool.

If you want you can follow this tutorial: http://www.badprog.com/php-5-pear-installation