faimmedia / static-builder

该包最新版本(v0.1.7)没有可用的许可证信息。

PHP 静态构建生成器

v0.1.7 2024-03-09 12:22 UTC

This package is auto-updated.

Last update: 2024-09-09 13:22:12 UTC


README

此存储库将为您的 PHP 项目启动一个内部 Web 服务器,收集页面并将文件复制到您选择的目录。

安装

使用 composer 安装此库

composer require faimmedia/static-builder 

示例

<?php

use FaimMedia\StaticBuilder\Build;
use FaimMedia\StaticBuilder\Action\{
	CombineUrl,
	Copy,
	Url,
};

$builder = new Build([
	'target' => './dist',
	'router' => './public/router.php',
	'log'    => './cache/server.log',
]);

$builder->addAction(
	new CombineUrl(
		[
			'hostname' => 'faimmedia.nl',
			'encoding' => ['gzip', 'br'],
			'path'     => 'en',
		],
		new Url([
			'url' => 'faq',
		]),
		new Url([
			'url'    => 'not-found',
			'expect' => 404,
		]),
	),
	new Url([
		'url'  => 'file/generator',
		'save' => false,
	]),
	new Copy([
		'source' => './images',
		'path'   => 'static',
	]),
);

$builder->execute();