PHPackages                             starring-jane/wordpress-blade - 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. starring-jane/wordpress-blade

ActiveLibrary[Templating &amp; Views](/categories/templating)

starring-jane/wordpress-blade
=============================

A composer package that enables Wordpress to use the Blade templating engine

1.0.15(2y ago)85.3k↓33.3%1MITPHP

Since Sep 23Pushed 2y ago4 watchersCompare

[ Source](https://github.com/starringjane/wordpress-blade)[ Packagist](https://packagist.org/packages/starring-jane/wordpress-blade)[ RSS](/packages/starring-jane-wordpress-blade/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (18)Used By (0)

WordPress Blade
===============

[](#wordpress-blade)

Adds the Laravel Blade template engine to WordPress

Installation for WordPlate (skip for basic WordPress)
-----------------------------------------------------

[](#installation-for-wordplate-skip-for-basic-wordpress)

Start with adding the composer package

`composer require starring-jane/wordpress-blade`

Create a WordpressBlade instance in your theme `functions.php`

```
use StarringJane\WordpressBlade\WordpressBlade;

WordpressBlade::create(
    base_path('resources/views'), // Path to all blade files
    base_path('storage/views/cache'), // Path to blade cache
    base_path('public/themes/janes/components') // Path to component classes (optional, but recommended)
);
```

Create the following structure

```
/public
├── /themes
|   └── /theme-name
|       ├── /components
|       |   └── button.php
|       ├── /templates
|       |   ├── 404.php
|       |   ├── front-page.php
|       |   ├── page.php
|       |   └── single.php
|       └── functions.php
|       └── index.php
|       └── style.css
├── /resources
|   └── /views
|       └── /components
|       |   └── button.blade.php
|       └── /pages
|       |   └── page.blade.php
|       └── index.blade.php
└── /storage/cache/views

```

Installation for WordPress (skip for WordPlate)
-----------------------------------------------

[](#installation-for-wordpress-skip-for-wordplate)

Start with adding the composer package

`composer require starring-jane/wordpress-blade`

Create a WordpressBlade instance in `functions.php`

```
use StarringJane\WordpressBlade\WordpressBlade;

WordpressBlade::create(
    get_theme_file_path('views'), // Path to all blade files
    get_theme_file_path('cache/views'), // Path to blade cache
    get_theme_file_path('components') // Path to component classes (optional, but recommended)
);
```

Autoload your theme namespace in `composer.json`

```
{
    ...
    "autoload": {
        "psr-4": {
            "ThemeName\\": "wp-content/themes/theme-name"
        }
    },
    ...
}

```

Create the following structure

```
/wp-content/themes/theme-name
├── /cache/views
├── /components
|   └── button.php
├── /templates
|   ├── 404.php
|   ├── front-page.php
|   ├── page.php
|   └── single.php
├── /views
|   └── /components
|   |   └── button.blade.php
|   └── /pages
|   |   └── default.blade.php
|   └── index.blade.php
└── functions.php
└── index.php
└── style.css

```

Templates
---------

[](#templates)

Add a page template in the `/templates` directory with a component class and add at least a public render function

`/templates/page.php`

```
