Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

Code Examples of view composers

Discover how to use Laravel's view composers method in real-world applications. Browse 6 examples from popular open-source projects.

6 examples
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.

monicahq/monica

  • 23656
  • Created Jul 2017
  • Updated Nov 2025

Files in this example

  • app/Http/ViewComposers/CurrencySelectViewComposer.php
    • resources/views/partials/components/currency-select.blade.php
View full example

pterodactyl/panel

  • 8314
  • Created Dec 2016
  • Updated Nov 2025

Files in this example

  • app/Providers/ViewComposerServiceProvider.php
    • app/Http/ViewComposers/AssetComposer.php
      • resources/views/templates/wrapper.blade.php
View full example

Bottelet/DaybydayCRM

  • 2311
  • Created Jul 2016
  • Updated Mar 2025

Files in this 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
View full example

range-of-motion/budget

  • 1057
  • Created Jul 2017
  • Updated Dec 2024

Files in this example

  • app/Providers/AppServiceProvider.php
    • resources/views/layout.blade.php
View full example

spatie/freek.dev

  • 636
  • Created Nov 2017
  • Updated Nov 2025

Files in this example

  • app/Http/ViewComposers/LazyViewComposer.php
    • app/Providers/ViewServiceProvider.php
      • resources/views/front/components/lazy.blade.php
View full example

tighten/onramp

  • 164
  • Created Jul 2019
  • Updated Nov 2025

Files in this example

  • app/Providers/ViewServiceProvider.php
    • resources/views/partials/language-switcher.blade.php
View full example

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.