Howdy
WordPress plugin starter. Based on "Service Provider" design pattern.
Environment setup
composer install
npm install
Plugin Backend Architecture
howdy.php |---- bootstrap.php
|
Service Provider |
| |
Controller |---- Helpers
| |
Views |
Debugging Tool/API
On development environment, two apis are available for better debugging experience.
dump($data); // debug data
dd($data); // debug data and die.
SingleTon
A trait for singleton is available. You can use it for creating single class instance. For example: check HowdyServiceProvider
we have used SingleTon
, then created class instance in howdy.php > HowdyServiceProvider::getInstance()
.
HTTP API
Set rest api base url, namespace, version in HowdyHttp
class
Request Example
/**
* GET request
*
* @param (string) $route
* @param (array) $arguments
* @return \Howdy\Helpers\Response
*/
$response = HowdyHttp::get( 'post',
[
'timeout' => 25
]
);
/**
* POST request
*
* @param (string) $route
* @param (array) $arguments
* @return \Howdy\Helpers\Response
*/
$response = HowdyHttp::post( 'authenticate',
[
'body' => [ 'token' => 'sdlfepoagdhwt3543sfes' ]
]
);
Response API
HTTP requests return \Howdy\Helpers\Response
object. This object has apis as below.
getBody() // json decoded body of the response
getBody(false) // json encoded body
getStatusCode() // status code of the response
getMessage() // response message
getHeaders() // get response headers
dump() // debug response
Response Example
$response = HowdyHttp::post( 'authenticate',
[
'body' => [ 'token' => 'sdlfepoagdhwt3543sfes' ]
]
);
if ( $response->getStatusCode() === 200 ) {
// Do something
}
$response->dump(); // debug response data