Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vincent15000's avatar

Transform a Laravel web app in a progressive web app with a manifest file

Hello,

I've been told that it was possible to transform a simple web application in a progressive web app by just adding a manifest.json file.

In my case, it would be interesting to generate the manifest.json file from a service inside the Laravel app and load this manifest file dynamically.

Has somebody already done something like that ?

Thanks for your suggestions.

Vincent

0 likes
1 reply
LaryAI's avatar
Level 58

Yes, it is possible to transform a Laravel web app into a progressive web app by adding a manifest.json file. Here's how you can generate the manifest.json file dynamically from a Laravel service:

  1. Create a new Laravel service that generates the manifest.json file. Here's an example:
<?php

namespace App\Services;

class ManifestService
{
    public function generate()
    {
        $manifest = [
            'name' => 'My App',
            'short_name' => 'My App',
            'start_url' => '/',
            'display' => 'standalone',
            'background_color' => '#ffffff',
            'theme_color' => '#ffffff',
            'icons' => [
                [
                    'src' => '/images/icon-192x192.png',
                    'sizes' => '192x192',
                    'type' => 'image/png',
                ],
                [
                    'src' => '/images/icon-512x512.png',
                    'sizes' => '512x512',
                    'type' => 'image/png',
                ],
            ],
        ];

        return json_encode($manifest);
    }
}

This service generates a basic manifest.json file with the app name, start URL, display mode, background color, theme color, and icons.

  1. Create a new route in your Laravel app that returns the generated manifest.json file. Here's an example:
Route::get('/manifest.json', function () {
    $manifestService = app(\App\Services\ManifestService::class);
    $manifest = $manifestService->generate();

    return response($manifest, 200)
        ->header('Content-Type', 'application/json');
});

This route uses the ManifestService to generate the manifest.json file and returns it as a JSON response with the correct Content-Type header.

  1. Add a link to the manifest.json file in your app's HTML head section. Here's an example:
<link rel="manifest" href="/manifest.json">

This link tells the browser where to find the manifest.json file.

That's it! Your Laravel web app is now a progressive web app with a dynamic manifest.json file.

2 likes

Please or to participate in this conversation.