承接 aculix99/laravel-quick-static 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

aculix99/laravel-quick-static

最新稳定版本:1.0.5

Composer 安装命令:

composer require aculix99/laravel-quick-static

包简介

Serve static html, json and xml files without booting laravel for best performance

README 文档

README


Latest Version on Packagist Total Downloads

Introduction

This package allows you to serve static html, json and xml files without booting laravel for best performance! It's inspired by page-cache.

Installation

Install with Composer

composer require aculix99/laravel-quick-static

.gitingore

  • Add the cache folder name (default = _quick-static) to your .gitingore to avoid cached files in your vcs

URL Rewriting

Snippet

Add these lines to the public/index.php of your laravel application right after the use statements:

define('QUICK_STATIC_ROOT', __DIR__);
require __DIR__ . '/../vendor/aculix99/laravel-quick-static/loader.php';

Full file as reference

Your full index.php will then look like this:

<?php

use Illuminate\Foundation\Application;
use Illuminate\Http\Request;

define('QUICK_STATIC_ROOT', __DIR__);
require __DIR__ . '/../vendor/aculix99/laravel-quick-static/loader.php';

define('LARAVEL_START', microtime(true));

// Determine if the application is in maintenance mode...
if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) {
    require $maintenance;
}

// Register the Composer autoloader...
require __DIR__.'/../vendor/autoload.php';

// Bootstrap Laravel and handle the request...
/** @var Application $app */
$app = require_once __DIR__.'/../bootstrap/app.php';

$app->handleRequest(Request::capture());

Configuration

Publish config file

php artisan vendor:publish --tag=quick-static

Cache config file

  • The config file needs to be cached so that the loader.php can read it without booting laravel.
  • Run the following command to generate bootstrap/cache/quick-static.php
php artisan quick-static:cache-config

Composer

  • Add these two commands to your post-autoload-dump-script
"post-autoload-dump": [
    // "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
    // "@php artisan package:discover --ansi",
    "@php artisan vendor:publish --tag=quick-static",
    "@php artisan quick-static:cache-config"
],

Customizations

Feel free to use and adjust the loader within your index.php the way you like it. Since it's PHP rewriting, you can do your very own, performant PHP MAGIC. Also you can ignore cached files if query parameters are present.

Usage

Using the middleware

Just add the middleware to the corresponding routes like this:

...
Route::middleware(\Aculix99\LaravelQuickStatic\Middleware\StoreStatic::class)->group(function() {
    Route::get('/path', fn() => view('test'));
    Route::get('/json', fn() => response()->json('test'));
});
...

Clearing the cache

php artisan quick-static:clear

Optimization

  • The quick-static compiled config cache file will be automatically created and deleted when php artisan optimize and php artisan optimize:clear gets utilized.
  • Furthermore the config file will be cached when the composer script post-autoload-dump runs, so after every
    • composer dump-autoload
    • composer install
    • composer update
  • Also you can manually create and delete the compiled config file:
    • php artisan quick-static:cache-config
    • php artisan quick-static:clear-cached-config

License

This package is open-sourced software licensed under the MIT license.

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固