Introduction to Symfony Framework Part-1


Symfony is an open-source PHP web application framework, designed for developers who need a simple and elegant toolkit to create full-featured web applications. Symfony is sponsored by SensioLabs. It was developed by Fabien Potencier in 2005. This tutorial will give you a quick introduction to Symfony framework and make you comfortable with its various components.

File Structure and Functionalities Overview

Here are the files and directory structure for the symphony Framework

I] Apps Folder: contains below directories

  1. front: [It Contains The Website Front End Related Modules , Files And Folders ]

1.1. Confi [It Contains Website Configuration File ]

This Folder Contains “.yml format files. The name confi indicates that the directory is related to configuration. This directory contains site configuration related files. Below are the some files name and its workings.

1. app.yml :

Application yml file used to store application related details like facebook api key, google+, twitter keys and other application related information.

2. routing.yml :

This file contains all the pages URL ,Link Information. Below is the example how to write or set the url for particular module and page.



url: /mytrips

param: { module: worldtraveler, action: mytrips }

above example explains that when browser get request url as mytrips then it calls associate module and action. Now in this example it will execute code of action: mytrip from worldtraveler module.

3. Settings.yml :

- This file is used to store the settings information. In this file site settings, login key, or cache management related settings are defined.

4. view.yml :

- This File contains site view details. Like front page configuration, CSS files details, etc

5. security.yml :

- Using this file we can set extra security for the site.

- If user used any key encryption or decryption for password or any other application he can define those keys here.

- Cache management settings.

6. configurationClass.php :

This File contains configuration code.

7. filters.yml :

  • This Files Contains code related to Filters which are used in the site.
  • Like search autocomplete , searching filters. Etc

8. cache.yml :

  • This file is used to unable/disable the cache and security purpose.

1.2 Lib [Library Files Directory]

- This Folder contains the form folder which contains all the forms which are used in the site.

For Detailed Information please refer the below link;


1.3 Modules [Modules Directory]

- This Directory Contains modules directory and modules related pages.

- Each module in the framework is stored in separate folder with the same name for the module.

Ex: lets consider a new module “ABC” :

Path And Folder Structure For The Module ”ABCD” Will Be As Follows.

Path: Apps->front->Module->Modules->ABCD

Every module consist the below Folders And Files :

  1. actions — folder consist two files

1. actions.class.php

- Here main logic,code is written for particular action.

- This file is like script file in Smarty Framework.

2. component.class.php

- This file also contains the main code.

- This file is like default action script file in Smarty Framework

2. confi-This folder consist configuration code files.

3. template- This Folder Consist of layout structure template files.

1.4 Templates [Template Directory]

  • This folder consist main website layout structure.

2. Admin [It Contains Admin Related Files And Folders.]

  • This Folder Consist admin related modules and files.

II] Cache

- This Folder Contains cache files.

- There are also sub directories as follows

1. Front- Contains front end cache files.

2. Admin- contains Admin related cache files.

III] Config

- This folder consist all database related files as well as database configuration file.

- This Folder Consist database table schema.yml files for each table.

What are schema files?

The schema.yml file contains the description of all tables and their columns. Each column is described with the following information: type: The column type (Boolean, integer, float, decimal, string, array, object, blob, clob, timestamp, time, date, enum, gzip)

not null: Set it to true if you want the column to be required

unique: Set it to true if you want to create a unique index for the column.

  • As well as we can create different schema files according to module or need.

IV] lib

- This folder consist of sub folders and files.

- This folder consist all the base class files.

- Ex: This consist captcha code, breadcrumbs, Facebook, Twitter, filters all the object which we

have used the base class for that objects will be present in this directory.

- It consist model base classes related to database.

Peer Class Structure :

The general idea is to have a class that corresponds (in a way yet to be defined in detail) with a database table, so that the objects of that class are equivalent to rows in the table. Classes of this kind derive a lot of their behavior by sub classing a standard class provided by the framework (Symfony/Propel). In addition, each database table is also given a “peer class” consisting of static methods.

Path: lib->model->model name->

- In this above folder there are two files one is tablename.php and another one is tablnamepeer.php

- To do CURD operation we have to define code in this files.

Path: lib->model->model name->om This folder consist two files

1.Base tablename.php

2.Basepeer tablename.php

Path: lib->model->model name->map this table consist of below file


Ex: We have a table name as Trip and model: Worldtraveler then we have to create the four files in particular folder as below.

Path: lib->model->worldtraveler->



Path: lib->model->worldtraveler->om



Path: lib->model->worldtraveler->map


For more about Peer Class: Visit The below Link

V] Public html

1. Front: in this directory you can find the front end related folders and files.

- You can find the CSS, Images , JS, font files in this folder related to front end.

2. Admin: in this directory you can find the front end related folders and files.

- You can find the CSS, images , JS, font files in this folder related to admin end.

Two main files which is used to load the site and admin part are

1. index.php for front end.

2. admin.php for back end.


Developer , Choreographer , Dancer , Traveler

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store