PHP code example of aon2003 / laravel-page-titles

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

    

aon2003 / laravel-page-titles example snippets


'web' => [
    ...
    \Aon2003\PageTitles\Middleware\PageTitles::class,
],

return [
    'index' => env('APP_NAME', 'Home Page'),
    'home' => env('APP_NAME', 'Home Page'),
];

return [
    ...
    '{route_name}' => '{page_title}',
];

<title>{{ __($page_title) }}</title>

return [
    ...
    'index' => 'Hello, :0!',
];

function index() {
    $page_props = ['Alex'];
    
    return view('{page}', compact('page_props'));
}

return [
    /*
    |--------------------------------------------------------------------------
    | Translation File Name
    |--------------------------------------------------------------------------
    |
    | Used to find the page titles translations.
    | If you change the translation file name, you MUST change this variable, too!
    |
    */

    'translation_file_name' => 'page-titles',
];
bash
php artisan vendor:publish --tag="laravel-page-titles"
html
<title>{{ __($page_title, $page_params ?? []) }}</title>