Download the PHP package jelix/properties-file without Composer
On this page you can find all versions of the php package jelix/properties-file. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jelix/properties-file
More information about jelix/properties-file
Files in jelix/properties-file
Package properties-file
Short Description classes to read and write properties files. Format is similar to Java properties files.
License LGPL-2.1
Homepage http://jelix.org
Informations about the package properties-file
Some classes to read and write properties files.
Properties files are like Java Properties file. The implemented format is using to store locales for an application made with Jelix, a PHP Framework.
installation
The library is compatible from PHP 5.6 to PHP 8.1.
You can install it from Composer. In your project:
Usage
You have two classes: Properties
which is a container for key/value pairs,
a Reader
to parse a properties file and a Writer
to write properties into
a file.
Options for the writer:
lineLength
: maximum length of a line. If the string length is higher, it will be splitted. (default: 120)cutOnlyAtSpace
: to cut lines where there is space, not on the middle of a word (default: true)spaceAroundEqual
: to add or not space around the equal sign (boolean, default: true)headerComment
: to add comment as header (string, default: empty string)removeTrailingSpace
: to remove trailing space on values (boolean, default: false)encoding
: encoding of values to write. (string, default: "UTF-8")
History
The parser is based on a class, jBundle coming from the Jelix Framework until Jelix 1.6, and has been released in 2018 into a separate repository as Jelix\PropertiesFile\Parser.
Format
The file content structure is quite simple. It's basically a key=string
structure, with some improvements.
You can't use double and single quotes to delimit your strings, new lines do this.
Keys can contain characters a
to z
(lowercase/uppercase), numbers and
characters _
, -
, .
.
Here is an example of file:
Multi line
If the text is long and you want to write it in several lines, you can type an
anti-slash \
at the end of each line (excepted the last one of the text), to tell
the parser to continue reading the translated string.
However, it doesn't insert a line break in the displayed string. If you want to
insert a real line break, use \n
or \r
(\r\n
on windows, \n
on linux,
\r
on macs):
Comments
You can also put some comments. They have to begin with a #
. When the parser sees
#
, the rest of the line is ignored. A comment can be at the beginning of a line,
or in the middle of a line, or at the end of the line. If you want to use a #
in a
value, you have to escape it with an anti-slash: \#
.
Whitespaces
Whitespaces before and after a value are ignored. If you want to put a value equal
to a space, you have to use \s
.
The value of space
will be ' '
, and the value of nospace
, an empty string.
You can also use \S
to insert an 'unbreakable' space.
All versions of properties-file with dependencies
ext-mbstring Version >=5.6.0