Book Image

PhpStorm Cookbook

By : Mukund Chaudhary
Book Image

PhpStorm Cookbook

By: Mukund Chaudhary

Overview of this book

Table of Contents (16 chapters)
PhpStorm Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Creating a controller with Symfony


So you will have to create a new controller first. This controller will be responsible for making decisions about how you will cook your Pizza.

Change often leads to confusion, so it is better to make few changes in the Symfony directory structure and just jump to create a new controller.

How to do it...

Create a new controller class inside the directory <Project-Root>/src/Acme/DemoBundle/Controller. Name it CookingController.php. There are a few rules to follow:

  • By default, you should create a controller with the suffix Controller in the name

  • Each controller should extend a class Controller that is defined in the namespace Symfony\Bundle\FrameworkBundle\Controller\Controller

  • The controller should be defined in the namespace Acme\DemoBundle\Controller

  • Since you will be required to route the methods as actions, you will need to use namespace Sensio\Bundle\FrameworkExtraBundle\Configuration\Route.

  • You need to define a route in a configuration file (a file...