The package requires minimal pre-requisites:
- PHP 5.3 or newer
Add the following to your composer.json file:
"repositories": [
{
"type": "vcs",
"url": "https://github.com/JeffersonLab/eloglib-php.git"
}
],
"require" : {
"jlab/eloglib-php" : "dev-master"
}
Or later once the package is made public, you can get the latest version, simply by requiring the project using Composer:
$ composer require jlab/eloglibInstantiate an entry with just a title and logbook name and then echo out the XML representation:
#!/usr/bin/php
<?php
require(__DIR__.'/vendor/autoload.php');
$entry = new Jlab\Eloglib\Logentry('Test','TLOG');
print $entry->getXML();
?>Settings are resolved in this order, first match winning:
- Overrides on the entry itself, via
withConfig() - Values given to
LogentryUtil::setDefaultConfig() - The process environment (
getenv()) $_ENVand$_SERVER, which is where a.envfile lands- The
.envshipped with this package
Nothing to do — the defaults in the bundled src/.env apply, and any
environment variable of the same name overrides them.
Useful when the host application already holds these settings and should not have to route them through the environment. A framework can do this once at boot:
use Jlab\Eloglib\LogentryUtil;
LogentryUtil::setDefaultConfig(array(
'SUBMIT_URL' => 'https://logbooks.jlab.org/incoming',
'ELOGCERT_FILE' => '/etc/elog/elogcert',
));In Laravel, for example, from a service provider — which keeps the settings in
config/, where they survive php artisan config:cache:
LogentryUtil::setDefaultConfig([
'SUBMIT_URL' => config('elog.submit_url'),
'ELOGCERT_FILE' => config('elog.cert_path'),
]);To send a single entry somewhere else without disturbing global state:
$entry = new Jlab\Eloglib\Logentry('Test', 'TLOG');
$entry->withConfig(array('ELOGCERT_FILE' => '/path/to/another.pem'));ext-curl, ext-dom and ext-libxml are needed. ext-posix is used when
present but is not required.
Is available: API Reference