PHPackages                             codebar-ag/laravel-prerender - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. codebar-ag/laravel-prerender

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

codebar-ag/laravel-prerender
============================

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

v12.4.0(9mo ago)44178.4k—9.2%17MITPHPPHP 8.2.\*|8.3.\*|8.4.\*CI passing

Since Sep 13Pushed 2mo ago4 watchersCompare

[ Source](https://github.com/codebar-ag/laravel-prerender)[ Packagist](https://packagist.org/packages/codebar-ag/laravel-prerender)[ Docs](https://github.com/codebar-ag/Laravel-Prerender)[ RSS](/packages/codebar-ag-laravel-prerender/feed)WikiDiscussions main Synced 1mo ago

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

[![](https://camo.githubusercontent.com/c11302deac92b7b11c699aac31494cb3a0a96a38b94f85a824fb4d64c88bf65e/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4c61726176656c25323050726572656e6465722e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d636f64656261722d61672532466c61726176656c2d70726572656e646572267061747465726e3d63697263756974426f617264267374796c653d7374796c655f32266465736372697074696f6e3d496e746567726174652b50726572656e6465722e696f2b776974682b4c61726176656c266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313735707826696d616765733d74656d706c617465267769647468733d35303026686569676874733d353030)](https://camo.githubusercontent.com/c11302deac92b7b11c699aac31494cb3a0a96a38b94f85a824fb4d64c88bf65e/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4c61726176656c25323050726572656e6465722e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d636f64656261722d61672532466c61726176656c2d70726572656e646572267061747465726e3d63697263756974426f617264267374796c653d7374796c655f32266465736372697074696f6e3d496e746567726174652b50726572656e6465722e696f2b776974682b4c61726176656c266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313735707826696d616765733d74656d706c617465267769647468733d35303026686569676874733d353030)

[![Latest Version on Packagist](https://camo.githubusercontent.com/410359da92b10c26a8515ac525bd33e3a738518f0668e2c28d8f2e6bcbd7000f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636f64656261722d61672f6c61726176656c2d70726572656e6465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/codebar-ag/laravel-prerender)[![Total Downloads](https://camo.githubusercontent.com/f1cf09b59cb8e21c21423dcac30f9c1588e1eff49ce40a9c7dd89456390e26d8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636f64656261722d61672f6c61726176656c2d70726572656e6465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/codebar-ag/laravel-prerender)[![GitHub-Tests](https://github.com/codebar-ag/laravel-prerender/actions/workflows/run-tests.yml/badge.svg?branch=main)](https://github.com/codebar-ag/laravel-prerender/actions/workflows/run-tests.yml)[![GitHub Code Style](https://github.com/codebar-ag/laravel-prerender/actions/workflows/fix-php-code-style-issues.yml/badge.svg?branch=main)](https://github.com/codebar-ag/laravel-prerender/actions/workflows/fix-php-code-style-issues.yml)[![PHPStan](https://github.com/codebar-ag/laravel-prerender/actions/workflows/phpstan.yml/badge.svg)](https://github.com/codebar-ag/laravel-prerender/actions/workflows/phpstan.yml)[![Dependency Review](https://github.com/codebar-ag/laravel-prerender/actions/workflows/dependency-review.yml/badge.svg)](https://github.com/codebar-ag/laravel-prerender/actions/workflows/dependency-review.yml)

This package was developed to give you a quick start to integrate with the Prerender.io service in your Laravel application.

🙇 Credits
---------

[](#-credits)

This package is a clone from [jeroennoten/laravel-prerender](https://github.com/jeroennoten/Laravel-Prerender)with [jeroennoten](https://github.com/jeroennoten) as the original author. [CasperLaiTW](https://github.com/CasperLaiTW) provided Laravel 6,7 &amp; 8 compatibility by an unmerged (14th September 2020) Pull-Request.

💡 What is Prerender.io?
-----------------------

[](#-what-is-prerenderio)

The Prerender.io middleware will check each request to see if it's a from a crawler. If it is a request from a crawler, the middleware will send a request to Prerender.io for the static HTML of that page. If not, the request will continue on to your normal server routes. The crawler never knows that you are using Prerender.io since the response always goes through your server.

> Google now recommends that you use Prerender.io in their [Dynamic Rendering](https://docs.prerender.io/article/9-google-support)documentation!

🛠 Requirements
--------------

[](#-requirements)

PackagePHPLaravelPrerender.io accessv12.0.0^8.2 - ^8.412.x✅v11.0.0^8.2 - ^8.311.x✅v3.3.0^8.1 - ^8.310.x✅v3.2.0^8.0 - ^8.29.x✅v3.1.1^7.3 - ^8.18.x✅⚙️ Installation
---------------

[](#️-installation)

You can install the package via composer:

```
composer require codebar-ag/laravel-prerender
```

If you want to make use of the Prerender.io service, add the following to your `.env` file:

```
PRERENDER_TOKEN=token
```

Or if you are using a self-hosted service, add the server address in the `.env` file.

```
PRERENDER_URL=https://prerender.services
```

That's it. Every GET-Request from a crawler will be prerendered.

✋ Disable the service
---------------------

[](#-disable-the-service)

You can disable the service by adding the following to your `.env` file:

```
PRERENDER_ENABLE=false
```

This may be useful for your local development environment.

✏️ How it works
---------------

[](#️-how-it-works)

1. The middleware checks to make sure we should show a prerendered page
    1. The middleware checks if the request is from a crawler (agent string or `_escaped_fragment_`)
    2. The middleware checks to make sure we aren't requesting a resource (js, css, etc...)
    3. (optional) The middleware checks to make sure the url is in the whitelist
    4. (optional) The middleware checks to make sure the url isn't in the blacklist
2. The middleware makes a `GET` request to the [prerender service](https://github.com/prerender/prerender) (phantomjs server) for the page's prerendered HTML
3. Return the HTML to the crawler

🔧 Configuration file
--------------------

[](#-configuration-file)

You can publish the config file with:

```
php artisan vendor:publish --provider="CodebarAg\LaravelPrerender\LaravelPrerenderServiceProvider"
```

Afterwards you can customize the Whitelist/Blacklist on your own.

This is the contents of the published config file:

```
