Author: Awais Farooq

  • Service Container

    In any application, objects tend to increase as the application grows. As objects increase, the dependency between the objects also increases. Object dependency needs to be handled properly for a successful application. As discussed in the Components chapter, Symfony provides an easy and efficient component, DependencyInjection to handle object dependency. A service container is a container of…

  • Components

    As discussed earlier, Symfony components are standalone PHP library providing a specific feature, which can be used in any PHP application. Useful new components are being introduced in each and every release of Symfony. Currently, there are 30+ high quality components in Symfony framework. Let us learn about the usage of Symfony components in this…

  • Architecture

    Symfony is basically a collection of high quality components and bundles. Components are collection of classes providing a single core functionality. For example, Cache component provides cache functionality, which can be added to any application. Components are building blocks of a Symfony application. Symfony has 30+ high quality components, which are used in many PHP framework such…

  • Installation

    This chapter explains how to install Symfony framework on your machine. Symfony framework installation is very simple and easy. You have two methods to create applications in Symfony framework. First method is using Symfony Installer, an application to create a project in Symfony framework. Second method is composer-based installation. Let’s go through each of the…

  • Introduction

    A PHP web framework is a collection of classes, which helps to develop a web application. Symfony is an open-source MVC framework for rapidly developing modern web applications. Symfony is a full-stack web framework. It contains a set of reusable PHP components. You can use any Symfony components in applications, independently from the framework. Symfony…

  • Generating Module

    Let us see how to generate a Module. Step 1 − To generate a module, open the module generation interface and fill in the form. Step 2 − Then, click the “Preview” button and “Generate”. Step 3 − We need to activate the module. Modify the modules application component in the config/web.php file. Step 4 − To check whether our newly generated module…

  • Generating Controller

    Let us see how to generate a Controller. Step 1 − To generate a controller with several actions, open the controller generator interface fill in the form. Step 2 − Then, click the “Preview” button and “Generate”. The CustomController.php file with index, hello, and world actions will be generated in the controllers folder. Form Generation Step 1 − To generate…

  • Creating a Model

    To create a Model in Gii − Generating CRUD Let us generate CRUD for the MyUser model. Step 1 − Open the CRUD generator interface, fill in the form. Step 2 − Then, click the “Preview” button and “Generate”. Go to the URL http://localhost:8080/index.php?r=my-user, you will see the list of all users. Step 3 − Open the URL http://localhost:8080/index.php?r=my-user/create. You…

  • Gii

    Gii is the extension, that provides a web-based code generator for generating models, forms, modules, CRUD, and so forth. By default, the following generators are available − To open the gii generation tool, type http://localhost:8080/index.php?r=gii: in the address bar of the web browser. Preparing the DB Step 1 − Create a new database. Database can be prepared in…

  • Localization

    I18N (Internationalization) is the process of designing an application that can be adapted to various languages. Yii offers a full spectrum of I18N features. Locale is a set of parameters that specify a user’s language and country. For example, the en-US stands for the English locale and the United States. Yii provides two types of languages:…