PHPackages                             sgtaziz/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. [Templating &amp; Views](/categories/templating)
4. /
5. sgtaziz/blazar

ActiveLibrary[Templating &amp; Views](/categories/templating)

sgtaziz/blazar
==============

pre-render pages on the fly

v1.0.8(8y ago)012MITPHPPHP ~7.0

Since Aug 27Pushed 8y ago1 watchersCompare

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

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

Blazar
======

[](#blazar)

[![Latest Stable Version](https://camo.githubusercontent.com/4fd73ee79e03568c2554d87a1d0991174b37fc0de6466b835de8b028d519b5f1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f637466302f626c617a61722e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/ctf0/blazar) [![Total Downloads](https://camo.githubusercontent.com/3d0b7029258252fcd235d1c868b670145fd6e7f4c43f8a5362579c4f9284111e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f637466302f626c617a61722e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/ctf0/blazar)

Automate pre-rendering pages on the fly through utilizing [PhantomJs](phantomjs.org) which runs in the background when needed without adding any overhead to the server nor to the user experience.

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

[](#installation)

- install [PhantomJs](http://phantomjs.org/download.html)
- `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 [
    /*
     * phantomjs bin path
     */
    'phantom_path' => '',

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

    /*
     * phantomjs options
     */
    'options' => '--ignore-ssl-errors=true --ssl-protocol=any --disk-cache=false --debug=true 2>&1',

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

    /*
     * log the url when its processed by phantomjs
     */
    '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 `PhantomJs` took long to render the page or when something goes wrong.
    > - after `PhantomJs` 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 `PhantomJs`, 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)

#### \# Why PhantomJs

[](#-why-phantomjs)

I've tried both [usus](https://github.com/gajus/usus) &amp; [puppeteer](https://github.com/GoogleChrome/puppeteer),

And my only take that both needs to run an instance of **Chrome**, while i wanted to keep the whole thing as hidden and as low-leveled as possible.

however if anyone knows how to get any to work as "PhantomJs", am all ears 👂 .

#### \# 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 phantomjs is the same as the current logged in user.

so trying to pre-render pages with **`auth` middleware** will be cashed 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

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 84% 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 ~17 days

Recently: every ~32 days

Total

9

Last Release

3088d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fde534d6e24e337d9797ca6ea5845ae19db8696df90a30560a1f90e20375eb45?d=identicon)[sgtaziz](/maintainers/sgtaziz)

---

Top Contributors

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

---

Tags

laravelprerenderphantomjsctf0Blazarpre-render

### Embed Badge

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

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

###  Alternatives

[moonshine/moonshine

Laravel administration panel

1.3k239.9k76](/packages/moonshine-moonshine)[robsontenorio/mary

Gorgeous UI components for Livewire powered by daisyUI and Tailwind

1.5k531.0k21](/packages/robsontenorio-mary)[hasinhayder/tyro-dashboard

Tyro Dashboard - Beautiful admin dashboard for managing Tyro roles, privileges, users, and settings

5452.7k](/packages/hasinhayder-tyro-dashboard)[ublabs/blade-simple-icons

A package to easily make use of Simple Icons in your Laravel Blade views.

1958.8k](/packages/ublabs-blade-simple-icons)[technikermathe/blade-lucide-icons

A package to easily make use of Lucide icons in your Laravel Blade views.

18379.7k9](/packages/technikermathe-blade-lucide-icons)

PHPackages © 2026

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