ladumor/laravel-pwa

this package used for the make pwa website.

v0.0.4 2023-09-02 13:09 UTC

This package is auto-updated.

Last update: 2024-03-27 09:36:23 UTC


README

Latest Stable Version Daily Downloads Monthly Downloads Total Downloads License PHP Version Require

Laravel PWA

You can follow this video tutorial as well for installation.

68747470733a2f2f696d672e796f75747562652e636f6d2f76692f39482d5438314b5150796f2f302e6a7067

Watch Other Lavavel tutorial here

68747470733a2f2f696d672e796f75747562652e636f6d2f76692f794d7473674273714451732f302e6a7067)

Installation

Install the package by the following command, (try without --dev if you want to install it on production environment)

composer require --dev ladumor/laravel-pwa

Add Provider

Add the provider to your config/app.php into provider section if using lower version of laravel,

Ladumor\LaravelPwa\PWAServiceProvider::class,

Add Facade

Add the Facade to your config/app.php into aliases section,

'LaravelPwa' => \Ladumor\LaravelPwa\LaravelPwa::class,

Publish the Assets

Run the following command to publish config file,

php artisan laravel-pwa:publish

Configure PWA

Add following code in root blade file in header section.

<!-- PWA  -->
<meta name="theme-color" content="#6777ef"/>
<link rel="apple-touch-icon" href="{{ asset('logo.PNG') }}">
<link rel="manifest" href="{{ asset('/manifest.json') }}">

Add following code in root blade file in before close the body.

<script src="{{ asset('/sw.js') }}"></script>
<script>
   if ("serviceWorker" in navigator) {
      // Register a service worker hosted at the root of the
      // site using the default scope.
      navigator.serviceWorker.register("/sw.js").then(
      (registration) => {
         console.log("Service worker registration succeeded:", registration);
      },
      (error) => {
         console.error(`Service worker registration failed: ${error}`);
      },
    );
  } else {
     console.error("Service workers are not supported.");
  }
</script>

License

The MIT License (MIT). Please see License File for more information

Buy Me A Coffee

Note

PWA only works with https. so, you need to run either with php artisan serve or create a virtual host with https. you can watch the video for how to create a virtual host with HTTPS

68747470733a2f2f696d672e796f75747562652e636f6d2f76692f44354971446348795853512f302e6a7067