LaravelPackages.net
Acme Inc.
Toggle sidebar
tradzero/wp_rest_laravel

54
3
0.03
About tradzero/wp_rest_laravel

tradzero/wp_rest_laravel is a Laravel package. It currently has 3 GitHub stars and 54 downloads on Packagist (latest version 0.03). Install it with composer require tradzero/wp_rest_laravel. Discover more Laravel packages by tradzero or browse all Laravel packages to compare alternatives.

Last updated

WPREST

laravel package for easy use wordpress rest api, only provide post, category create and update at this version.

Prepare

WP REST API V2

All REST API provided by WP REST API V2, if your wordpress version more than 4.7, you can skip this, because it's included in wordpress 4.7, if not, you should install it WP REST API V2 plugin

JWT Authentication for WP-API

Wordpress don't provide a easy way to authenticate api, so i decide use JWT plugin to authenticate.

Here is link

Usage

when you installed, you need to configure and enable it.

Install

$ composer require tradzero/wp_rest_laravel:dev-master -vvv

Edit /pathto/config/app.php

'providers' => [
    // Other service providers...
    Tradzero\WPREST\WPRESTServiceProvider::class,
],

You can also add alias in

'aliases' => [
    'WPREST' => Tradzero\WPREST\Facade::class,
]

Publish config file

$ php artisan vendor:publish --provider=Tradzero\WPREST\WPRESTServiceProvider

Configure wordpress.php
enter your wordpress endpoint and account infomation.

Usage

use Tradzero\WPREST\Resources\Post;
use Tradzero\WPREST\Resources\Category;
use WPREST;

$post = new Post();
$post->setTitle('hello world');
$post->setContent('Its post created using WP REST API');

WPREST::createPost($post);

$post->setId('XX');
WPREST::updatePost($post);

$category = new Category;
$category->setName('category 1');
WPREST::findCategoryOrCreate($category);
// or
WPREST::createCategory($category);
$post->setCategories(array($category));
WPREST::createPost($post);

Star History Chart