classmarkets / javaproperties.php
A class for loading Java properties files in PHP
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 0
pkg:composer/classmarkets/javaproperties.php
Requires
- php: >=5.3.0
This package is auto-updated.
Last update: 2020-02-26 12:17:53 UTC
README
Parse Java properties files in PHP.
This class allows you to parse Java properties files or strings in PHP. It should be completely compliant with [the parsing rules of java.util.Properties](http://docs.oracle.com/javase/7/docs/api/java/util/Properties.html#load(java.io.Reader).
INTERFACE
<?php class Classmarkets\JavaProperties implements \ArrayAccess { void loadResource($url, $streamContext = null); void loadString($string); array getAll(); }
SYNOPSIS
<?php $properties = new Classmarkets\JavaProperties; $properties->loadString("foo: bar"); // OR: $properties->loadResource("http://mysite/legacy/app.properties"); var_export($properties->getAll()); var_export($properties['foo']);
yields:
array (
'foo' => 'bar',
)
loadResource accepts any URL for which there is a supported protocol wrapper, including of course you're own registered streamWrappers. It takes a stream context as an optional second argument.
REQUIREMENTS
- PHP has to be compiled
--with-pcre-regex allow_url_fopen = onfor network streams. This is implied by fopen. Refer to the docs for details.
INSTALLATION WITH COMPOSER
Here are the required entries in your composer.json:
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/classmarkets/JavaProperties.php"
}
],
"require": {
"classmarkets/javaproperties.php": "*"
}
}
After you have added them just run composer.phar update. We currently do not have plans to publish this package on packagist, sorry.
KNOWN LIMITATIONS
- Escaped key-value-delimiters are not supported, e. g.
foo\:bar = bazwill not result in[ 'foo:bar' => 'baz' ], but[ 'foo\' => 'bar = baz' ]. - Lines ending with multiple backslashes are not handled properly. They are treated as if they ended with exactly one backslash.
Patches welcome :)