danack / jig
此包已被废弃且不再维护。没有建议的替代包。
轻量级、快速、灵活的PHP模板系统,使用真正的依赖注入。
0.21.2
2016-02-07 13:16 UTC
Requires
- nikic/php-parser: ^0.9.3
- zendframework/zend-escaper: ^2.5.0
Requires (Dev)
- mockery/mockery: 0.9.1
- nikic/fast-route: ~0.2.0
- phpunit/phpunit: 3.7.*
- rdlowrey/auryn: v1.0.0-alpha
- squizlabs/php_codesniffer: ^2.0.0
- dev-master
- 0.21.2
- 0.21.1
- 0.21.0
- 0.20.6
- 0.20.5
- 0.20.4
- 0.20.3
- 0.20.2
- 0.20.1
- 0.20.0
- 0.19.0
- 0.18.1
- 0.18.0
- 0.17.2
- 0.17.1
- 0.17.0
- 0.16.4
- 0.16.3
- 0.16.2
- 0.16.1
- 0.16.0
- 0.15.1
- 0.15.0
- 0.14.5
- 0.14.4
- 0.14.3
- 0.14.2
- 0.14.1
- 0.14.0
- 0.13.0
- 0.12.0
- 0.11.0
- 0.10.2
- 0.10.1
- 0.10.0
- 0.9.2
- 0.9.1
- 0.9.0
- 0.2.1
- 0.2.0
- 0.1.8
- 0.1.7
- 0.1.6
- 0.1.5
- 0.1.4
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1.0
- dev-blockRenderExtraLine
This package is auto-updated.
Last update: 2022-09-11 23:09:23 UTC
README
Jig - "一种用来夹持工件并引导在它上操作的机器的工具."
换句话说,夹具可以让您使用锋利的工具快速工作而不用担心割伤手指。
构建状态 |
---|
|
什么
Jig是一个模板渲染器,将视图层提升为您的应用中的第一等公民。
通过使用它,所有模板都是可单元测试的,因为它不像大多数其他模板系统那样使用'服务定位器'模式。
-
编译为PHP类以获得超级性能。
-
在模板中使用真正的依赖注入,以便对视图进行单元测试。
-
超级轻量级。与APC/OPCache一起使用时,在模板已编译的情况下无开销。
-
简单但功能强大的插件系统。
文档
请运行此命令以查看文档
git clone https://github.com/danack/TierJigDocs
cd TierJigDocs/
composer install
mkdir -p var/cache
php -S localhost:8000 -t public
"我知道我在做什么,只给我看看代码"使用Jig指南
use Auryn\Injector;
use Jig\JigConfig;
use Jig\Jig;
// Create a JigConfig object
$jigConfig = new JigConfig(
//The directory the source templates are in
__DIR__."/../templates/",
//The directory the generated PHP code will be written to.
__DIR__."/../var/generatedTemplates/",
// How to check if the templates need compiling.
Jig::COMPILE_CHECK_MTIME,
// The extension our templates will have.
"php.tpl"
);
// Create a Jig renderer with our config
$jig = new Jig($jigConfig);
// Check the template is compiled to PHP and get the classname of the
// generated PHP template.
$className = $jig->compile("gettingStarted/basic");
// Create a DIC that can create an instance of the template
$injector = new Injector();
$injector->alias('Jig\Escaper', 'Jig\Bridge\ZendEscaperBridge');
// Create an instance of the template
$templateInstance = $injector->make($className);
// Render the template and send it to the user.
$output = $templateInstance->render();
// Send the output to the user
echo $output;
// Alternatively if your DIC supports direct execution
//$output = $injector->execute([$className, 'render']);