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 model with Symfony


How does an application remember things? Persistence is the name of the phenomenon by which any application maintains its state. To have persistence, you need to have data structure(s). To manage data structures in a typical engineering perspective, you can use models—the M in the MVC paradigm.

Getting ready

Remember that you have some toppings as well as some ingredients to be added to your pizza dish. So, typically, you need an array to store (represent) the toppings and the ingredients. This is a green signal to go ahead and use model. But again, there is a twist in the tale. Symfony has no default model system in place. Bad design? Maybe not. It was originally designed to be a request-response system. Symfony looks to you for this purpose. You can create a model freestyle.

How to do it...

  1. Start by creating a new directory at the same level as the controller. Name it Model. This is descriptive naming, you see.

  2. Inside the Model directory, use PhpStorm's new class...