Symfony Book Introduction

The Symfony book is basically the bible for Symfony 2 developers. Best of all it’s completely free for you to download and start learning right away. You can either read it on the website or get the PDF.

Here’s our short guide to the key content covered and a summary of what you will learn.

Symfony and HTTP Fundamentals

The Symfony book has a great introduction chapter for everyone to read. It explains the fundamentals of web development – HTTP. After covering the basics of HTTP, it ends with a summary of the Symfony framework itself:

  • It is a PHP library
  • It encompasses a set of components, as well as third-party libraries
  • It gives developers solid configuration and a library that ties everything together
  • The goal is a consistent experience
  • The framework itself is a bundle/plug in and can be configured or entirely replaced
  • Your app development isn’t imposed on by Symfony, due to it’s powerful tools
  • Beginner/normal users can quickly begin implementing Symfony, whilst for advanced users, the opportunities are endless

Symfony versus Flat PHP

This chapter is a great introduction for those who are not sure why to go with Symfony 2. It explains clearly the reasons why Symfony 2 gives you the ability to develop more efficiently, with solid code, rather than with flat PHP.

The Symfony book guides you through the process of creating a basic app in flat PHP, then shows you how to make it more organised. It takes you a journey and by the end of the chapter you understand how Symfony can be so beneficial in helping you with boring, mundane tasks and create good solid code.

Installing and Configuring Symfony

The third chapter helps you set up and begin running with an application built on Symfony, using downloadable starter projects, so that you can begin developing right away. Very helpful! It covers composer, getting installed, set up and starting, plus source control.

Creating pages in Symfony

In this chapter, as the title suggests, it’s all about starting to make pages. A new page is a fairly simple 2-step process that involves creating a route defining the URL, specifying a controller as a PHP function, creating a controller that receives the request and turns it into a Symfony Response object that is then sent back to you.

It basically mimics the way the internet works; interactions on the web are initiated with a HTTP request, and the job of the application is to interpret and return a HTTP response. Things get more interesting in upcoming chapters.

The Symfony book next goes into even more powerful tricks and tools. In fact, the more you learn, the more you really appreciate what this framework can do.

Controller

In this chapter we learn about controllers. You create these PHP functions which then takes the information from the HTTP request, constructs it and then returns a HTTP response. This response could include:

  • HTML page
  • XML doc
  • JSON array
  • Image
  • 404 error

In fact the controller encompasses whatever logic you decide on, for your app to show the rendered content. The chapter demonstrates how a controller would render a page.

Routing

Routing is a system in Symfony 2 that allows the mapping of a URL of incoming requests, to the controller that processes the request. Having pretty-looking URLs is kind of important. Making a URL change using Symfony’s router involves a simple change.

The Symfony router lets you create complex routes that map to the controller, generate URLS within templates and controllers, load up resources using bundles and allows debugging.

Creating and Using Templates

In this chapter of the Symfony book, we learn how to write flexible templates for returning content, populating email bodies, short cuts and ways to extend templates and reuse your template code.

Templating is so important because of the controller being responsible for handling each Symfony app request. The controller sends off the work to other places so the code can be tested and also reused.

Where HTML, CSS or other content is needed to be generated by the controller, it hands the work to the templating engine. There are two different template renderers, traditional PHP templates and Twig templates.

Databases and Doctrine

Symfony comes integrated with Doctrine1. This is a library that gives you powerful tools that allows you to focus on your objects and to use any PHP object to hold your data.

It relies on mapping metadata info, and allows the creation of complex queries. In the eight chapter of the Symfony book, we learn about the philosophy of Doctrine fixtures and see that working with a database is fairly simple.

Symfony book

Databases and Propel

The propel integration is described in this chapter. A challenging task in development is persisting and reading info to and from a database. Symfony doesn’t come with an object relational mapper (ORM) but instead you can install propel for this.

Testing

We love testing at Code Review and in past projects, testing is one of the most important actions you can take throughout the entire development process.

Whenever you write a new line of code, you can add new bugs. To ensure good solid code from start to finish, you can test your code with functional and unit tests. It gives you peace of mind in the real world when doing client work.

