Examples of View composers (6)

Short information about view composers

View composers are usually used to define some global variables that would be available in some partial Blade View, no matter where that View is called.
Typical examples are global things like page title, meta tags, some global stats numbers to be seen in the header/sidebar.
Read more in the official Laravel docs.

Repository: monicahq/monica (Github)
★ 16962 Created: Jul 2017 Updated: Aug 2022 Laravel version: 8
Files in the example:
- app/Http/ViewComposers/CurrencySelectViewComposer.php
- resources/views/partials/components/currency-select.blade.php
Repository: pterodactyl/panel (Github)
★ 4072 Created: Dec 2016 Updated: Aug 2022 Laravel version: 8
Files in the example:
- app/Providers/ViewComposerServiceProvider.php
- app/Http/ViewComposers/AssetComposer.php
- resources/views/templates/wrapper.blade.php
Repository: Bottelet/DaybydayCRM (Github)
★ 2016 Created: Jul 2016 Updated: Jul 2022 Laravel version: 7
Files in the example:
- app/Http/ViewComposers/ClientHeaderComposer.php
- app/Providers/ViewComposerServiceProvider.php
- config/app.php
- resources/views/clients/show.blade.php
- resources/views/partials/clientheader.blade.php
Repository: range-of-motion/budget (Github)
★ 781 Created: Jul 2017 Updated: Jul 2022 Laravel version: 8
Files in the example:
- app/Providers/AppServiceProvider.php
- resources/views/layout.blade.php
Repository: spatie/freek.dev (Github)
★ 521 Created: Nov 2017 Updated: Aug 2022 Laravel version: 8
Files in the example:
- app/Http/ViewComposers/LazyViewComposer.php
- app/Providers/ViewServiceProvider.php
- resources/views/front/components/lazy.blade.php
Repository: tighten/onramp (Github)
★ 145 Created: Jul 2019 Updated: Aug 2022 Laravel version: 8
Files in the example:
- app/Providers/ViewServiceProvider.php
- resources/views/partials/language-switcher.blade.php

Additional resources on view composers: