antlur/laravel-static-export 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

antlur/laravel-static-export

最新稳定版本:v0.1.2

Composer 安装命令:

composer require antlur/laravel-static-export

包简介

Export your laravel site as static files

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Host your Laravel site on Netlify, Vercel, or any other static site host. This package will generate static files from your Laravel site with very little setup. A convenient attribute is provided to provide routes with dynamic parameters.

Installation

You can install the package via composer:

composer require antlur/laravel-static-export

You can publish the config file with:

php artisan vendor:publish --tag="static-export-config"

This is the contents of the published config file:

return [
    'output_path' => base_path('dist'),

    'clear_before_export' => true,
];

Usage

php artisan export

Dynamic Data during static site generation

When generating the static site, you can use the ExportPaths attribute to define which routes should be generated. This is useful when you have dynamic data that you want to generate static pages for. For example, if you have a blog and you want to generate static pages for each blog post, you can use the ExportPaths attribute to define which routes should be generated. The rest of your logic can be handled as if it was a normal Laravel application.

// web.php
Route::get('/blog/{slug}', [BlogController::class, 'show']);

// app/Http/Controllers/BlogController.php
use Antlur\Export\Attributes\ExportPaths;

class BlogController
{
    // You can pass a class that implements PathProvider
    #[ExportPaths(BlogPostPaths::class)]
    public function show(string $name)
    {}

    // Or you can pass an array of paths directly
    #[ExportPaths(['/blog/first-post', '/blog/second-post'])]
    public function show(string $name)
    {}
}

// app/PathProviders/BlogPostPaths.php
class BlogPostPaths implements \Antlur\Export\Contracts\PathProvider
{
    public function paths(): array
    {
        return [
            '/blog/first-post',
            '/blog/second-post',
        ];
    }
}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-02-22