You don’t need permission to test, just do it as part of your own quality control of your work.

Validation

It’s common to do validation when creating web applications. Data that you enter in forms needs to be validated, and before it gets added to a database or passed on to a web service. It enables you to guarantee that any object is valid.

Symfony comes with a powerful validator component, which makes this easy and clear to do. It can be used anywhere with an object, but is most often used with forms.

Forms

This chapter of the Symfony book covers the important building blocks of forms and guides you through building a complex form from the start. The first goal is translating data from an object to a HTML form so the user can modify the data, the second goal is to the take the submitted data and reapply it to the object.

We learn the main features of the form library. For many developers, using HTML forms can be very challenging, thankfully Symfony keeps things relatively simple in comparison with the integration of the form component.

Security

This is a really indepth chapter and covers the serious issue of getting the security right for your application. The security component in Symfony 2 follows a solid model that is based on authentication and authorisation.

There is a 2-step process involved, the first being the security system identifies the user and has to authenticate them, the second step is determining access to a given resource.

HTTP Cache

The framework of Symfony is designed to follow HTTP and caching is included within this. Being able to use the cache system means you can overcome some of the headaches that can ensue as your site grows.

The processing that is usually performed for each request should only be done once, and that’s what we learn in this chapter of the Symfony book, and what caching helps you accomplish.

Translations

We learn the translations component in this chapter of the Symfony book. The process has three main steps. These include enabling and configuring Symfony’s translation service, abstract messages/strings, translating each message and managing the users locale.

Service Container

The service container allows the standarding and centralising of objects in an application. It essentially makes your life a bit easier. All of the core Symfony classes use the container.

In this chapter of the Symfony book we learn how to extend, configure and use any object using the service container. This includes customising objects from any third-party bundle. It helps you to write code much more easily, so that it is reusable, testable and decoupled, making it simpler to maintain.

Performance

This chapter of the Symfony book is all about making things even quicker. We learn some of the most common, powerful ways to do this. It includes using a byte code cache, composers class map functionality, caching the autoloader and using bootstrap files.

Internals

You only need to read this chapter of the Symfony book if you really want to know how Symfony works underneath. It uncovers some of the code layers. If you’ve already read and understood the Symfony book this far, you might as well keep going and learn Symfony more indepth, or if not, set it aside for now until you are read to learn more about behind the scenes.

The Symfony Stable API

This very brief final chapter, the Symfony book talks about stable API. It covers what this is, and a list of components that are publicly tagged API.

Diving Deeper!

Ready to start putting what you’ve learned in the Symfony book into practice?

Overall the Symfony book is an essential part of learning Symfony. Many people learn in different ways, and it’s always good to watch and learn how things are done in real life rather than just reading text.

Here at Code Review you can watch a range of free and members only practical training videos. Each Symfony 2 tutorial is broken down into short segments to make your learning easier.

Symfony Getting Started

Symfony Getting Started

In this post we will point you in the direction of some great Symfony getting started videos. On first impressions Symfony can appear really difficult and is easy to get freaked out by. Chris helps take you through different segments of learning Symfony 2, step by step in this series.

You can also visit our dedicated members area for lots more beginners training videos.

Symfony getting started videos

Here are some of our most popular Symfony getting started topics:

In this beginners video, you learn out to set up your development environment in Symfony 2 so that you can begin working on your first project.

Making sense of it all!

In part one, you set up your Linux server that allowed us to install your Symfony getting started essentials. In this second video you will look at the files and folders that were downloaded with the default install and learn what they all mean. It’s a very high level overview, and designed to give you more of an understanding of the ways that the files and folders fit together.

Symfony Bundles

Previously we looked at the default install that you get with Symfony 2. Next you will learn how to set up your first Symfony 2 bundle. The video features routing, a controller and Twig templates.

Bootstrap

