I'm still starting out with Laravel, currently sifting through the documentation. The documentation sheds little light on this subject, simply stating that:
"View creators are very similar to view composers; however, they are executed immediately after the view is instantiated instead of waiting until the view is about to render."
But what exactly does this mean? What are the advantages and disadvantages of this? Where would it be preferable to use a view creator instead of a view composer?
Hey, thanks. I do actually understand what view composers and creators are for. I mentioned in my question that the documentation just doesn't elaborate too much on the usefulness of view creators in particular.
I understand they're executed after the view is instantiated rather than before it's about to render - which is fine, but why is that useful? I've done some looking around and it appears people are saying it will allow me to modify variables before they're output, whereas view composers would not allow me to do that - which makes sense. Is that really their only use, though?
I'm supposing this is one of those things that will hit me when I come to needing it...but until then, any sort of examples of where this sort of thing would be useful, would be appreciated.
The basic difference between a View Creator and a View Composer is that a View Creator is called directly when the view is instantiated; whereas a View Composer is called whenever the view is rendered. So this means, you have control over when data is bound to the view and if it is overridden, e.g. you can set default value(s) for the View in the creator (before any data is bound using with). You can then override those default values when the View is called either in the Composer or by directly passing data in the conventional manner.