定制 sandulat/laratron 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sandulat/laratron

Composer 安装命令:

composer require sandulat/laratron

包简介

Laravel-Rendertron SSR Middleware

README 文档

README

🖼Laravel SSR using Rendertron 🖼

About

Since we know that not all crawlers can render Javascript, we have to implement SSR (Server-Side Rendering). Implementing SSR in Laravel may be a headache and the easiest solution could be Rendertron.

Laratron is a tiny middleware for your Laravel app that detects whether the visitor is a crawler and passes the request to Rendertron.

About Rendertron (from official Readme):

Rendertron is designed to enable your Progressive Web App (PWA) to serve the correct content to any bot that doesn't render or execute JavaScript. Rendertron runs as a standalone HTTP server. Rendertron renders requested pages using Headless Chrome, auto-detecting when your PWA has completed loading and serializes the response back to the original request. To use Rendertron, your application configures middleware to determine whether to proxy a request to Rendertron. Rendertron is compatible with all client side technologies, including web components.

Installation

First of all we need to install Rendertron. Please consult the official documentation for more info. To install Laratron run this inside your project:

composer require sandulat/laratron

Configuration

Laratron exposes only one simple option, the URL of Rendertron, which can be set in your env file:

RENDERTRON_URL=http://localhost:3000

Usage

After installation you can use the middleware laratron on any route that you'd like to be server-side rendered.

Route::get('/', function () {
    return view('home');
})->middleware('laratron');

Or you can apply it on the entire web middleware group in App\Http\Kernel:

'web' => [
    // ...
    \Sandulat\Laratron\Http\Middleware\LaratronMiddleware::class,
],

Credits

Created by Stratulat Alexandru.

统计信息

  • 总下载量: 20
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 27
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 27
  • Watchers: 1
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-07-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固