We looked at a basic controller in the last video with a very basic template. When you put Symfony into practice in real life, you are more likely to use a web framework to help speed up your development. This is where we will use Twitter Bootstrap, which has recently been rebranded to just Bootstrap. Bear in mind that there are other ways to set up Bootstrap and this is the way Chris has had success with.

Backend Database

The previous video showed you some front end Symfony getting started tips with Bootstrap. In the next training video we will look more at the backend, and connecting Symfony 2 to our database. Chris talks you through Doctrine Object Relational Mappers (ORM). It can feel overwhelming as a beginner to learn a new way to interacting with your database, new concepts, configuration, set up and more. Hopefully this video will help demystify what appears at first to be a very complicated way of doing something, and let you see that it is well worth learning.

Symfony 2 Forms

We have looked at Doctrine, which allowed you to create, update and delete entities in your database. In this next video, we look at a corner stone of modern web development – the Symfony 2 form. Symfony 2 has a great form builder. Let’s look at basic forms, how to render them in your templates, how to handle, validate and save submitted form data and how to repopulate a Symfony 2 form with existing data.

Join Us!

In this Symfony getting started post, we’ve looked at a few of Chris’s introductory videos. You can check out tons more beginners and intermediate Symfony 2 tutorials in our members area.

We hope to make learning Symfony something fun and more straight forward than struggling along on your own. Have you got something specific you’d like to learn, a particular struggle or just a question about Symfony? Just get in touch and ask via our contact page. Hope to see you inside!

Symfony 2 Tutorial: An Introduction

Hello and Welcome to the blog!

Learning Symfony is something Chris has been passionate about for a long time. Back when he first started using it, there wasn’t a great deal of documentation or a useful Symfony 2 tutorial around. Of what there was, much of it was in French.

When you’re in the middle of a real life important Symfony 2 project for a client, learning French from scratch first wasn’t an option.

Chris spent hours and hours learning, working stuff out and becoming the highly skilled Symfony developer he is today. He’s learned through real world projects whilst under pressure.

image-symfony-2-tutorial.png

 

A promise to teach

During this period, Chris made the promise to himself that once he had completed his current projects, he would create a Symfony 2 tutorial which became a series to help other developers learn the framework, so that they wouldn’t have to go through many of the struggles that he did.

He kept that promise and you can now find a ton of Chris’s training videos on YouTube which receive great feedback, and Chris regularly receives emails of thanks from his 1400+ subscribers that grows every day.

Launching Code Review

A natural progression from the YouTube videos was to launch a dedicated Symfony 2 tutorial website that could be organised into different projects and series, with a small monthly membership fee that allows Chris to put more time and effort into creating training that is really helpful and detailed.

Members can also submit their own requests for future videos if they have something in mind they are struggling with or would like to learn more about.

A very small selection of the many comments have included:

Great tutorials… Looking forward to more advanced topics on symfony… very helpful for developers like me who are new to symfony… Thanks again…

Chris, thank you for putting in the time to do these.  Your videos have been a great help in demystifying Symfony, your examples are great blue prints that bring clarity to this framework.  Much appreciated!

You’re a hero!! 😀 you’ve saved my day!!! great tutorials keep up the good work!

What can you expect from a Code Review Symfony 2 Tutorial?

If you’ve already seen and enjoyed Chris’s videos on YouTube you will already have an idea of how his videos guide you through the process, step by step in smaller segments.

Members of Code Review benefit from watching real world projects that you might have to deal with for your clients. New step by step videos are added weekly that guide you through a new concept or situation.

The next Symfony 2 tutorial and future ones are listed. The range of topics are very exciting for intermediate developers.

Where else can you learn Symfony?

There are a few other tutorial websites out there. Everyone has their own likes and dislikes so have a look around and find what works best you for. We hope you will give our membership a try though!

There is now more and more Symfony documentation (specifically the manual and cookbook which are free on the official website), as well as a couple of books on Amazon. What we will say is that although reading the documentation is useful, there is nothing like watching coding in action and also following along with your own projects, and that’s where Code Review comes in.

What would you most like to see a Symfony 2 tutorial on?

Leave a comment, we’d love to hear from you and how you are getting on with your development projects.