From 8827831a48f15dbcf8b6016c0995beaf09911dbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=94=81?= <52o@qq52o.cn> Date: Fri, 11 Dec 2020 16:21:12 +0800 Subject: [PATCH] Added NoneEngine as the default engine of view config (#2958) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Changed default engine of view config * Update CHANGELOG-2.0.md Co-authored-by: 李铭昕 <715557344@qq.com> --- publish/view.php | 5 ++-- src/Engine/NoneEngine.php | 57 +++++++++++++++++++++++++++++++++++++++ src/Render.php | 4 +-- tests/NoneTest.php | 29 ++++++++++++++++++++ 4 files changed, 90 insertions(+), 5 deletions(-) create mode 100644 src/Engine/NoneEngine.php create mode 100644 tests/NoneTest.php diff --git a/publish/view.php b/publish/view.php index 100613e..7fc7bf1 100644 --- a/publish/view.php +++ b/publish/view.php @@ -9,15 +9,14 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ +use Hyperf\View\Engine\NoneEngine; use Hyperf\View\Mode; -use Hyperf\ViewEngine\HyperfViewEngine; return [ - 'engine' => HyperfViewEngine::class, + 'engine' => NoneEngine::class, 'mode' => Mode::SYNC, 'config' => [ 'view_path' => BASE_PATH . '/storage/view/', 'cache_path' => BASE_PATH . '/runtime/view/', - 'charset' => 'UTF-8', ], ]; diff --git a/src/Engine/NoneEngine.php b/src/Engine/NoneEngine.php new file mode 100644 index 0000000..bad2fa5 --- /dev/null +++ b/src/Engine/NoneEngine.php @@ -0,0 +1,57 @@ + + + + + + + Hyperf + + + + + +
+
+

Hyperf

+

Hyperf is an extremely performant and flexible PHP CLI framework based on Swoole 4.5+, powered by the + state-of-the-art coroutine server and a large number of battle-tested components. Aside from the decisive + benchmark outmatching against PHP-FPM frameworks, Hyperf also distinct itself by its focus on flexibility + and composability. Hyperf ships with an AOP-enabling dependency injector to ensure components and classes + are pluggable and meta programmable. All of its core components strictly follow the PSR standards and thus + can be used in other frameworks.

+

Learn more

+

This view engine is not available, please use engines below.

+ +
+
+ + +HTML; + } +} diff --git a/src/Render.php b/src/Render.php index 1689c6b..760fea5 100644 --- a/src/Render.php +++ b/src/Render.php @@ -17,7 +17,7 @@ use Hyperf\Task\TaskExecutor; use Hyperf\Utils\Context; use Hyperf\View\Engine\EngineInterface; -use Hyperf\View\Engine\SmartyEngine; +use Hyperf\View\Engine\NoneEngine; use Hyperf\View\Exception\EngineNotFindException; use Hyperf\View\Exception\RenderException; use Psr\Container\ContainerInterface; @@ -47,7 +47,7 @@ class Render implements RenderInterface public function __construct(ContainerInterface $container, ConfigInterface $config) { - $engine = $config->get('view.engine', SmartyEngine::class); + $engine = $config->get('view.engine', NoneEngine::class); if (! $container->has($engine)) { throw new EngineNotFindException("{$engine} engine is not found."); } diff --git a/tests/NoneTest.php b/tests/NoneTest.php new file mode 100644 index 0000000..ffd4654 --- /dev/null +++ b/tests/NoneTest.php @@ -0,0 +1,29 @@ +render('/', [], []); + + $this->assertNotEmpty($content); + } +}