Fabulous PHP frameworks: Symfony

Symfony offers extensive features such as excellent debugging and logging, but the learning curve is steeper than most

1 2 3 Page 2
Page 2 of 3

Symfony's view system is architected on the decorator design pattern, in which you specify the fundamentals of a view by defining a template (really just a PHP file) that determines the appearance and behavior of a single page and embedding the template in a layout, which carries global view information to be applied to all pages. Symfony provides plenty of elaborations on this theme. You can define reusable chunks of template code called "partials." You can also create "slots," which are placeholders that can be inserted in just about any view element and whose components are filled in the same way you would assign a value to a variable.

Symfony makes extensive use of the YAML (Yet Another Markup Language) template language. YAML defines your database model's schema, specifies the settings for your application's views, and configures environments, session settings, security, and other characteristics of the controller layer. In short, when you dive into Symfony, be prepared to learn YAML.

Symfony's debugging features are outstanding. Turn debugging on, and a debug toolbar appears in the upper-right corner of every page of your application. (Examine the Web page's source and you'll see piles of JavaScript and HTML that Symfony generated to assist with debugging.) Buttons on the toolbar reveal dropdowns from which you can view information such as the headers of the most recent HTTP exchanges between the browser and server, settings for Symfony global variables, PHP configuration information, parameters passed to the current view template, and more. Symfony also does quite a bit of logging, which you can examine from the debug toolbar. I was able to follow the steps that a request passes through to produce a response, beginning with the routing that occurs when a request arrives at the application index.php file all the way to the formulation of the HTTP response.

In addition, when you run Symfony in a development environment, it will log all SQL queries into a log subdirectory. Because Symfony code does not expose SQL directly, this logging feature is useful if you need to track down database-related problems that are not apparent at the object level. (This SQL logging information is also available from the debug toolbar.)

Symfony database ins and outs
Symfony uses an ORM (object relational mapping) system for database access. Actually, Symfony uses either of two popular PHP ORM frameworks: Propel and Doctrine. Consequently, low-level SQL is abstracted away from the development process, and you can treat all database access as being the manipulation of persistent objects.

1 2 3 Page 2
Page 2 of 3
How to choose a low-code development platform