2017 © Pedro Peláez
 

library laravel-wordpress-client

A small client to request data from a wordpress project using the built-in JSON api.

image

jeffochoa/laravel-wordpress-client

A small client to request data from a wordpress project using the built-in JSON api.

  • Tuesday, December 12, 2017
  • by jeffer8a
  • Repository
  • 1 Watchers
  • 17 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Wordpress json-api client for Laravel 5.5.*

A small client to request data from a wordpress project using the built-in JSON api., (*1)

About

This package uses kitetail/zttp which is a lightweight Guzzle client., (*2)

Install

$ composer require jeffochoa/laravel-wordpress-client

Config

Publish the config file:, (*3)

$ php artisan vendor:publish --laravel-wordpress

Add your wordpress site API endpoint to the .env file, (*4)

WP_API_URL=

How to use?

Here you have a list of the available methods:, (*5)

$wordpress = new WordpressClient();

$response = $wordpress->categories();
$response = $wordpress->media();
$response = $wordpress->pages();
$response = $wordpress->posts();
$response = $wordpress->statuses();
$response = $wordpress->tags();
$response = $wordpress->taxonomies();
$response = $wordpress->types();
$response = $wordpress->users();

Using via facade accessor

$response = Wordpress::categories();

Request params

All the methods receive an array to be use as part of the query, (*6)

$response = Wordpress::posts(['page' => 1, 'per_page' => 1]);

Here you can get a list of the arguments that you can use on each request., (*7)

Parsing the responses

As an array:, (*8)

$response = Wordpress::posts(['page' => 1, 'per_page' => 1])->json();

As a collection:, (*9)

$response = Wordpress::posts(['page' => 1, 'per_page' => 1])->collection();

Testing

To run the tests you can clone this project then:, (*10)

$ composer install

And finally you need to create your own phpunit.xml file, (*11)

$ cp phpunit.example phpunit.xml

Don't forget to set the wordpress api endpoint in your phpunit.xml file, (*12)

<env name="WP_API_URL" value="www.wordpress.dev/wp-json/wp/v2"/>

Contribute

Pull requests and issues are welcome., (*13)

Thanks!

Say hi on twitter: @Jeffer_8a, (*14)

The Versions

12/12 2017

dev-master

9999999-dev

A small client to request data from a wordpress project using the built-in JSON api.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jefferson Ochoa (Jeff)