Category: Symfony

  • File Uploading

    Symfony Form component provides FileType class to handle file input element. It enables easy uploading of images, documents, etc. Let us learn how to create a simple application using FileType feature. Step 1 − Create a new application, fileuploadsample using the following command. Step 2 − Create an entity, Student, having name, age and photo as shown in the following code. src/AppBundle/Entity/Student.php…

  • Validation

    Validation is the most important aspect while designing an application. It validates the incoming data. This chapter explains about form validation in detail. Validation Constraints The validator is designed to validate objects against constraints. If you validate an object, simply map one or more constraints to its class and then pass it to the validator…

  • Forms

    Symfony provides various in-built tags to handle HTML forms easily and securely. Symfony’s Form component performs form creation and validation process. It connects the model and the view layer. It provides a set of form elements to create a full-fledged html form from pre-defined models. This chapter explains about Forms in detail. Form Fields Symfony…

  • Doctrine ORM

    In Symfony web framework, model plays an important role. They are the business entities. They are either provided by customers or fetched from back-end database, manipulated according to business rules and persisted back into the database. They are the data presented by Views. Let us learn about models and how they interact with back-end system…

  • View Engine

    A View Layer is the presentation layer of the MVC application. It separates the application logic from the presentation logic. When a controller needs to generate HTML, CSS, or any other content then, it forwards the task to the templating engine. Templates Templates are basically text files used to generate any text-based documents such as…

  • Routing

    Routing maps request URI to a specific controller’s method. In general, any URI has the following three parts − For example, in URI / URL, http://www.tutorialspoint.com/index?q=data, www.tutorialspoint.com is the host name segment, index is the path segment and q=data is the query segment. Generally, routing checks the page segment against a set of constraints. If any constraint…

  • Controllers

    Controller is responsible for handling each request that comes into Symfony application. Controller reads an information from the request. Then, creates and returns a response object to the client. According to Symfony, DefaultController class is located at “src/AppBundle/Controller”. It is defined as follows. DefaultController.php Here, the HttpFoundation component defines an object-oriented layer for the HTTP specification, and the FrameworkBundle contains most of…

  • Creating a Simple Web Application

    This chapter explains how to create a simple application in Symfony framework. As discussed earlier, you know how to create a new project in Symfony. We can take an example of “student” details. Let’s start by creating a project named “student” using the following command. After executing the command, an empty project is created. Controller…

  • Bundles

    A Symfony bundle is a collection of files and folders organized in a specific structure. The bundles are modeled in such a way that it can be reused in multiple applications. The main application itself is packaged as a bundle and it is generally called AppBundle. A bundle may be packaged specific to an application such…

  • Expression

    As we discussed earlier, expression language is one of the salient features of Symfony application. Symfony expression is mainly created to be used in a configuration environment. It enables a non-programmer to configure the web application with little effort. Let us create a simple application to test an expression. Step 1 − Create a project, expression-language-example. Step…