定制 zmrq/php-pwa 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

zmrq/php-pwa

最新稳定版本:1.0.0

Composer 安装命令:

composer require zmrq/php-pwa

包简介

A PHP library for Progressive Web Apps (PWAs)

README 文档

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.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-05