Symfony 2 tutorial. Mobile application has taken a huge leap. Today, mobile applications are not just apps anymore – they are actually solutions to business issues. From a simple informative app to a critical business application, mobile apps have become a powerful tool that efficiently supports marketing strategies of a business.

Just open your phone and everything is available in your hands in the form of web apps starting from very basic daily essentials to luxuries and entertainment like music, gaming, banking, shopping, ticketing, billing recharges and so on.

Now the real question is how to build a web app. Thanks to the availability of a wide range of developers who share their experiences and knowledge online, you can easily find the relevant information and documentation on building an app. Similarly like you search ‘how to create a blog’ and get thousands of solutions, you can search “building a web app using symphony” to get the most relevant answer.

However, before you get started, make sure your web app is:

User friendly

technically concrete

easily accessible

Less time consuming

Less viable to unauthorized access

On the toplist of various search engines like Google, yahoo, playstore etc.

Building a web app is quite a technical process but having a little knowledge of basic languages and learning a basic web development program, you can easily create a web application for your personal use.

In the following series, I will discuss some techniques and key steps that may help you build your own website using Symfony. It is a three-layered process which involves:

Bootstrapping or Rebooting: The very first step is to download the Symfony standard from its official site followed by unzipping the archives to the web root directory.

After this you need to download the PHP packaging system which is known as composer.Now there can be two possibilities:

1. If you already have the cURL utility installed, issue the following command:

You will get a new downloaded file known as composer.phar. This file is the entry point for our PHP package management.

The files that we have known contain no bundles so as to make Symfony work. For that you need to run:

phpcomposer.phar update

This will install all the required bundles and in case you run into errors i.e. missing utilities or critical dependencies, composer will let you know about that. Depending upon the speed of your connection the aforesaid installation procedure will complete itself within the couple of minutes.

With Symfony, the common practice is to use app_dev.php as the initial page during development, on the other hand when it comes to production app_dev.php would be omitted.

With the resources provided by Symfony one can feel free to search and familiarize themselves with the framework, toolbars and the debug messages without any obstruction.

To get the latest composer.phar framework, you must periodically run composer.phar self-update

There is one more feature provided on Symfony webpage i.e. it has a demo app in the form of a bundle known as AcmeDemoBundle which can be used as an example to build your own app.

Modules (Entities)

In Symfony, modules are also referred to as Bundle, Controllers, Views, and Models. A controller is a collection of files which serves as the canister for logic control, data retrieving and presentation of a particular set of function in your website.

Bundle or controller or entity serves as the foundation of an MVC-structured website.To initiate the application development and generate a bundle, run the following command:

php app/console generate:bundle

The console will ask you various questions before creating a bundle such as:

Bundle namespace: Be sure to have "Bundle" at the end.

Bundle name: use the suggested name derived from the namespace.

Target Directory

Configuration format: You are available with 4 options i.e. PHP, YAML, XML and annotation. You can opt for any one.

Would you like to generate the whole directory structure: Not necessary.

Confirm the kernel update, generation and Routing generation.

Routing

Routing is nothing but a mapping mechanism which processes the request, grabs the data and render the response to the web browser. You can download all the routes via app/config/routing.yml You have the provision for defining your own route. You can create your route in MyBundle/Resouces/config and then import the same in app/config/routing.yml :

Acme_hello: Resource: "@AcmeHelloBundle/Resouces/config/routing.yml"

Database

Configuring the database with Symfony 2 is relatively simpler and can be done by issuing the following command app/config/parameters.yml :

Very first requirement of an app is its entry point which is the "home" route. Pattern defines the URI pattern which the route should match.At an entry point, / is used. defaults:_controller states the action of the application when the route is matched.

Controllers

After routes come Controllers. There are a total of 4 controllers named BookController.php, DefaultController.php, LakersController.php, and ReadingController.php located in src/tr/rsywxBundle/Controller .

Two controllers are illustrated below matching book_list and books_search.

Change the ORM mapping files located at

src/tr/rsywxBundle/Resources/config/doctrine)

and build mandatory functions like retrieving data to build a repository.

For example:

File location: src/tr/rsywxBundle/Resources/config/doctrine/BookBook.orm tr/rsywxBundle/Entity/BookBook: type: entity repositoryClass: tr/rsywxBundle/Entity/BookRepository # Add this line to state that you will use BookRepository.php as the repository class for BookBook table table: book_book fields: ...

After that, run php app/console doctrine:generate:entity again. Now notice that a new BookRepository.php file is created under src/tr/rsywxBundle/Entity . Afterwards open that file and you will be able to create your own functions for data manipulation:

Views and Templates

Nothing can be represented without a view as a view is equivalent to a template according to the Symfony.

A template defines how your app would appear to the users. It is a text file that generates a text-based format. PHP template is one of the most popular templates that has a combination of PHP and text code.

A processed image will be shown every time an image tag i.e. <img> comes across.

This is not the complete set of tutorial from Symfony but a brief introduction that might help you make a wiser decision by choosing Symfony for building a web application for your use.

Author Bio: Rachael Wright, an outreaching expert to increase the brand visibility with effective content marketing campaigns. She works with 6S Digital Marketing Solutions, a content marketing company , to help SMEs and large business sectors from planning to execution of effective content campaigns.