PHP code example of devrabiul / laravel-pwa-kit

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

    

devrabiul / laravel-pwa-kit example snippets


return [
    'enable_pwa' => true,
    'install-toast-show' => true,
    'manifest' => [
        'name' => env('APP_NAME', 'Laravel'),
        'short_name' => 'LPT',
        'start_url' => '/',
        'theme_color' => '#FF5733',
        'background_color' => '#ffffff',
        'display' => 'standalone',
        'icons' => [
            [
                'src' => 'logo.png',
                'sizes' => '512x512',
                'type' => 'image/png',
            ]
        ],
    ],
    'livewire-app' => false,
];

'livewire-app' => true,

use Illuminate\Http\Request;
use Devrabiul\PwaKit\Facades\PwaKit;

public function updateLogo(Request $request)
{
    // $request['logo'] contains the uploaded file
    $result = PwaKit::updatePWALogo($request);

    if ($result['status']) {
        return back()->with('success', $result['message']);
    } else {
        return back()->withErrors($result['errors'] ?? $result['error']);
    }
}

use Devrabiul\PwaKit\Facades\PwaKit;

$manifest = [
    'appName' => env('APP_NAME', 'Laravel'),
    'name' => env('APP_NAME', 'Laravel'),
    'shortName' => env('APP_NAME', 'Laravel'),
    'short_name' => env('APP_NAME', 'Laravel'),
    'startUrl' => '/',
    'start_url' => '/',
    'scope' => '/',
    'author' => 'Rabiul Islam',
    'version' => '1.0',
    'description' => 'A description of your web app.',
    'orientation' => 'portrait',
    'dir' => 'auto',
    'lang' => 'en',
    'display' => 'standalone',
    'themeColor' => '#FF5733',
    'theme_color' => '#FF5733',
    'backgroundColor' => '#ffffff',
    'background_color' => '#FF5733',
    'icons' => [
        [
            'src' => 'logo.png',
            'sizes' => '512x512',
            'type' => 'image/png',
        ]
    ],
];

PwaKit::createOrUpdate($manifest, true); // true = force overwrite
bash
php artisan vendor:publish --provider="Devrabiul\PwaKit\PwaKitServiceProvider"
blade
{{-- Before closing </body> tag --}}
{!! PwaKit::scripts() !!}
bash
php artisan pwa:update-manifest