MediaPlug-PHP is a PHP wrapper for the MediaPlug (http://gomediaplug.com) REST API. It provides a simple, chainable API syntax for the construction of MediaPlug URLs.
PHP Shell Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples
script
src
tests
.gitignore
MIT-LICENSE
Makefile
README.md
Rakefile

README.md

MediaPlug-PHP

MediaPlug-PHP is a PHP wrapper for the MediaPlug (http://gomediaplug.com) REST API. It provides a simple, chainable API syntax for the construction of MediaPlug URLs.

Install

  1. If you are using pear, you can install MediaPlug-PHP from pearhub

    $ pear channel-discover pearhub.org
    $ pear install pearhub/MediaPlug
    

    If you already added pear to your load path, just require 'MediaPlug/MediaPlug.inc' in your file.

    <?php
    require_once 'MediaPlug/MediaPlug.inc';
    $mp = new MediaPlug("mp.yourserver.com");
    echo $mp->image('http://example.com/test.png', 'png')->rotate(90) . "\n";
    ?>
    
  2. You also can clone this repository. Switch to a tag and copy the whole src directory and require file MediaPlug.inc in your project.

  3. If you don't want to use GIT, you can download a zip package or tarball of this project using the Downloads button in the top right corner.

Example

$mp = new MediaPlug("mp.yourserver.com");

# chain API like MediaPlug-Ruby
$mp->image('http://some.url', 'jpg')->resize('>100x>100')->crop('100x100')->getURL();
# => http://mp.yourserver.com/mp/get?mpsrc=http%3A%2F%2Fsome.url&mpaction=resize%20width%3D%3E100%20height%3D%3E100%20format%3Djpg%3Bcrop%20location%3Dcenter%20width%3D100%20height%3D100%20format%3Djpg

NOTICE: shorten is not implemented yet

Now Mediaplug2 server allows you to create shorten Url: Write down your access id from your profile in Mediaplug Mangement Portal:

$mp = new MediaPlug("video.gomediaplug.com", YOUR_MEDIA_PLUG_ACCESS_ID)
$mp->image('http://some.url', 'jpg')->resize('>100x>100')->crop('100x100')->shorten();

API Reference

See http://intridea.github.com/mediaplug2-php.

Development

Test

Install PHPUnit and run make. At the moment of this writing, I have to manually install following pear packages first:

$ pear install Net_URL2-0.3.1
$ pear install HTTP_Request2-2.0.0RC1

Use script/phpunit.sh to run specified test file and all files in a directory such as:

$ script/phpunit.sh tests/MediaPlug/Util/toMediaPlugOptionsTest.php
$ script/phpunit.sh tests/MediaPlug/Util

See Test Report in doc/test.html.

The coverage test requires XDebug and json extension. Install XDebug and enable extension xdebug and json in php.ini. Run rake cov and see Coverage Report in doc/cov/index.html.

Generate Document

Install phpDocumentor and run make doc.