mutantlabs/simplempd

Simple PHP Wrapper for MDP is a PHP class for interfacing with the MPD Music Daemon. It allows you to develop an API to interface with MPD

Installs: 46

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 1

Forks: 3

Open Issues: 0

Language:JavaScript

dev-master 2013-06-28 14:21 UTC

This package is not auto-updated.

Last update: 2024-04-22 12:18:58 UTC


README

#Install

Depends on https://github.com/marcj/php-rest-service

Install simplempd with Composer:

Create a composer.json:

{
    "require": {
        "mutantlabs/simplempd": "dev-master"
    }
}

and run

$ wget http://getcomposer.org/composer.phar
$ php composer.phar install

After the installation, you need to include the vendor/autoload.php to make the class in your script available.

include 'vendor/autoload.php';

Requirements

  • PHP 5.3 and above.
  • PHPUnit to execute the test suite.
  • Setup PATH_INFO in mod_rewrite (.htaccess) or other webserver configuration

htaccess Example:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Simple PHP Wrapper for MDP is a PHP class for interfacing with the MPD Music Daemon. It allows you to develop an API to interface with MPD

#SimpleMPDWrapper Class usage

use SimpleMPDWrapper

use MPDWrapper\SimpleMPDWrapper;

Construct a new SimpleMPDWrapper instance Required parameters: Password, MPD Server address, Port, Refresh interval

$mp = new SimpleMPDWrapper("","192.168.0.1",6600,0);

Send a command using the send method:

echo json_encode($mp->send("add", "spotify:track:48mZ0CGCffjH49h5lAPTIe"));

Or utilise the quick method wrappers

echo json_encode($mp->add("spotify:track:48mZ0CGCffjH49h5lAPTIe"));

#SimpleMPDWrapper API Method using php-rest-service

include 'vendor/autoload.php';

use MPDWrapper\SimpleMPDWrapper;
use RestService\Server;

Server::create('/')
->addGetRoute('add/(.*)', function($data){
            $mp = new SimpleMPDWrapper("","192.168.1.120",6600,0);
            $response = array(
                'message' => 'track sent to mutant playlist',
                'track' => $data,
                'response' => $mp->add($data)
            );
            return $response;
        })
->run();

License