zmrq/php-pwa

A PHP library for Progressive Web Apps (PWAs)

Maintainers

Package info

github.com/zaiimrq/php-pwa

Type:package

pkg:composer/zmrq/php-pwa

Statistics

Installs: 9

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

1.0.0 2025-08-05 22:31 UTC

This package is auto-updated.

Last update: 2026-04-06 00:19:16 UTC


README

Effortlessly Enable Seamless, Offline-Ready Web Experiences

Last Commit PHP Languages

✨ Overview

PHP-PWA is a lightweight library that enables your native PHP applications to become Progressive Web Apps (PWAs) without requiring any additional PHP or JavaScript frameworks. With PHP-PWA, your web app can work offline, load faster, and feel like a native applicationβ€”all with simple integration into your existing PHP codebase.

πŸš€ Features

  • ⚑ Instant offline support via Service Worker
  • πŸ”„ Automatic generation of PWA manifest file (manifest.json)
  • 🧩 Easy integration with native PHP applications (no framework required)
  • πŸ“¦ Composer-friendly package structure
  • πŸ›‘οΈ No dependency on any PHP framework

πŸ› οΈ Technology Stack

Built with:

JSON Composer PHP

πŸ“¦ Installation

Install via Composer:

composer require zmrq/php-pwa

βš™οΈ Usage

  1. Enable PWA in your application's root:

    <?php
        use Zmrq\PWA\Pwa;
    
        // The 'dir' parameter is the public root directory for PWA assets, default is 'pwa'.
        Pwa::enable(dir: 'pwa');
    
        // This returns an instance of the manifest class, allowing you to configure the manifest.
        $manifest = Pwa::enable(dir: 'pwa')
                        ->name('PHP PWA')
                        ->shortName('PWA')
                        ->startUrl('/');
    ?>
  2. Add the following script to your HTML <head>:

        <?= Pwa::renderMetaTags()
  3. Add the following script before the closing </body> tag:

        <?= Pwa::renderServiceWorker() ?>

πŸ“ Example Directory Structure

/public
    /pwa
        β”œβ”€β”€ logo.png
        β”œβ”€β”€ offline.html
        β”œβ”€β”€ manifest.json
        └── sw.js
    β”œβ”€β”€ index.php

πŸ–ΌοΈ Offline Page Preview

Below is a preview of the offline page as shown by offline.png:

Offline Page Preview

🀝 Contributing

Contributions are welcome! Please fork this repository and submit a pull request.

πŸ“„ License

Licensed under the MIT License.