tapestry-cloud / code-example-plugin
Tapestry 的代码示例插件
1.0.0
2017-05-17 20:55 UTC
This package is auto-updated.
Last update: 2024-09-07 16:13:52 UTC
README
安装
要安装,请运行: composer require tapestry-cloud/code-example-plugin
接下来,您需要更新您的站点配置以包含代码示例文件夹的路径
// ... 'plugins' => [ 'code_example_path' => __DIR__ . '/code_examples/' ], // ...
最后,在您的 site Kernel.php 中,您需要注册插件的服务提供者
<?php use Tapestry\Modules\Kernel\KernelInterface; class Kernel implements KernelInterface { /** * @var Tapestry */ private $tapestry; public function __construct(Tapestry $tapestry) { $this->tapestry = $tapestry; } /** * This method is executed by Tapestry when the Kernel is registered. * * @return void */ public function register() { // Use project autoloader require_once(__DIR__ . '/vendor/autoload.php'); } /** * This method of executed by Tapestry as part of the build process. * * @return void */ public function boot() { $this->tapestry->register(\TapestryCloud\CodeExample\ServiceProvider::class); } }
使用方法
此插件添加了 $this->codeExample('example.php')
辅助函数,它将以编码后的 html 实体输出您的代码示例。