Skip to content

Instantly share code, notes, and snippets.

@jehaby
Last active April 12, 2016 11:01
Show Gist options
  • Save jehaby/6c9cc193e08bbf35f5b9561abb42402d to your computer and use it in GitHub Desktop.
Save jehaby/6c9cc193e08bbf35f5b9561abb42402d to your computer and use it in GitHub Desktop.
Static pages with Symfony
<?php
class SomeController extends Controller {
/**
* @Route("/speaker/{slug}", name="speaker")
*/
public function speakerAction($slug)
{
$pagesDirectory = $this->getParameter('kernel.root_dir') . '/Resources/pages/';
$speakerInfo = include $pagesDirectory . $slug . '.php';
if (empty($speakerInfo)) {
throw new NotFoundHttpException;
}
return $this->render('speaker.html.twig', $speakerInfo + ['slug' => $slug]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment