##Introduction
This project exposes the following namespaces for use in your custom plugins and themes:
- Kit\IO\HTTP\KitCurl
- Kit\DB\Memcached
- WPKit\KitCurl
KitCurl is a cURL based proxy service for loading external resources server side (for the times you just forced to). Why KitCurl over cURL or fopen?
- Written for server performance and stability.
- Composer.phar driven
- Modern PSR-0 coding pattern
- Access to rationalised cURL configuration, like sane timeouts.
- Memcached support with transparent failover for easier development installs.
- Support for multiple memcached servers with failover and load-balancing.
- Abstracted cache support for rapidly adding support for other caching systems.
Installation is done in bash (for now)
-
cd into your Wordpress mu-plugins or plugins directory
soap@codex:wp-contents/plugins$
-
grab the code
soap@codex:wp-contents/plugins$ git clone git@github.com:t4g/wp-kitcurl.git
-
build the project
cd wp-kitcurl curl -sS https://getcomposer.org/installer | php -- --install-dir=bin php bin/composer.phar install
-
done! just enable it in the backend.
<?php
$_ = new Kit\IO\HTTP\KitCurl();
echo $_ -> new_http_rawget(<url>) -> execute()
** Procedural **
$kitcurl = new Kit\IO\HTTP\KitCurl();
$request = $kitcurl -> new_http_rawget(<url>);
$request -> set_timeout(3); // optional, override setting on the fly
$response = $request -> execute();
** OOP **
$kitcurl = new Kit\IO\HTTP\KitCurl();
echo $kitcurl -> new_http_rawget(<url>) -> set_timeout(3) -> execute();
** Static OOP **
use Kit\IO\HTTP as Kit
echo Kit\KitCurlSingleton() -> new_http_rawget(<url>) -> noCache -> execute();
** Working with the response **
// get contents
$mycontents = $response; // or echo $response; etc etc
// explore the response
echo $response->getSize(); // total size of the doc
if( $response->getIsViaCached() ){ echo "Bingo" } // total size of the doc
// .... For a full list of methods available see [[ docs ]]
$kitcurl -> add_named( 'something', 'http://api.example.com/blaa' );
$kitcurl -> add_named( 'example', 'http://api.v2.example.com/blopen' );
$nparam = array(
'test' => 'value',
'version' => 'test'.
)
echo $kitcurl -> new_http_get('example') -> params($nparam) -> execute();
$postdata = array(
'myfile' => get_file_contents('~/etc/passed'),
'or_login_deets' => 'myuser'
)
$kitcurl -> new_http_get('example') -> post($postdata) -> execute() -> getHeaders();
HelloKit\IO\HTTP\KitCurl\KitCurlRequest Object
(
[_timeout_enabled:protected] => 1
[_timeout_value:protected] => 5
[_uncached:protected] =>
[_expire_cache:protected] => 600
[_inst_caller:Kit\IO\HTTP\KitCurl\KitCurlRequest:private] => Kit\IO\HTTP\KitCurl Object
(
)
[_inst_responce:Kit\IO\HTTP\KitCurl\KitCurlRequest:private] => Kit\IO\HTTP\KitCurl\KitCurlResponce Object
(
[_data:protected] =>
[_headers:protected] =>
[_status:protected] => 0
[_path:protected] =>
[_iscached:Kit\IO\HTTP\KitCurl\KitCurlResponce:private] =>
[_stat_size:Kit\IO\HTTP\KitCurl\KitCurlResponce:private] =>
[_stat_microtime_start:Kit\IO\HTTP\KitCurl\KitCurlResponce:private] => 0.36297200 1386319704
[_stat_microtime_total:Kit\IO\HTTP\KitCurl\KitCurlResponce:private] =>
)
[_inst_pcurl:Kit\IO\HTTP\KitCurl\KitCurlRequest:private] => Kit\IO\HTTP\Curl Object
(
[_instCURLCopy:Kit\IO\HTTP\Curl:private] =>
[_response:Kit\IO\HTTP\Curl:private] => Array
(
)
[_complete:Kit\IO\HTTP\Curl:private] =>
)
[url:Kit\IO\HTTP\KitCurl\KitCurlRequest:private] => http://apple.com
[reqtype:Kit\IO\HTTP\KitCurl\KitCurlRequest:private] =>
)
** Cache options **
....
use Kit\IO\HTTP\KitCurl as KitCurl; // optional
$kitcurl -> cache_enabled( KitCurl/KitCurlOptions::CACHE_DISABLED );
** Working with the Kit\DB\Memcached backend **
....
//flushing
$kitcurl -> cache() -> flush();
//advanced stuff
$kitcurl -> cache() -> backend() -> getStats();
$kitcurl -> cache() -> backend() -> getServerList();
soap@codex:plugins/wp-kitcurl$
soap@codex:plugins/wp-kitcurl$ ./bin/generate_phpdocs.sh
** If you require phpdoc to be installed **
cd ./developer
php ../bin/composer.phar install