Config

It’s time to have a config class, so we can configure our project without changing code.
You should change your code only if you have to fix bugs or expand/adjust your logic, but not if you want to have other configurations (e.g. path to logfile, debug mode, etc…).

In this class we will read the configuration from an xml file.

Let’s create the default config file (this must be always there). When created copy the file and rename it to Config.xml.

PROJECT_ROOT/vendor/PHPluz/etc/config/Config.default.xml

Now we need a class that reads the Config.xml file and creates the constants.
PROJECT_ROOT/vendor/PHPluz/Config.php

After reading the configuration file we have something similar to this:

Leave a Reply