Skip to content

Instantly share code, notes, and snippets.

@coreymcmahon
Created April 29, 2012 11:03
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/2549428 to your computer and use it in GitHub Desktop.
Save coreymcmahon/2549428 to your computer and use it in GitHub Desktop.
Basic Symfony Controller demonstrating the use of a logical name for template - http://www.symfonycentral.com
<?php
// src/MyCompany/BlogBundle/Controller/BlogController.php
namespace MyCompany\BlogBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class BlogController extends Controller
{
public function viewAction($id)
{
$post = $this->get('doctrine')
->getEntityManager()
->getRepository('MyCompanyBlogBundle:Post')
->find($id);
// Use the logical name of the template
return $this->render('MyCompanyBlogBundle:Blog:show.html.twig', array(
'post' => $post,
));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment