MLPHP
PHP API for MarkLogic
MLPHP is a PHP API for MarkLogic that makes it easy to store documents, manage document metadata, and create sophisticated search queries on a web server running PHP (version 5.4 or greater). The PHP classes communicate with the MarkLogic via the MarkLogic REST API., (*1)
After installing MLPHP (see below), you can load documents into
MarkLogic with just a couple lines of PHP code:, (*2)
use MarkLogic\MLPHP;
$document = new MLPHP\Document($client);
$document->setContentFile('myfile.xml')->write('/myfile.xml');
Searching is just as easy:, (*3)
use MarkLogic\MLPHP;
$search = new MLPHP\Search($client);
$results = $search->retrieve('cat');
More details are available in the examples described below., (*4)
Dependencies
Installation
To add MLPHP to your project, simply add MLPHP as a Composer requirement in composer.json:, (*5)
{
"require": {
"marklogic/mlphp" : "dev-master"
}
}
And then, depending on how you installed Composer, run, (*6)
% composer install
or, (*7)
% php composer.phar install
API Documentation
API docs are available online. A copy is also provided inside the MLPHP repo under api/docs
., (*8)
License
MLPHP is licensed under the Apache License, Version 2.0 (see LICENSE.txt)., (*9)
Status
MLPHP is in early-stage development, but ready for use. The API is subject to change., (*10)
Examples
MLPHP examples are being revised., (*11)
Development
Building
% git clone git@github.com:marklogic/mlphp mlphp
% cd mlphp
% composer install
To generate a clean set of new API docs from source
-
Update master branch, (*12)
% cd $PATH_TO_MLPHP/mlphp/api/docs
% git rm -rf *
% cd $PATH_TO_MLPHP/mlphp/
% vendor/bin/phpdoc mlphp.ini
% cd $PATH_TO_MLPHP/mlphp/api/docs
% git add .
% git commit -a -m "New docs"
% git push origin master
-
Update gh-pages copy (Technique borrowed from https://gist.github.com/825950), (*13)
% cd $PATH_TO_MLPHP/mlphp/api
If this is the first time,, (*14)
% git clone -b gh-pages \
--single-branch git@github.com:marklogic/mlphp docs-ghpages
Then..., (*15)
% cd $PATH_TO_MLPHP/mlphp/api/docs-ghpages
% git rm -rf [a-z]*
% cd $PATH_TO_MLPHP/mlphp
% vendor/bin/phpdoc mlphp-ghpages.ini
% cd PATH_TO_MLPHP/mlphp/api/docs-ghpages
% git add .
% git commit -a -m "New docs"
% git push origin gh-pages
Unit tests
Unit tests can be found under tests
. To run,, (*16)
- Edit
phpunit-config.php
and set configuration variables specific to your MarkLogic setup.
-
Run the tests:, (*17)
% vendor/bin/phpunit tests
MLPHP uses PHPUnit for testing. See the tests README.md for more., (*18)
Contributing
You can request a new feature by submitting an issue to the project's [GitHub Issue Tracker]
(https://github.com/marklogic/mlphp/issues)., (*19)
Please submit pull requests to the develop
branch., (*20)
Copyright
Copyright 2002-2015 MarkLogic Corporation. All Rights Reserved., (*21)