Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9533f9a

Browse files
committed
merged branch hrbonz/part12_fixes (PR #19)
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.
2 parents d0ff8bc + 400c087 commit 9533f9a

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

book/part12.rst

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ some code from the front controller to it::
1212

1313
namespace Simplex;
1414

15-
use Symfony\Component\HttpKernel\HttpKernel;
1615
use Symfony\Component\Routing;
1716
use Symfony\Component\HttpKernel;
1817
use Symfony\Component\EventDispatcher\EventDispatcher;
1918

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

183182
$response->send();
184183

184+
As all the objects are now created in the dependency injection container, the framework code should be the previous simple version::
185+
186+
<?php
187+
188+
// example.com/src/Simplex/Framework.php
189+
190+
namespace Simplex;
191+
192+
use Symfony\Component\HttpKernel\HttpKernel;
193+
194+
class Framework extends HttpKernel
195+
{
196+
}
197+
185198
.. note::
186199

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

0 commit comments

Comments
 (0)