PHPackages                             jelix/properties-file - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. jelix/properties-file

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jelix/properties-file
=====================

classes to read and write properties files. Format is similar to Java properties files.

v1.2.3(3y ago)3110.6k↓29.4%[4 issues](https://github.com/jelix/properties-file/issues)2LGPL-2.1PHPPHP &gt;=5.6.0

Since Oct 11Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/jelix/properties-file)[ Packagist](https://packagist.org/packages/jelix/properties-file)[ Docs](http://jelix.org)[ RSS](/packages/jelix-properties-file/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (7)Used By (2)

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](https://jelix.org), a PHP Framework.

installation
============

[](#installation)

The library is compatible from PHP 5.6 to PHP 8.1.

You can install it from Composer. In your project:

```
composer require "jelix/properties-file"

```

Usage
=====

[](#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.

```
use \Jelix\PropertiesFile\Properties;
use \Jelix\PropertiesFile\Parser;
use \Jelix\PropertiesFile\Writer;

$properties = new Properties();

$reader = new Parser();
$reader->parseFromFile('file.properties', $properties);

$value = $properties->get('a_key');
$value = $properties['a_key'];

$properties->set('a_key', 'new_value');
$properties['a_key'] = 'new_value';

$writer = new Writer();
$writer->writeToFile($properties, 'file.properties');

// with a limit of line length (default is 120)
$writer->writeToFile($properties, 'file.properties',
                    array("lineLength"=>80));
```

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
=======

[](#history)

The parser is based on a class, jBundle coming from the [Jelix Framework](http://jelix.org)until Jelix 1.6, and has been released in 2018 into a separate repository as Jelix\\PropertiesFile\\Parser.

Format
======

[](#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:

```
title.offlineElements = elements to check
title.onlineElements = online elements
buttons.save = Save
buttons.ok=Ok
```

Multi line
----------

[](#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.

```
intro=this is a very very\
long text in\
several lines
message=this is a regular line
```

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):

```
intro=this is a very very \
long text in\nseveral lines, but in\n one line\nin the source
```

Comments
--------

[](#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)

Whitespaces before and after a value are ignored. If you want to put a value equal to a space, you have to use `\s`.

```
nospace= #this is using a regular space
space= \s#this is using a \s space
```

The value of `space` will be `' '`, and the value of `nospace`, an empty string.

You can also use `\S` to insert an 'unbreakable' space.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~271 days

Recently: every ~339 days

Total

6

Last Release

1419d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ae8142be36568660282368ce7c1eec904ecbc515ab5b58c759a487f3a6f1d114?d=identicon)[laurentj](/maintainers/laurentj)

![](https://www.gravatar.com/avatar/baa42c7323bbc9245b0c70f770031383879941a1a813f678f2835699fd50b375?d=identicon)[mdouchin](/maintainers/mdouchin)

---

Top Contributors

[![laurentj](https://avatars.githubusercontent.com/u/336034?v=4)](https://github.com/laurentj "laurentj (19 commits)")

---

Tags

filesproperties

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jelix-properties-file/health.svg)

```
[![Health](https://phpackages.com/badges/jelix-properties-file/health.svg)](https://phpackages.com/packages/jelix-properties-file)
```

###  Alternatives

[lorisleiva/lody

Load files and classes as lazy collections in Laravel.

956.6M9](/packages/lorisleiva-lody)[wapmorgan/file-type-detector

Detects file type by filename or content and generates correct mimetype.

35367.8k2](/packages/wapmorgan-file-type-detector)[mediawiki/semantic-extra-special-properties

Provides extra special properties for Semantic MediaWiki

3074.6k1](/packages/mediawiki-semantic-extra-special-properties)[colinodell/indentation

Library to detect and manipulate indentation in strings and files

3911.5k5](/packages/colinodell-indentation)[vanilo/properties

Vanilo Properties (Attributes) Module

11105.2k2](/packages/vanilo-properties)[antares/accessible

PHP library that allows you to define your class' getters, setters and constructor with docblock annotations.

123.9k1](/packages/antares-accessible)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
