Last active
February 5, 2018 15:16
-
-
Save derrabus/ded9110d60d711060b4248ecaa2c68d9 to your computer and use it in GitHub Desktop.
Application-aware Silex Controller
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 Acme\MyApp; | |
use Silex\Application; | |
use Silex\Provider\TwigServiceProvider; | |
$app = new Application(); | |
$app->register(new TwigServiceProvider()); | |
$app->get('/my_route', 'Acme\MyApp\Controller\MyController::myAction'); |
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 Acme\MyApp\Controller; | |
use Silex\Application; | |
class MyController | |
{ | |
public function myAction(Application $app): string | |
{ | |
// Insert controller logic here. | |
return $app['twig'] | |
->render('my_template.html.twig', $parameters); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment