PHPackages                             dievardump/wp-bladeone-plugin - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. dievardump/wp-bladeone-plugin

ActiveWordpress-plugin[Templating &amp; Views](/categories/templating)

dievardump/wp-bladeone-plugin
=============================

Plugin enabling Blade(One) syntaxing in wordpress themes

2643[2 issues](https://github.com/dievardump/wp-bladeone-plugin/issues)PHP

Since Jul 15Pushed 5y ago1 watchersCompare

[ Source](https://github.com/dievardump/wp-bladeone-plugin)[ Packagist](https://packagist.org/packages/dievardump/wp-bladeone-plugin)[ RSS](/packages/dievardump-wp-bladeone-plugin/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

WP Blade(One)
=============

[](#wp-bladeone)

Wordpress plugin to allow the use of Blade syntax in your templates.

to achieve this, this plugin use [BladeOne](https://github.com/EFTEC/BladeOne/), which is a standalone port of Laravel's Blade, without dependencies.

1 - Installation
----------------

[](#1---installation)

You will need to use composer and have [composer/installers](https://github.com/composer/installers) installed and configured, so composer knows how to install this plugin in the right wordpress directory.

Then you just need to

`composer require dievardump/wp-bladeone-plugin`

And activate it in the Wordpress plugins panel

2 - Configuration
-----------------

[](#2---configuration)

There are 3 constants that you can define to configure the WP BladeOne.

- `WP_BLADEONE_VIEWS`

Where BladeOne will look for the view files. If you use [WP Blade(One) Starter Template](https://github.com/dievardump/wp-bladeone-theme) or want `WP BladeOne` to work with Wordpress hierarchy, it should be your theme directory. If you just want to render some templates using `wp_bladeone()->run($view_name, $data)` then you can set another path. (see Usage below) default to `get_stylesheet_directory()`

- `WP_BLADEONE_CACHE`

Where BladeOne will have the right to write the views cached files. Usually somewhere in `WP_CONTENT_DIR` as other directories are often not writable. default to `WP_CONTENT_DIR . '/cache/.wp-bladeone-cache'`

- `WP_BLADEONE_MODE`

Configures how BladeOne manages the rendering of the views, including caching. See [BladeOne](https://github.com/EFTEC/BladeOne/) to know what the different modes are and what they do. default to `\eftec\bladeone\BladeOne::MODE_AUTO`

3 - Usage
---------

[](#3---usage)

There are two ways to use this Plugin in your templates.

### 3.1 Using Hierarchy

[](#31-using-hierarchy)

This plugin will hook on some Wordpress actions so when Wordpress tries to render a template file, it will first look if a Blade version is available. (i.e: before rendering `index.php` it will first look if `index.blade.php` exists).

This allows you to create full themes working entirely with Blade syntax (see [WP Blade(One) Starter Template](https://github.com/dievardump/wp-bladeone-theme) as en example)

### 3.2 Using `wp_bladeone()->run($view_name, $data)`

[](#32-using-wp_bladeone-runview_name-data)

If you don't want to use the hierarchical hooks, you can set `WP_BLADEONE_VIEWS` to `/views` (or any other directory for that matters) and put all your blade template files there.

Then, in your themes files, when you want to use a Blade view just do `wp_bladeone()->run($view_name, $data)`.

Exemple: file `wp-config.php`

```
