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
✨ 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:
📦 Installation
Install via Composer:
composer require zmrq/php-pwa
⚙️ Usage
-
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('/'); ?>
-
Add the following script to your HTML
<head>:<?= Pwa::renderMetaTags()
-
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:
🤝 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
其他信息
- 授权协议: MIT
- 更新时间: 2025-08-05
