We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

partial VS include

hi! what is the difference between 'partial' and 'includes' ? I've read phalcon documents but i did not understand ! Explain more friendly. thanks.


what do you mean by includes ? can you give us an example ?

what do you mean by includes ? can you give us an example ?

look at this link: https://docs.phalcon.io/3.4/en/volt#include


yeah i never used it ( volt ) before

for what i learned partial can be used with either view format ( phtml or volt )

and can accept paramaters

i'm sure someone will help you


An important distinction is that a partial remains a dynamic include, whereas an include is more like a #include in C, which inserts the content of the included file into the one that is doing the including.

What this means in practice is that if A includes B and you change B but you don't rebuild A, your change will not take effect. In contrast, with a partial you can change B without needing to have volt recompile A.

If you always flush the template cache after a change to any template then using includes is fine, and it's easy enough to do that automatically after deploying a change to a live environment, but it's more of a pain to do in development. I'd recommend to stick to partials for that reason.

What is pretty much biggest difference it's the way they works - include will include content of your other template to a final template, partial will call volt method to do all th of it. So pretty much like above. If you want then update this included view you must to remember about clearing cache for also final view.

I remember discussing approximately this years in the past however we never did something stable to enforce it. I accept as true with it's far the way the framework is based, with Active Record guide however don't take my word for it - not a hundred% certain.