laravel 刀片模板引擎可以与codeigniter一起使用吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32021680/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The blade template engine can be used with codeigniter?
提问by Joe
The template engine called blade can be used with codeigniter or pure php? I know that it can be used with laravel and I'd like to know if also can be used with any other php framework or with pure php
称为blade的模板引擎可以与codeigniter或pure php一起使用吗?我知道它可以与 laravel 一起使用,我想知道是否也可以与任何其他 php 框架或纯 php 一起使用
回答by user2094178
Blade
can be used stand-alone in PHP.
Blade
可以在 PHP 中独立使用。
This means you can comfortably use it in CodeIgniter.
这意味着您可以在 CodeIgniter 中轻松使用它。
https://github.com/PhiloNL/Laravel-Blade
https://github.com/PhiloNL/Laravel-Blade
Then again, you will need composer
for that.
再说一次,您将需composer
要这样做。
回答by Gustavo Martins
Alternatively you could use this CodeIgniter Library to simulate Blade: CodeIgniter Slice-Libray
或者,您可以使用此 CodeIgniter 库来模拟 Blade:CodeIgniter Slice-Libray
It works pretty like Blade and it was designed directly for CodeIgniter!
它的工作原理与 Blade 非常相似,并且是直接为 CodeIgniter 设计的!
回答by magallanes
For the record and as answer to another post:
作为记录并作为对另一篇文章的回答:
I tested many libraries to run blade outside Laravel (that i don't use) and most (with all respect of the coders) are poor hacks of the original library that simply copied and pasted the code and removed some dependencies yet it retains a lot of dependencies of Laravel.
我测试了许多库以在 Laravel 之外运行刀片(我不使用)并且大多数库(在所有编码人员的方面)都是原始库的糟糕黑客,它们只是简单地复制和粘贴代码并删除了一些依赖项,但它保留了很多Laravel 的依赖关系。
I created an alternative for blade that its free (MIT license, i.e. close source/private code is OK) in a single file and without a single dependency of an external library. You could download the class and start using it, or you could install via composes (composer require eftec/bladeone). So even composer is optional.
我为刀片创建了一个替代方案,它在单个文件中免费(MIT 许可证,即关闭源代码/私有代码是可以的),并且没有外部库的单一依赖项。您可以下载该类并开始使用它,也可以通过 composes 进行安装(composer 需要 eftec/bladeone)。所以即使作曲家也是可选的。
https://github.com/EFTEC/BladeOne
https://github.com/EFTEC/BladeOne
https://packagist.org/packages/eftec/bladeone
https://packagist.org/packages/eftec/bladeone
Its 100% compatible sans the Laravel's own features (extensions).
它 100% 兼容没有 Laravel 自己的特性(扩展)。
回答by twigg
I have done a full write up here: http://mstd.eu/index.php/2017/03/02/using-the-laravel-blade-templating-engine-in-codeigniter-3/
我在这里做了一个完整的写:http: //mstd.eu/index.php/2017/03/02/using-the-laravel-blade-templating-engine-in-codeigniter-3/
Basically, include the package with composer (you need to set CI up to use composer), then create a blade instance passing it your view and cache folder like so:
基本上,使用 composer 包含包(您需要设置 CI 以使用 composer),然后创建一个刀片实例,将您的视图和缓存文件夹传递给它,如下所示:
$blade = new BladeInstance(__DIR__ . "/../views", __DIR__ . "/../cache/views");
echo $blade->render("index");