Skip to content

Latest commit

 

History

History
131 lines (97 loc) · 3.03 KB

README.md

File metadata and controls

131 lines (97 loc) · 3.03 KB

Kathamo

Framework for WordPress plugin development.



It is recommended to use Kathamo Generator to generate your custom skeleton of this Framework


Environment setup

If make commands work in your OS then just need to run make setup.


Otherwise follow this process:
  1. composer install
  2. npm install
  3. npm run dev

If you want to enqueue unminified assets then change HOWDY_DEV_MODE to true for loading unminified assets.

TailwindCSS support also added. To watch changes npm run tailwindcss:admin or npm run tailwindcss:public



Plugin Architecture

Architecture

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 Core we have used SingleTon, then created class instance in plugin.php > Core::getInstance().



HTTP API

Set rest api base url, namespace, version in HttpKernel class


Request Example

/**
 * GET request
 *
 * @param (string) $route
 * @param (array) $arguments
 * @return \Howdy\Core\Lib\Response
 */
$response = HttpKernel::get( 'post',
    [
        'timeout' => 25
    ]
);

/**
 * POST request
 *
 * @param (string) $route
 * @param (array) $arguments
 * @return \Howdy\Core\Lib\Response
 */
$response = HttpKernel::post( 'authenticate',
    [
        'body' => [ 'token' => 'sdlfepoagdhwt3543sfes' ]
    ]
);

Response API

HTTP requests return \Howdy\Core\Lib\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 = HttpKernel::post( 'authenticate',
    [
        'body' => [ 'token' => 'sdlfepoagdhwt3543sfes' ]
    ]
);

if ( $response->getStatusCode() === 200 ) {
    // Do something
}

$response->dump();  // debug response data


Deploy Automation

Deploy to WordPress org plugin repo by creating a tag and push it on Github. For doing so, just go to your plugin Github repo Settings > Secrets and create tow variables as below. Then change SLUG in .github/workflows/diploy.yml, here add your plugin's WP ORG slug.

That's it, now whenever you push a tag on Github the plugin will be automatically deployed to WP ORG plugin repo. It remove all development files that are not required in production. If you want to change which development files to remove than just modife .distignore

WP_SVN_USER <your svn user>
WP_SVN_PASS <your svn password>