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.
After installing MLPHP (see below), you can load documents into MarkLogic with just a couple lines of PHP code:
use MarkLogic\MLPHP;
$document = new MLPHP\Document($client);
$document->setContentFile('myfile.xml')->write('/myfile.xml');
Searching is just as easy:
use MarkLogic\MLPHP;
$search = new MLPHP\Search($client);
$results = $search->retrieve('cat');
More details are available in the examples described below.
- MarkLogic 7 or later. Download the server, start it, and request a free Developer or Express license directly from the Admin UI on port 8001.
- PHP 5.4-or-later-enabled web server (e.g., Apache running PHP) with the following extension libraries (typically available by default)
- DOM
- cURL
- XSL
- MLPHP
- Composer.
To add MLPHP to your project, simply add MLPHP as a Composer requirement in composer.json:
{
"require": {
"marklogic/mlphp" : "dev-master"
}
}
And then, depending on how you installed Composer, run
% composer install
or
% php composer.phar install
API docs are available online. A copy is also provided inside the MLPHP repo under api/docs
.
MLPHP is licensed under the Apache License, Version 2.0 (see LICENSE.txt).
MLPHP is in early-stage development, but ready for use. The API is subject to change.
MLPHP examples are being revised.
% git clone [email protected]:marklogic/mlphp mlphp
% cd mlphp
% composer install
-
Update master branch
% 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)
% cd $PATH_TO_MLPHP/mlphp/api
If this is the first time,
% git clone -b gh-pages \ --single-branch [email protected]:marklogic/mlphp docs-ghpages
Then...
% 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 can be found under tests
. To run,
-
Edit
phpunit-config.php
and set configuration variables specific to your MarkLogic setup. -
Run the tests:
% vendor/bin/phpunit tests
MLPHP uses PHPUnit for testing. See the tests README.md for more.
You can request a new feature by submitting an issue to the project's [GitHub Issue Tracker] (https://github.com/marklogic/mlphp/issues).
Please submit pull requests to the develop
branch.
Copyright 2002-2015 MarkLogic Corporation. All Rights Reserved.