ekandreas/bladerunner
最新稳定版本:1.8.2
Composer 安装命令:
composer require ekandreas/bladerunner
包简介
WordPress Blade L5/6/7/8 template engine
关键字:
README 文档
README
WordPress plugin for Laravel Blade templating.
To install it to your Composer based WordPress installation:
composer require ekandreas/bladerunner
Activate the plugin inside WordPress and templates with *.blade.php are inspected and active. Your theme still needs an index.php due to WordPress basic functionality. When removed the theme is known as broken.
If you don't use a composer based WordPress development environment you can download the latest distributed plugin at Bladerunner site http://bladerunner.aekab.se and install it the common way with zip upload to WordPress via wp-admin.
Releases to this plugin is listed last in this readme.
Hello World
- Install the library with composer
- Make sure the cache-folder is writeable in uploads, eg
../wp-content/uploads/.cache - Activate the plugin
- Create a view, eg:
<!-- view file: views/pages/index.blade.php --> Hello World Page rendered at {{ date('Y-m-d H:i:s') }}
- In your
index.php, add a global call for the view created, eg:
<?php bladerunner('views.pages.index')
https://laravel.com/docs/5.2/blade
Cache
- If
WP_DEBUGis set and true then templates always will be rendered and updated. - View files (cache) is invalidated at
save_post - (It's a really good idea to empty the .cache folder inside
uploadswhen develop templates. Eg, create adelcommand inside your gulp-file.)
Directories
- Your cached views will always be stored in your wp upload folder,
.cache - Your views must be placed within your theme folder.
- Your views must have
.blade.phpextension.
Template helper
There is a template helper function named bladerunner, defined globally to use in standard WordPress templates.
Example:
You want to create a 404-template and don't want to use the .blade.php extension to the template file.
- Create a 404.php in the theme root.
- Add the following code to the template:
<?php bladerunner('views.pages.404');
- In the folder
views/pages, create a blade template404.blade.php
You can pass any data with the global bladerunner function like so,
<?php bladerunner('views.pages.404', ['module'=>$module]);
or use compact, eg:
<?php bladerunner('views.pages.404', compact('module'));
Controllers
With version 1.7 controllers are added to Bladerunner. As default Bladerunner will look for extended classes in the theme folder + /controllers. If you would like to add or change the controller paths take a look below at filters!
The controller class has to extend \Bladerunner\Controller to work.
It will guess the path to the view but you can override this with protected $view='your.custom.view.path''
The controller files follow the same hierarchy as WordPress.
You can view the controller hierarchy by using the Blade directive @debug.
Extend the Controller Class, it is recommended that the class name matches the filename. Create methods within the Controller Class:
- Use public function to expose the returned values to the Blade views/s.
- Use public static function to use the function within your Blade view/s.
- Use protected function for internal controller methods as only public methods are exposed to the view. You can run them within
__construct
Controller example:
The following example will expose $images to views/single.blade.php
controllers/Single.php
<?php namespace App; use Bladerunner\Controller; class Single extends Controller { /** * Return images from Advanced Custom Fields * * @return array */ public function images() { return get_field('images'); } }
views/single.blade.php
@if($images) <ul> @foreach($images as $image) <li><img src="{{$image['sizes']['thumbnail']}}" alt="{{$image['alt']}}"></li> @endforeach </ul> @endif
Hooks and Filters
Bladerunner continuously implements filters and hooks to modify values and processes.
Hooks
...
Filters
Modify Bladerunners cache folder path, default ../wp-content/uploads/.cache
add_filter('bladerunner/cache/path', function() { return '/my/path/to/cache'; });
If you don't want Bladerunner to create the cache folder:
add_filter('bladerunner/cache/make', function() { return false; });
If you wan't to customize the base paths where you have your views stored, use:
add_filter('bladerunner/template/bladepath', function ($paths) { if (!is_array($paths)) { $paths = [$paths]; } $paths[] = ABSPATH . '../../resources/views'; return $paths; });
If you wan't to customize the controller paths where you have your controllers stored, use:
add_filter('bladerunner/controller/paths', function ($paths) { $paths[] = PLUGIN_DIR . '/my-fancy-plugin/controllers'; return $path; });
We will soon add more WordPress extenstions to the Bladerunner engine. Please give us your great examples to implement!
Links
- Bladerunner site with documentation and distro
- Docs Laravel Blade v5.2
- Packagist
- Code repo at Github
- Support / Issues
Tests
Test requirements:
- Latest Docker install (not the old school Boot2Docker)
- PHP Composer Currently only tested on OSX.
Test step by step
Checkout the components for testing via Composer inside the repo:
composer update
Using Testrunner (required-dev package) and Docker the test should be exexuted with a single command:
vendor/bin/dep testrunner
ekandreas/bladerunner 适用场景与选型建议
ekandreas/bladerunner 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 32.32k 次下载、GitHub Stars 达 10, 最近一次更新时间为 2015 年 12 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「wordpress」 「laravel」 「blade」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ekandreas/bladerunner 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ekandreas/bladerunner 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ekandreas/bladerunner 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Alfabank REST API integration
Render blade templates into a PSR-7 Response object.
Must-use plugin integrating WordPress with the Upsun platform: environment awareness, router-cache friendliness, safe preview clones, deploy migrations, Site Health checks, and a wp upsun CLI command.
A tiny Flask-like PHP microframework where each public method is an endpoint and routes are inferred from method names.
The EdgestashBlade Laravel package adds Edgestash support to Blade. Edgestash is a Varnish Enterprise module that processes Mustache templates on the edge.
Laravel package for Accurate Online API integration.
统计信息
- 总下载量: 32.32k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 13
- 点击次数: 23
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-12-14