PHP code example of netpeoplehu / view-composer

1. Go to this page and download the library: Download netpeoplehu/view-composer library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

netpeoplehu / view-composer example snippets


Netpeople\ViewComposer\Providers\ViewComposerServiceProvider::class,

    App\Http\ViewComposers\ExampleComposer::class => [
        'welcome',
        'layout.main'
    ]

    /**
     * Bind data to the view.
     *
     * @param  View  $view
     * @return void
     */
    public function compose(View $view)
    {
        $view->with('example', 'It works');
    }
bash
php artisan vendor:publish --provider=Netpeople\\ViewComposer\\Providers\\ViewComposerServiceProvider
bash
php artisan vendor:publish --provider=Netpeople\\ViewComposer\\Providers\\ViewComposerServiceProvider
bash
php artisan make:composer ExampleComposer