This repository is based off the tutorial by Fabien Potencier entitled "Create your own framework... on top of the Symfony2 Components."
The tutorial is broken into 12 parts. Each completed section of the tutorial is tagged using a version number, such as "1.0" for Part 1, "2.0" for Part 2 and so on.
In order to access the exercises, you'll have to check out a copy of the repository...
$ git clone git@github.com:coreymcmahon/Simplex.git
You can then shift between the different versions of the repository used throughout the 12 part tutorial using the syntax:
$ git checkout [version]
... where [version] is the tag you'd like to use, such as:
$ git checkout 2.0
Also, you'll need to install Composer to pull down the dependencies. To do this, execute the following command from within the project directory:
$ curl -s http://getcomposer.org/installer | php
$ php composer.phar install
Enjoy!
In this lesson we learn how to install Composer, a package management tool for PHP projects. We then start building our framework by importing the Symfony2 autoloader and creating the first iteration of our "Hello" application.
Next, we use the Symfony2 HTTP foundation library to provide an abstraction over the HTTP layer.
To provide more control over the flow of requests into and throughout our framework, we implement a "front controller." This involves creating a class through which all requests are routed. We also start to use templating to provide more flexibility in the view layer of our framework.
Now that we have a front-controller and a method of abstracting the flow of HTTP requests and responses through our application, we can start to decouple the format of URLs from the flow of control. We do this using the Symfony 2 Routing component.
We now have a pretty solid base for our framework. We have an abstraction over the HTTP layer, all requests are handled by our internal application logic via the front controller (as opposed to the web server responding to requests for specific resources) and we have a robust mechanism for handling routing URL requests to relevant response objects. The next step is to break out the logic responsible for creating responses into separate units known as controllers.
Note that the end of the lesson introduces a new application for calculating whether or not the current year is a "leap year" or not. This new application is tagged as "5.1" in the repository (the previous application modified to include controllers as discussed in the previous paragraph is tagged as "5.0").
In this lesson the Symfony 2 HTTP Kernel is introduced so that Controllers can be "lazy-loaded" when defining our routes. This means that instead of having to instantiate instances of each controller class when defining routes just in case we need it to service the current request, we can use the HTTP Kernel to work out which controller is going to be used and then create an instance of that single class.
In part 7 we create our own namespace for our evolving framework and split up the components according to the model view controller design pattern.
At this point we have a fully functioning MVC framework, built using the Symfony 2 components. Before we do any further work on developing the framework, it's time to step back and write some tests for the existing code using the PHPUnit framework.
In this lesson we learn how to make our framework extensible by adding events throughout the request handling process using the Symfony 2 event dispatcher.
For large scale web applications, one of the most important ways we can decrease server load is by caching responses. In Part 10 we learn how to add Caching to our framework.
In this lesson we refactor the code to make better use of the HttpKernel component and it's standard implementation which uses events to trigger routing.
In the final lesson we use the Symfony 2 dependency injection component to manage dependencies and configuration between the different components in our application.