View Composers
View composers are callbacks or class methods that are called when a view is rendered. If you have data that you want to be bound to a view each time that view is rendered, a view composer can help you organize that logic into a single location.
Let's register our view composers within a service provider. We'll use the view helper to access the underlying IlluminateContractsViewFactory contract implementation. Remember, Laravel does not include a default directory for view composers. You are free to organize them however you wish. For example, you could create an AppHttpViewComposers directory: