Models available in all views

Hi all, I just try to play a little with Phalcon in order to get familiar with it. I read the documentation about views and models and found out that all models are available in all views. I'm just wondering if this is a downsize for example when we look at speed and performance. When I have an application with 50 or more models I almost never will need all 50 of them in one view. But they will be always loaded and be available there. Isn't this a little to much of overhead?

The benefit I see in this is that I will never need to do things like:

PostController->IndexAction()....load posts->pass to view

What are your thoughs on this? Did I miss something? Is a model maybe just lazy loaded during my first usage of it?

Thanks

edited Mar '14

Hi Phalcon, thanks for the clear description. I understand the implementation but I have another question. In other frameworks you have also everything in the autoloader through composer or a similiar solution. But there it is still not possible to use the model in a view without passing it to the view via the controller. The solution in Phalcon is differently and I like it (makes things easier) but talking about good practise and bad practice I would like to know if there is any downsize of this approach?



1.3k

there are no downsizes, unless you call your model in your controller or view or anywhere in the app, it wont be used at all, thats why its called autoloading as it loads on demand.



83.5k

A developer can choose whether if he wants lo avoid use models directly at the views or pass them via a viewmodel or the view component, Phalcon does not impose a specific practice. In my personal opinion if it's ok if models are only accesed at views for read only purposes.