Examples of View composers (5)

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)
★ 13109 Created: Jul 2017 Updated: Jul 2021 Laravel version: 8
Files in the example:
- app/Http/ViewComposers/CurrencySelectViewComposer.php
- resources/views/partials/components/currency-select.blade.php
Repository: pterodactyl/panel (Github)
★ 2612 Created: Dec 2016 Updated: Jul 2021 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)
★ 1748 Created: Jul 2016 Updated: Jun 2021 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: spatie/freek.dev (Github)
★ 428 Created: Nov 2017 Updated: Jul 2021 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)
★ 129 Created: Jul 2019 Updated: Jul 2021 Laravel version: 8
Files in the example:
- app/Providers/ViewServiceProvider.php
- resources/views/partials/language-switcher.blade.php

Additional resources on view composers: