The symfony framework is a full-stack MVC framework that helps you develop websites
faster. It also establishes a set of best practices that will help you to develop maintainable and
secure websites. And advocating best practices starts as soon as you want to install the
framework itself
How it install in to your computer
Installing symfony is not very much different to installing any other PHP software but, to
make your installation secure from the start, you should not just put all the files under web root directory
what are the Prerequisites
First, ensure that you have PHP 5.2.4 at a minimum
Launch the configuration checker script from the command line:
$ php check_configuration.php
If there is a problem with your PHP configuration, the output of the command will give you
hints on what to fix and how to fix it.
step 1 Initializing the Project Directory
Before installing symfony, you first need to create a directory that will host all the files related to your project:
$ mkdir -p /home/sfproject
$ cd /home/sfproject
step 2 Choosing the Installation Location
You can install symfony globally on your machine, or embed it into each of your project. The latter is the recommended one as projects will then be totally independent from each others As a best practice, install the symfony framework files in the lib/vendor project directory. So, first, create this directory:
$ mkdir -p lib/vendo
The easiest way to install symfony is to download the archive for the version you choose from the symfony website. Go to the installation page for the version you have just chosen, symfony instance Download the archive, put it under the freshly created lib/vendor/ directory, unarchive it, and rename the directory to symfony:
$ cd lib/vendor
$ tar zxpf symfony-1.4.0.tgz
$ mv symfony-1.4.0 symfony
$ rm symfony-1.4.0.tgz
If use Subversion, it is even better to use the svn:externals property to embed symfony into your project in the lib/vendor/ directory:
$ svn pe svn:externals lib/vendor/
step 3 Project Creation
From the sfproject/ directory, run the symfony generate:project task to actually create the symfony project:
$ php lib/vendor/symfony/data/bin/symfony generate:project PROJECT_NAME
The generate:project task generates the default structure of directories and files needed
for a symfony project
Directory Description
apps/ Hosts all project applications
cache/ The files cached by the framework
config/ The project configuration files
data/ Data files like initial fixtures
lib/ The project libraries and classes
log/ The framework log files
plugins/ The installed plugins
test/ The unit and functional test files
web/ The web root directory (see below)
step 4 Installation Verification
Now that symfony is installed, check that everything is working by using the symfony command line to display the symfony version
$ cd ../..
$ php lib/vendor/symfony/data/bin/symfony -V
get the symfony options and tasks list
$ php lib/vendor/symfony/data/bin/symfony
step 5 Configuring the Database
When creating a new project, Doctrine is enabled by default. Configuring the database used by Doctrine is as simple as using the configure:database task
$ php symfony configure:database "mysql:host=localhost;dbname=dbname" root password
step 6 Application Creation
Now, create the frontend application by running the generate:app task
$ php symfony generate:app frontend
under the apps/frontend/ directory:
Directory Description
config/ The application configuration files
lib/ The application libraries and classes
modules/ The application code (MVC)
templates/ The global template files
step 7 Directory Structure Rights
Before trying to access your newly created project, you need to set the write permissions on the cache/ and log/ directories to the appropriate levels, so that your web server can write to them
$ chmod 777 cache/ log/
step 8 Web Server Configuration
Locate and open the httpd.conf configuration file and add the following configuration at the end

This configuration makes Apache listen to port 8080 on your machine, so the website will be accessible at the following URL:
http://localhost:8080/
You can change 8080 to any number, but favour numbers greater than 1024 as they do not require administrator rights
Thank you.
No comments:
Post a Comment