Skip to content

Commit

Permalink
merged branch hrbonz/part12_fixes (PR #19)
Browse files Browse the repository at this point in the history
Commits
-------

400c087 add framework code as people would probably modify it following first code example (putting object creations in src/Simplex/Framework.php)
de69a87 HttpKernel name can't be imported twice, if importing only Symfony\Component\HttpKernel\HttpKernel there will be problems later with HttpKernel subclasses (HttpKernel\Controller\ControllerResolver first and the others following). Could use 'use ... as ...' but I don't like it.

Discussion
----------

Part12 fixes for clarity

Fixed two things :

  * the first example didn't work, the duplicate name '`HttpKernel`' makes the import impossible. I understand that this example is not supposed to be followed but it's here and most people will make the modifications to `src/Simplex/Framework.php` and `web/front.php`. For the sake of don-t-panic-the-newbie, all the code presented should work ::)
  * Linked to the first point, expose the final code of `src/Simplex/Framework.php` to make sure everybody gets it.
  • Loading branch information
fabpot committed Feb 7, 2012
2 parents d0ff8bc + 400c087 commit 9533f9a
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions book/part12.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ some code from the front controller to it::

namespace Simplex;

use Symfony\Component\HttpKernel\HttpKernel;
use Symfony\Component\Routing;
use Symfony\Component\HttpKernel;
use Symfony\Component\EventDispatcher\EventDispatcher;

class Framework extends HttpKernel
class Framework extends HttpKernel\HttpKernel
{
public function __construct($routes)
{
Expand Down Expand Up @@ -182,6 +181,20 @@ The front controller is now only about wiring everything together::

$response->send();

As all the objects are now created in the dependency injection container, the framework code should be the previous simple version::

<?php

// example.com/src/Simplex/Framework.php

namespace Simplex;

use Symfony\Component\HttpKernel\HttpKernel;

class Framework extends HttpKernel
{
}

.. note::

If you want a light alternative for your container, consider `Pimple`_, a
Expand Down

0 comments on commit 9533f9a

Please sign in to comment.