dev-master
9999999-devA small client to request data from a wordpress project using the built-in JSON api.
MIT
The Requires
The Development Requires
by Jefferson Ochoa (Jeff)
Wallogit.com
2017 © Pedro Peláez
A small client to request data from a wordpress project using the built-in JSON api.
A small client to request data from a wordpress project using the built-in JSON api., (*1)
This package uses kitetail/zttp which is a lightweight Guzzle client., (*2)
$ composer require jeffochoa/laravel-wordpress-client
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=
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();
$response = Wordpress::categories();
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)
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();
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"/>
Pull requests and issues are welcome., (*13)
Say hi on twitter: @Jeffer_8a, (*14)
A small client to request data from a wordpress project using the built-in JSON api.
MIT