PHPackages                             ctf0/blazar - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. ctf0/blazar

AbandonedArchivedLibrary

ctf0/blazar
===========

pre-render pages on the fly

v2.0.1(8y ago)141.7k4MITPHPPHP ~7.0

Since Aug 27Pushed 7y ago1 watchersCompare

[ Source](https://github.com/ctf0/Blazar)[ Packagist](https://packagist.org/packages/ctf0/blazar)[ Docs](https://github.com/ctf0/Blazar)[ RSS](/packages/ctf0-blazar/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (10)Dependencies (3)Versions (11)Used By (0)

> ### This project is abandoned due to impracticality, i would highly recommend to try using ServiceWorkers and here is [a little article](https://ctf0.wordpress.com/2018/07/14/laravel-and-pwa/) to get you started.
>
> [](#this-project-is-abandoned-due-to-impracticality-i-would-highly-recommend-to-try-using-serviceworkers-and-here-is-a-little-article-to-get-you-started)

Blazar
======

[](#blazar)

[![Latest Stable Version](https://camo.githubusercontent.com/1c3ce1092c0d76e62bca6040fcda247824c017b5b669c8dfd8534085ee9c9edc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f637466302f626c617a61722e737667)](https://packagist.org/packages/ctf0/blazar) [![Total Downloads](https://camo.githubusercontent.com/8944a47808c4c7110e3d52445bc94def3db5ce20f2beca8fb1b772754a3819c0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f637466302f626c617a61722e737667)](https://packagist.org/packages/ctf0/blazar)

Automate pre-rendering pages on the fly through utilizing [puppeteer](https://github.com/GoogleChrome/puppeteer) which runs in the background when needed without adding any overhead to the server nor to the user experience.

Installation
------------

[](#installation)

- install [puppeteer](https://github.com/GoogleChrome/puppeteer#installation)
- `composer require ctf0/blazar`
- (Laravel &lt; 5.5) add the service provider to `config/app.php`

```
'providers' => [
    ctf0\Blazar\BlazarServiceProvider::class,
]
```

- publish the package assets

`php artisan vendor:publish --provider="ctf0\Blazar\BlazarServiceProvider"`

- add the middlewares to `app/Http/Kernel.php`

```
protected $middlewareGroups = [
    // ...
    \ctf0\Blazar\Middleware\Blazar::class,
];

protected $routeMiddleware = [
    // ...
    'dont-pre-render' => \ctf0\Blazar\Middleware\DontPreRender::class,
];
```

- the package use caching through **Redis** to store the rendered results, so make sure to check the [docs](https://laravel.com/docs/5.4/redis) for installation &amp; configuration.

Config
------

[](#config)

**config/blazar.php**

```
return [
    /*
     * puppeteer bin path
     */
    'puppeteer_path' => '',

    /*
     * puppeteer script path
     *
     * leave it empty to the use the one from the package
     */
    'script_path' => '',

    /*
     * prerender the page only if the url is being visited from a bot/crawler
     */
    'bots_only' => false,

    /*
     * log the url when its processed by puppeteer
     */
    'debug' => true,

    /**
     *  clear user cache on logout
     */
    'clear_user_cache' => true
];
```

Usage
-----

[](#usage)

- we use [Queues](https://laravel.com/docs/5.4/events#queued-event-listeners) to **pre-render the visited pages** in the background for more than one reason

    > - avoid latency when the page is being accessed for the first time.
    > - don't keep the user waiting in case `puppeteer` took long to render the page or when something goes wrong.
    > - after `puppeteer` has finished rendering, the page is cached to optimize server load even further.
    > - make your website **SEO friendly**, because instead of serving the normal pages that usually produce issues for crawlers, we are now serving the **pre-renderd version**. [ReadMore](#-render-pages-automatically)
    > - even for websites with some traffic, we are still going to process each visited page without any problems.

#### \# Render Pages Automatically

[](#-render-pages-automatically)

Atm in order to ***pre-render*** any page, it have to be visited first but if you want to make sure that all is working from day one, you can use the excellent package [laravel-link-checker](https://packagist.org/packages/spatie/laravel-link-checker) by **Spatie**

- which by simply running `php artisan link-checker:run` you will

    > - check which "url/link" on the website is not working.
    > - **pre-render** all pages at once.

#### \# Flushing The Cache

[](#-flushing-the-cache)

- to clear the whole package cache, you can use

```
php artisan blazar:flush
```

or from within your app

```
Artisan::call('blazar:flush');
```

#### \# Bots Only

[](#-bots-only)

> we now use [CrawlerDetect](https://github.com/JayBizzle/Laravel-Crawler-Detect) instead of relying on '?\_escaped\_fragment\_'

if you decided to pre-render the pages for bots only, no need to the run the queue as the page will remain busy **"stalled response"** until rendered by `puppeteer`, which happens on the fly.

however because we are caching the result, so this will only happen once per page.

also note that we are saving the page cache equal to the url so even if you switched off the `bots_only` option, if the page is cached, we will always serve the cached result.

Notes
-----

[](#notes)

#### \# Queues

[](#-queues)

the worker should only fires when a url is visited &amp; if this url is not cached, however if you have an unfinished old process, the queue will start processing pages on its own, so to fix that, simply restart the queue server `beanstalkd, redis, etc...`

```
# ex. using Homebrew

brew services restart beanstalkd
```

#### \# Auth

[](#-auth)

as i dont know how to make laravel think that a page visited through puppeteer is the same as the current logged in user.

so trying to pre-render pages with **`auth` middleware** will be cached as if the user was redirected to the home page or whatever you've set to **redirectTo** under `Constollers/Auth/LoginController.php` &amp; `Middleware/RedirectIfAuthenticated.php`

so to solve that, simply add **`dont-pre-render` middleware** to those routes and everything will work as expected. also make sure to add the same middleware to any route that needs fresh csrf-token for each user **"login, register, etc.."** to avoid getting `CSRF Token Mismatch` for other users trying to use those pages.

#### \# More Reading

[](#-more-reading)

-
-

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 96.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~18 days

Recently: every ~31 days

Total

10

Last Release

3016d ago

Major Versions

v1.0.7 → v2.0.02018-01-18

### Community

Maintainers

![](https://www.gravatar.com/avatar/51dbfff65441e32301575f8ac241895817975e754d15574b86f543b33f1961f6?d=identicon)[ctf0](/maintainers/ctf0)

---

Top Contributors

[![ctf0](https://avatars.githubusercontent.com/u/7388088?v=4)](https://github.com/ctf0 "ctf0 (26 commits)")[![fridzema](https://avatars.githubusercontent.com/u/8180660?v=4)](https://github.com/fridzema "fridzema (1 commits)")

---

Tags

laravelmiddlewarephantomjsphpprerenderpuppeteerlaravelprerenderphantomjsctf0Blazarpre-render

### Embed Badge

![Health badge](/badges/ctf0-blazar/health.svg)

```
[![Health](https://phpackages.com/badges/ctf0-blazar/health.svg)](https://phpackages.com/packages/ctf0-blazar)
```

###  Alternatives

[nutsweb/laravel-prerender

Laravel middleware for prerendering javascript-rendered pages on the fly for SEO

279165.5k1](/packages/nutsweb-laravel-prerender)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
