kseven/laravel-pwa
Composer 安装命令:
composer require kseven/laravel-pwa
包简介
A simple and easy-to-use PWA (Progressive Web App) package for Laravel applications.
关键字:
README 文档
README
Laravel PWA is a package designed to seamlessly integrate Progressive Web Application (PWA) functionality into your Laravel projects. With this package, you can easily configure, update the manifest, and register service workers, enabling any Laravel app to function as a PWA.
Features 🚀
- Automatically generate PWA manifest and service worker
- Configurable installation button
- Supports Laravel 8, 9, 10, and 11
- Easy setup and usage
- Compatible with mobile and desktop devices
Important ⚠️
Note: PWAs require a secure HTTPS connection to work correctly. Ensure your application is hosted with HTTPS; otherwise, service workers and other PWA features will not function as expected.
Installation 📦
To get started, install the package using Composer:
composer require kseven/laravel-pwa
Once installed, publish the PWA configuration files using:
php artisan ks:publish-laravel-pwa
This will create the required configuration file config/pwa.php and set up PWA functionality for your application.
Configuration ⚙️
Main Configuration File: config/pwa.php
This is your main configuration file where you can customize the PWA settings.
return [ 'debug' => env('APP_DEBUG', false), 'vapid_public' => env('VAPID_PUBLIC_KEY', null), 'install-button' => true, // Show or hide install button globally 'manifest' => [ 'name' => 'KSeven PWA', 'short_name' => 'KSPWA', 'description' => 'A Progressive Web Application setup for Laravel projects.', "version" => "0.0.0", 'background_color' => '#000', 'theme_color' => '#F12', "start_url" => "/?source=pwa", "scope" => "/", "display" => "standalone", "display_override" => ["standalone", "fullscreen"], "orientation" => "portrait-primary", "lang" => "pt-BR", "dir" => "ltr", "icons" => [ [ "src" => "/assets/images/96x96.png", "sizes" => "96x96", "type" => "image/png" ], [ "src" => "/assets/images/192x192.png", "sizes" => "192x192", "type" => "image/png" ], [ "src" => "/assets/images/512x512.png", "sizes" => "512x512", "type" => "image/png" ] ], "screenshots" => [ [ "src" => "/assets/images/screanshot1.jpg", "sizes" => "576x1280", "type" => "image/jpeg" ], [ "src" => "/assets/images/screanshot2.jpg", "sizes" => "576x1280", "type" => "image/jpeg" ], [ "src" => "/assets/images/screenshot-wide.jpg", "sizes" => "1365x605", "type" => "image/jpeg", "form_factor" => "wide" ] ], "categories" => ["general"], "shortcuts" => [ [ "name" => "KSeven", "short_name" => "KSeven", "description" => "Seu desenvolvedor...", "url" => "/", "icons" => [ [ "src" => "/assets/images/96x96.png", "sizes" => "96x96", "type" => "image/png" ] ] ] ], "related_applications" => [ [ "platform" => "webapp", "url" => "https://kseven.com.br/" ], [ "platform" => "play", "id" => "com.kseven.app" ] ], "prefer_related_applications" => false, "iarc_rating_id" => "e10+" ], ];
Customizing Manifest File
After changing config/pwa.php in your manifest array, run this command
You can update your PWA manifest file by running:
php artisan ks:pwa-update-manifest
This command updates the manifest.json file located in the public directory of your Laravel project.
Usage 🛠️
To integrate PWA functionality into your layouts, use the provided Blade directives.
1. Add Meta Tags
Place the @PwaHead directive inside the <head> tag of your main layout file:
<!DOCTYPE html> <html lang="en"> <head> @PwaHead <!-- Add this directive to include the PWA meta tags --> <title>Your App Title</title> </head> <body>
2. Register Service Worker
Just before the closing </body> tag in your main layout file, add:
@RegisterServiceWorkerScript <!-- This registers the service worker --> </body> </html>
These directives will automatically generate the necessary tags and JavaScript for the PWA.
Screenshots 📸
Installing PWA App
Offline Page
Contribution 🧑💻
We appreciate your interest in contributing to this Laravel PWA project! Whether you're reporting issues, fixing bugs, or adding new features, your help is greatly appreciated.
Forking and Cloning the Repository
-
Go to the repository page on GitHub.
-
Click the Fork button at the top-right corner of the repository page.
-
Clone your forked repository:
git clone https://github.com/your-username/laravel-pwa.git
Reporting Issues
If you encounter any issues, please check if the issue already exists in the Issues section. If not, create a new issue with the following details:
- Steps to reproduce the issue
- Expected and actual behavior
- Laravel version
- Any relevant logs or screenshots
Submit a Pull Request
When you're ready to contribute, open a pull request describing the changes you’ve made and how they improve the project. Please ensure:
- All commits are squashed into one clean commit.
- The code follows PSR-12 standards.
- You’ve tested the changes locally.
Coding Standards
- Follow the PSR-12 PHP coding standards.
- Keep your commit history clean and meaningful.
- Add comments where needed but avoid over-commenting.
Example Workflow 🌟
Here’s a simple example of how to use this package:
- Install the package via Composer.
- Publish the configuration files.
- Add the
@PwaHeaddirective in your layout file’s<head>. - Add the
@RegisterServiceWorkerScriptdirective before the closing</body>tag. - Customize the
config/pwa.phpto fit your project’s needs. - Run
php artisan ks:pwa-update-manifestto update the manifest file. - That's it! Your Laravel app is now PWA-enabled. 🚀
kseven/laravel-pwa 适用场景与选型建议
kseven/laravel-pwa 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 33 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 11 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「manifest」 「offline」 「laravel package」 「pwa」 「service worker」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 kseven/laravel-pwa 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kseven/laravel-pwa 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 kseven/laravel-pwa 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Plugin Manifest is the conduit between Craft CMS plugins and webpack, with manifest.json & webpack-dev-server HMR support
Rich payment solutions for Laravel framework. Paypal, payex, authorize.net, be2bill, omnipay, recurring paymens, instant notifications and many more
Injects assets from a Vite manifest to the Wordpress head, supports themes and plugins
Set Facebook offline conversion
Rich payment solutions for Yii framework. Paypal, payex, authorize.net, be2bill, omnipay, recurring paymens, instant notifications and many more
Package to use WebpackManifestPlugin in laravel
统计信息
- 总下载量: 33
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-11-11