Skip to content

Instantly share code, notes, and snippets.

@coreymcmahon
Created May 2, 2012 11:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coreymcmahon/2576072 to your computer and use it in GitHub Desktop.
Save coreymcmahon/2576072 to your computer and use it in GitHub Desktop.
Some Symfony controller code rendering a blog article using a Twig template - http://www.symfonycentral.com
<?php
# src/MyCompany/BlogBundle/Controller/ArticleController.php
namespace MyCompany\BlogBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class ArticleController extends Controller
{
public function viewAction($id)
{
$article = /* build article from model in here */;
return $this->render('MyCompanyBlogBundle:Article:view.html.twig',
array('article' => $article->getBody()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment