This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* Import the autoloader and classes from external namespaces */ | |
| require_once __DIR__.'/../src/autoload.php'; | |
| use Symfony\Component\HttpFoundation\Request; | |
| use Symfony\Component\HttpFoundation\Response; | |
| /* Build the request and response objects using HttpFoundation */ | |
| $request = Request::createFromGlobals(); | |
| $response = new Response(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // ... | |
| /* Define the routes for our application */ | |
| $routes = new Routing\RouteCollection(); | |
| $routes->add('hello', new Routing\Route('/hello/{name}', array('name' => 'World'))); | |
| $routes->add('bye', new Routing\Route('/bye')); | |
| /* Set up the context and establish whether this request matches a route */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // ... | |
| $routes->add('hello', new Routing\Route('/hello/{name}', array( | |
| 'name' => 'World', | |
| '_controller' => function ($request) { | |
| return render_template($request); | |
| } | |
| ))); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // ... | |
| $request = Request::createFromGlobals(); | |
| $routes->add('leap_year', new Routing\Route('/is_leap_year/{year}', array( | |
| 'year' => null, | |
| '_controller' => 'LeapYearController::indexAction', | |
| ))); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace Simplex; | |
| use Symfony\Component\HttpFoundation\Request; | |
| use Symfony\Component\HttpFoundation\Response; | |
| use Symfony\Component\Routing\Matcher\UrlMatcher; | |
| use Symfony\Component\Routing\Exception\ResourceNotFoundException; | |
| use Symfony\Component\HttpKernel\Controller\ControllerResolver; | |
| class Framework |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace Calendar\Controller; | |
| use Symfony\Component\HttpFoundation\Request; | |
| use Symfony\Component\HttpFoundation\Response; | |
| use Calendar\Model\LeapYear; | |
| class LeapYearController | |
| { | |
| // ... controller code in here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace Calendar\Model; | |
| class LeapYear | |
| { | |
| // ... code for function isLeapYear in here | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace Simplex; | |
| use Symfony\Component\Routing\Matcher\UrlMatcherInterface; | |
| use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface; | |
| class Framework | |
| { | |
| public function __construct(UrlMatcherInterface $matcher, ControllerResolverInterface $resolver) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace Simplex\Tests; | |
| use Simplex\Framework; | |
| class FrameworkTest extends \PHPUnit_Framework_TestCase | |
| { | |
| public function testNotFoundHandling() | |
| { | |
| $this->assertEquals(/* test condition in here */); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| require_once __DIR__.'/../vendor/.composer/autoload.php'; | |
| // ... etc | |
| use Symfony\Component\EventDispatcher\EventDispatcher; | |
| $dispatcher = new EventDispatcher(); | |
| $dispatcher->addListener('response', function (Simplex\ResponseEvent $event) { | |
| $response = $event->getResponse(); |