Indicate if the reader can read a file.
Get the list of supported file extension
Reader a file.
The abstract implement the method canRead
.
Get the content of a file with file lock. This prevent reading a file while an other process is writing it (The writting process need to use lock too).
IniReader
, read Ini and Properties files (.ini
,.properties
)JsonReader
, read Json files (.json
)NeonReader
, read Neon files (.neon
)PhpReader
, read PHP files (.php
)XmlReader
, read XML files (.xml
)YamlReader
, read YAML files (.yml
,.yaml
)
The Ini (.ini
) format is the same than the one use in php.ini.
It support [Section]
naming.
The Properties (.properties
) format is the same as Ini format. the extension is used in Java application.
Example, database.ini
[mysql]
host = localhost
username = root
password = root
port = 3306
dbname = app
[sqlite]
file = db.sqlite
The Json (.json
) format.
Example, database.json
{
"mysql": {
"host": "localhost",
"username": "root",
"password": "root",
"port": 3306,
"dbname": "app"
},
"sqlite": {
"file": "db.sqlite"
}
}
The Neon (.neon
) format. The format was created by Nette Framework.
It's syntax is very similar to Yaml, but less complex.
Example, database.neon
mysql:
host: localhost
username: root
password: root
port: 3306
dbname: app
sqlite:
file: db.sqlite
To use this format, you need to add nette/neon
to your project
The Php (.php
) format.
The file must return an array.
Example, database.php
<?php
return array(
"mysql" => array(
"host" => "localhost",
"username" => "root",
"password" => "root",
"port" => 3306,
"dbname" => "app"
),
"sqlite" => array(
"file" => "db.sqlite"
)
);
The Xml (.xml
) format.
Example, database.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<mysql>
<host>localhost</host>
<username>root</username>
<password>root</password>
<port>3306</port>
<dbname>app</dbname>
</mysql>
<sqlite>
<file>db.sqlite</file>
</sqlite>
</config>
The tag name of the first tag (config
in the example) can be anything, but prefer config
as it's have more meaning for the human reader.
The Yaml (.yml
, .yaml
) format
Example, database.yml
mysql:
host: localhost
username: root
password: root
port: 3306
dbname: app
sqlite:
file: db.sqlite
To use this format, you need to add symfony/yaml
to your project