Publish Laravel PWA configuration
masterAfter installation, publish the package's assets and configuration files using the Artisan command.
php artisan vendor:publish --provider="LaravelPWA\Providers\LaravelPWAServiceProvider"repository·master·Indexed 22 days ago
https://github.com/silviolleite/laravel-pwaA Laravel package that transforms standard web applications into Progressive Web Apps (PWA). It provides features for home screen installation, offline support, and custom splash screens via the @laravelPWA Blade directive and a configurable manifest.
After installation, publish the package's assets and configuration files using the Artisan command.
php artisan vendor:publish --provider="LaravelPWA\Providers\LaravelPWAServiceProvider"When a user is offline and attempts to access a page not in the cache, the default offline view is shown. You can customize this view by editing the Blade template located at resources/views/vendor/laravelpwa/offline.blade.php.
@extends('layouts.app')
@section('content')
<h1>You are currently not connected to any networks.</h1>
@endsectionTo add Progressive Web App capabilities to your Laravel project, install the package via Composer.
composer require silviolleite/laravelpwa --prefer-distTo enable the PWA features (meta tags, manifest link, and service worker registration), include the @laravelPWA Blade directive within the <head> section of your main layout file.
<html
<head>
<title>My Title</title>
...
@laravelPWA
</head>
<body>
...
</body>
</html>filesToCache list), you must update the file located at public/serviceworker.js.Customize your application's name, description, icons, splash screens, and shortcuts in config/laravelpwa.php.
Key configuration areas include:
manifest: Defines core PWA properties like name, short_name, start_url, theme_color, and icons.splash: Defines splash screen images for various device resolutions.shortcuts: Defines quick-access links for the user.custom: Allows you to insert personalized tags directly into the manifest.json.For icons, you can specify the size as the array key or use the sizes property within the array.
'manifest' => [
'name' => env('APP_NAME', 'My PWA App'),
'short_name' => 'PWA',
'start_url' => '/',
'background_color' => '#ffffff',
'theme_color' => '#000000',
'display' => 'standalone',
'orientation' => 'any',
'status_bar' => 'black',
'icons' => [
'72x72' => [
'path' => '/images/icons/icon-72x72.png',
'purpose' => 'any'
],
// ... other icon sizes
],
'splash' => [
'640x1136' => '/images/icons/splash-640x1136.png',
// ... other splash sizes
],
'shortcuts' => [
[
'name' => 'Shortcut Link 1',
'description' => 'Shortcut Link 1 Description',
'url' => '/shortcutlink1',
'icons' => [
"src" => "/images/icons/icon-72x72.png",
"purpose" => "any"
]
]
],
'custom' => [
'tag_name' => 'tag_value',
]
]If your PWA is not working as expected during local development:
/manifest.json is being served correctly./serviceworker.js is being served correctly.