PHP code example of engageinteractive / laravel-frontend

1. Go to this page and download the library: Download engageinteractive/laravel-frontend 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/ */

    

engageinteractive / laravel-frontend example snippets


namespace App\Config;

use EngageInteractive\LaravelFrontend\ConfigProvider;

class FrontendConfigProvider extends ConfigProvider
{
    /**
     * Key to use when retrieving config values.
     *
     * @var string
     */
    protected $configKey = 'laravel-frontend';
}

class AppServiceProvider extends ServiceProvider
{
...

    /**
     * All of the container bindings that should be registered.
     *
     * @var array
     */
    public $bindings = [
        \EngageInteractive\LaravelFrontend\ConfigProvider::class => \App\Config\FrontendConfigProvider::class,
    ];

...
}
sh
php artisan vendor:publish --provider="EngageInteractive\LaravelFrontend\ServiceProvider"



namespace App\Providers;

use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;

use EngageInteractive\LaravelFrontend\PageDefaultsViewComposer as BaseViewComposer;

class PageDefaultsViewComposer extends BaseViewComposer
{
    /**
     * Gets frontend default variables.
     *
     * @return array
     */
    protected function defaultsForFrontend()
    {
        return [
            'page' => [
                'title' => 'HTML Meta Title',
                'description' => 'HTML Meta Description',
                ...
            ],
        ];
    }

    /**
     * Gets application default variables (i.e. ones used when not in the
     * frontend templates.)
     *
     * @return array
     */
    protected function defaultsForApp()
    {
        return [
            'page' => [
                'title' => config('app.name'),
                ...
            ],
        ];
    }
}