Laravel service provider Laravel Service Provider for static site

Laravel Service Providing Static Site Deployment to  Firebase Hosting

Laravel is a robust PHP framework, best known for powering dynamic, database-driven web applications. Businesses often use it to build everything from a Laravel application for enterprise solutions to a fully customized Laravel e-commerce platform. Many companies also rely on expert Laravel service providers to create scalable and secure solutions tailored to their needs. However, not every project requires backend processing or real-time data fetching. For certain projects—like landing pages, company profiles, portfolios, documentation sites, or event microsites—a static site deployment can be a smarter choice.

At Sreyas IT Solutions, a trusted Laravel service provider, we have extensive experience in both Laravel website development—covering API integrations, advanced authentication, performance optimization—and Firebase solutions such as real-time databases, serverless cloud functions, authentication, hosting, and push notifications. This combined expertise enables us to design and deploy Laravel applications of any scale, as well as leverage Firebase’s global CDN and serverless architecture for lightning-fast, secure, and cost-efficient hosting.

By converting Laravel Blade views into static HTML, you can achieve:

  • Faster loading speeds through pre-rendered HTML
  • Simplified infrastructure with no backend server to maintain
  • Lower hosting costs thanks to lightweight static files
  • Better scalability through Firebase’s global hosting network

This guide will walk you through how to export Laravel Blade views as static HTML and deploy them to Firebase Hosting.

Prerequisites for Deploying a Laravel Website to Firebase

ToolDescription
LaravelVersion 9 or later    
PHPInstalled locally  
Node.js & NPM Required for Firebase CLI          
Firebase ProjectCreated at [firebase.google.com](https://firebase.google.com)
Firebase CLIInstall using `npm install -g firebase-tools`

Step-by-Step Instructions for Laravel Static Site Deployment

Step 1: Install Firebase CLI

Install globally and authenticate:

npm install -g firebase-tools
firebase login

Step 2: Create a Blade View

Create `resources/views/home.blade.php`:

<!DOCTYPE html>
<html>
<head>
    <title>My Static Page</title>
    <link rel="stylesheet" href="{{ $asset('css/style.css') }}">
</head>
<body>
    <h1>Welcome to Our Company</h1>
    <img src="{{ $asset('images/logo.png') }}" alt="Logo">
    <script src="{{ $asset('js/app.js') }}"></script>
</body>
</html>

 ⚠️ Do not use `{{ asset() }}` — it generates absolute paths which may break in static hosting.

Step 3: Create Laravel Export Command

Generate the command:

php artisan make:command ExportCheckAppStaticViews

Then replace `app/Console/Commands/ExportCheckAppStaticViews.php` with:

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\View;
use Illuminate\Support\Facades\File;

class ExportCheckAppStaticViews extends Command
{
    protected $signature = 'app:export-check-app-static-views';
    protected $description = 'Export Blade views as static HTML with relative asset paths for Firebase Hosting';

    public function handle()
    {
        $this->info(" Starting static export...");

        $pages = ['home' => 'index.html'];
        $outputPath = public_path('../firebase-dist');

        if (!File::exists($outputPath)) {
            File::makeDirectory($outputPath, 0755, true);
        }
        View::share('asset', fn($path) => ltrim($path, '/'));

        foreach ($pages as $view => $fileName) {
            $html = View::make($view)->render();
            File::put($outputPath . '/' . $fileName, $html);
            $this->info(" Exported view '{$view}' to '{$fileName}'");
        }
        $assets = ['css', 'js', 'images'];
        foreach ($assets as $folder) {
            $source = public_path($folder);
            $destination = $outputPath . '/' . $folder;

            if (File::exists($source)) {
                File::copyDirectory($source, $destination);
                $this->info(" Copied assets from '{$folder}'");
            } else {
                $this->warn("⚠️ Asset folder '{$folder}' not found.");
            }
        }
        $this->info(" All views and assets exported to 'firebase-dist' successfully.");
    }
}

Step 4: Export Static Files

Run the command:

php artisan app:export-check-app-static-views

This will create a new folder `firebase-dist/` with contents like:

firebase-dist/

  • index.html
  • css/
  • js/
  • images/

Step 5: Initialize Firebase Hosting

From your project root:

firebase init

Select:

  • Hosting
  • Public directory:`firebase-dist`
  • Configure as SPA? No
  • Overwrite index.html? No

Step 6: Deploy to Firebase Hosting

firebase deploy

Firebase CLI will give you a live URL such as:  https://your-project-id.web.app

Optional Enhancements for Laravel Services

FeatureDescription
Add More Views Add more items to `$pages` array in the command class  
Pretty URLs Use rewrite rules in `firebase.json`
Minify HTML   Use a PHP HTML minifier like `voku/html-min` before writing output files 
SEO & MetadataAdd meta tags, OpenGraph, and structured data in your Blade templates

Conclusion

By following these steps, you’ve transformed your Laravel website into a fully static, production-ready site hosted on Firebase. This approach is:

  • Cost-Effective – No backend infrastructure required
  • High-Performance – Delivered through Firebase’s global CDN for lightning-fast page loads
  • Low Maintenance – Minimal moving parts, fewer security concerns, and easy updates
  • SEO-Friendly – Static files with optimized HTML are easily indexed by search engines

At Sreyas IT Solutions, our proven ability to combine the power of a Laravel application with the efficiency of Firebase’s serverless ecosystem allows us to deliver solutions that are fast, scalable, and reliable. Whether it’s building a Laravel e-commerce platform, a custom business tool, or a high-performance Laravel website, we ensure all kind of Laravel services and technical excellence for clients worldwide.

Recent Blogs


Posted

in

by

Tags:

To Know Us Better

Browse through our work.

Explore The Technology Used

Learn about the cutting-edge technology and techniques we use to create innovative software solutions.