Book Image

Symfony2 Essentials

Book Image

Symfony2 Essentials

Overview of this book

Table of Contents (17 chapters)
Symfony2 Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

The configuration format


Symfony2 can handle configuration in different formats: YAML, XML, and annotations. The main configuration files within app/config are provided with the YAML format. XML is usually harder to read, and is used only with third-party bundles.

While both YAML and XML configuration are pretty straightforward and need no explanations, we should stop by annotations for a while. As an example, see the AppBundle/Controller/DefaultController class:

namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class DefaultController extends Controller
{
    /**
     * @Route("/", name="homepage")
     */
    public function indexAction(Request $request)
    {
        // replace this example code with whatever you need
        return $this->render('default/index.html.twig', array(
            'base_dir' => realpath(
                $this->container
                     ->getParameter...