1. Go to this page and download the library: Download slfomin/pwa-laravel library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
namespace App\Pwa;
use Illuminate\Http\Request;
use SlFomin\PwaLaravel\Contracts\ManifestResolver;
use SlFomin\PwaLaravel\Manifest\ManifestBuilder;
final class TenantManifestResolver implements ManifestResolver
{
public function resolve(Request $request, ManifestBuilder $default): ManifestBuilder
{
$tenant = $request->user()?->tenant;
return $tenant
? $default->name($tenant->name)->themeColor($tenant->brand_color)
: $default;
}
public function cacheKey(Request $request): ?string
{
return 'tenant.'.($request->user()?->tenant_id ?? 'guest');
}
}
use SlFomin\PwaLaravel\Attributes\PwaShortcut;
use SlFomin\PwaLaravel\Core\Shortcuts\ShortcutIcon;
class AuthController
{
#[PwaShortcut(name: 'Login', icon: '/icons/login.png')]
public function showLogin() {}
#[PwaShortcut(
name: 'Register',
icons: [
new ShortcutIcon('/icons/register-96.png', '96x96'),
new ShortcutIcon('/icons/register-192.png', '192x192'),
],
)]
public function showRegister() {}
}
use SlFomin\PwaLaravel\Facades\Pwa;
Pwa::manifest(); // ManifestBuilder for the current request
Pwa::manifestUrl(); // string — URL of the manifest
Pwa::serviceWorkerUrl(); // string — URL of the service worker
Pwa::worker(); // WorkerManager instance
Pwa::driver(); // ManifestDriver instance
use SlFomin\PwaLaravel\Events\PwaEvents;
use SlFomin\PwaLaravel\Events\ManifestResolved;
PwaEvents::manifestResolved(function (ManifestResolved $event): void {
// last-chance mutation before the JSON is serialized
$event->manifest->name('My App — '.app()->getLocale());
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.