jontynewman / oku-proc

从执行命令生成缓存输出的功能。

v1.1 2018-11-08 07:09 UTC

This package is not auto-updated.

Last update: 2024-09-29 10:12:46 UTC


README

从执行命令生成缓存输出的功能。

本包主要用于与来自 jontynewman\oku-io 包的 \JontyNewman\Oku\IO\Cache 实例一起使用。

安装

composer require 'jontynewman/oku-proc ^1.0'

示例

以下示例假设 rst2html5 可用,并且已安装 jontynewman\oku-io

<?php

use GuzzleHttp\Psr7\Response;
use JontyNewman\Oku\IO\Cache;
use JontyNewman\Oku\IO\Repository;
use JontyNewman\Oku\Process;
use JontyNewman\Oku\RequestHandler;

require 'vendor/autoload.php';

$dir = '/path/to/io/directory';

// Convert reStructuredText input files to HTML output files.
$process = new Process('rst2html5');

// Cache HTML output in the specified directory.
$cache = new Cache($process, $dir, 'html');

// Persist reStructuredText input in the specified directory (for future edits).
$repository = new Repository($cache, $dir, 'rst');

// Use a simple 404 page as the default response.
$default = new Response(404, ['Content-Type' => 'text/plain'], 'Not Found');

// Set up the request handler.
$handler = new RequestHandler($repository, $default);

// Run the application.
$handler->run();

有关使用编辑器的完整示例,请参阅 jontynewman\oku-io