typisttech/cloudflare-wp-api

This package is abandoned and no longer maintained. The author suggests using the cloudflare/sdk package instead.

WordPress HTTP API replacement of the jamesryanbell/cloudflare package.

0.3.0 2017-03-02 09:20 UTC

This package is auto-updated.

Last update: 2020-11-29 17:27:09 UTC


README

Latest Stable Version Total Downloads Build Status codecov Scrutinizer Code Quality PHP Versions Tested StyleCI Dependency Status License Donate via PayPal Hire Typist Tech

WordPress HTTP API replacement of the jamesryanbell/cloudflare package.

Why use WP HTTP API instead of curl?

curl is great. However, it is not always available on every hosts, especially shared hosting. Using WordPress HTTP API lets WordPress figure out the best way to make HTTP requests. It could be curl or something else. You don't need to care about it. See WordPress codex.

Install

Installation should be done via composer, details of how to install composer can be found at https://getcomposer.org/.

$ composer require typisttech/cloudflare-wp-api

Since the jamesryanbell/cloudflare package doesn't provide a way to inject client objects, we have to rename Cloudflare\Api to Cloudflare\BaseApi. And, use our Api class instead

$ vendor/bin/cfwp build

You have to run the command on every composer install and composer update. A better way to do so is to add this command to composer.json like so:

  "scripts": {
    "post-install-cmd": "cfwp build",
    "post-update-cmd": "cfwp build"
  }

Usage

Once $ cfwp build is done, you can use it exactly the same as the original package.

See jamesryanbell/cloudflare for more details about the original package.

Successful responses

Decode body array from wp_remote_request.

Error responses

WP_Error object. Maybe returned from wp_remote_request, or one of the followings:

Code Message Data
authentication-error Authentication information must be provided
authentication-error Email is not valid
decode-error Response errors is not an array response

Or, one of the Coudlfare defined error codes, here is some example:

Code Message Data
1012 Request must contain one of 'purge_everything' or 'files' response
1210 That operation is no longer allowed for that domain response

Start Developing

This command will clone the project source code from GitHub and install its dependencies.

$ composer create-project --no-install --prefer-source --keep-vcs typisttech/cloudflare-wp-api:dev-master
$ cd cloudflare-wp-api
$ composer install

Running the Tests

Cloudflare WP API run tests on Codeception and relies wp-browser to provide WordPress integration. Before testing, you have to install WordPress locally and add a codeception.yml file. See codeception.example.yml for a Varying Vagrant Vagrants configuration example.

Actually run the tests:

$ composer test

We also test all PHP files against PSR-2: Coding Style Guide and part of the WordPress coding standard.

Check the code style with $ composer check-style and fix it with $ composer fix-style.

Feedback

Please provide feedback! We want to make this library useful in as many projects as possible. Please submit an issue and point out what you do and don't like, or fork the project and make suggestions. No issue is too small.

Change log

Please see CHANGELOG for more information on what has changed recently.

Security

If you discover any security related issues, please email cloudflare-wp-api@typist.tech instead of using the issue tracker.

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Credits

Cloudflare WP API is a Typist Tech project and maintained by Tang Rufus, freelance developer for hire.

Full list of contributors can be found here.

Special thanks to James Bell whose Cloudflare package make this project possible.

License

Cloudflare WP API is licensed under the GPLv2 (or later) from the Free Software Foundation. Please see License File for more information.