We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Understanding MVC in Phalcon

I'm a beginner user of phalcon and have some doubts. I had seeking on the fórum, but I didn't found nothing similar.

  1. How you design your application? Which layers?
  2. Do you use DAO Patterns or make searchs inside model together with business rules?


17.8k
Accepted
answer
edited Apr '14

Honestly, to me, both of your questions highlight one of the neatest things about Phalcon, but also one of the hardest for newcomers (myself included) to overcome. Since I am still pretty new to Phalcon, I will answer your questions to best of my ability. But never fear, there are some smart people around here, so... just hang tight.

How you design your application? Which layers?

PHP design patterns are a hot topic of late and for good reason. Many developers are using PHP to construct more and more complex applications everyday, so it only stands to reason that Design Patterns will come up. If you are new to PHP in general, I would suggest you check out a GIT repo by Dominik Liebler. It contains a host of examples using all sorts of design patterns and will give you a good base line of how to approach an app during development. Another good resource, on the subject of design patterns, is an article over on Nettuts+ titled The Whens and Whys for PHP Design Patterns - by Patkos Csaba.

Now to answer your question. How ever you want! I know that's not what you want to hear, but it's true. If you just starting out though, I would suggest you install Phalcons DevTools. With this tool, you can scaffold out a blank project that will give you some structure to play with. Once you are comfortable, you can play around with it. Best to stick with a pattern though.

Do you use DAO Patterns or make searchs inside model together with business rules?

You can build out your models how ever you choose. Some people do not like to put really anything in their models, some do. Some put all their validation checks and queries there as well. Others might create a seperate class for that stuff. You are free to approach this how ever you want. You will find that if you create you database tables first and use Devtools to then create your model, some scaffolding will happen for you. Things such as setting up your column avaliablity and creating a column map for you. Play around with it, and see what happens.

Also, checkout the projects that the team have put together and see how they did things.

All that will have you reading and researching for a month or more, so be careful. Donn't get code overload! Hope my ramblings helped.

Thanks, now I have so much content to read and see how other people are coding and using phalcon.

Helps me a lot.

Awesome! If you need anything else or have any other questions, feel free to ask. Everyone here is pretty easy going. On Apr 15, 2014 9:08 PM, "Anthony Marques" [email protected] wrote: