JSON for storing application configurations
Prior to JSON becoming popular, configurations were either stored in a text file or in language-specific files, such as config.php
for PHP, config.py
for Python, and config.js
for JavaScript. All these can now be replaced by a language-independent config.json
file; use a JSON library for non-JavaScript libraries to parse it.
Configuration in PHP and Python
Let's take a quick look at an example config.json
file:
In the config.json
file, we store the metadata as a JSON object. We are specifying important information such as the project name, the environment of the project (which varies based on the server that the file is located on), any classes that have to be autoloaded during bootstrapping the application, and any classes or folders that we would want to exclude. Finally, using the RECURSIVE
key, we also specify that there are folders and those folders have files.
Note
Bootstrapping is the startup process for an application, in which we prepare that...