Download the PHP package ibnusyuhada/slim-lite-configuration without Composer
On this page you can find all versions of the php package ibnusyuhada/slim-lite-configuration. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ibnusyuhada/slim-lite-configuration
More information about ibnusyuhada/slim-lite-configuration
Files in ibnusyuhada/slim-lite-configuration
Package slim-lite-configuration
Short Description Slim Lite Configuration is a file(s) configuration loader for Slim Framework Middleware. Just say the file(s), then Slim Lite Configuration will register the configuration items automatically to Slim settings. This package support with Ini, Php, Json, Xml, Yaml format. If need to change the configuration file, this package can do as you want.
License MIT
Informations about the package slim-lite-configuration
Slim Lite Configuration
Slim Lite Configuration is a file(s) configuration loader for Slim Framework Middleware. Just say the file(s), then Slim Lite Configuration will register the configuration items automatically to Slim settings. This package support with Ini, Php, Json, Xml, Yaml format. If need to change the configuration file, this package can do as you want.
Requirements
Slim Lite Configuration requires PHP 5.3+ and works for Slim Framework v3.0.0 or above.
Installation
The easiest way to installing Slim Lite Configuration is via Composer
Usage
Slim Lite Configuration designed to be simple to use in Slim Framework. You only register the file(s) or directory of config file(s), then configuration immediately ready for use. When you need to change the items of configuration in a file, just say the path file. Internally uses hassankhan config.
Loading Files
Slim Lite Configuration able to load one file or multiple files or optional files at same time. Rather than say the file name one by one, you can add the directory of files then configuration ready to use. Initially register Slim Lite Configuration to container
Register Per Route
As middleware, after register Slim Lite Configuration into container, then we can register all items of configuration in specific route.
Register For All Routes
But, if you want all configuration are available for all routes, just do like code below
Write Or Update Configuration File
You are allowed to create a file of configuration if the request file is not exist. But you will get update if file configuration is exist. Here is the example usage in concept Slim Lite Configuration for all routes:
Access All Configuration Items
Let say we have a file config.yaml like below
In design, all items of configuration will be placed in Slim settings and Slim Lite Configuration container. So, when we want to get all items of configuration we can do with two possible ways in a route
or
Access Specific Configuration Item
In fact, when we want to access specific item of configuration, it can be done with two possible ways in a route as well
or
Set Configuration Item
Set new value of an item(s), there are two possible ways in a route, first is by using this way
In this way, Slim Lite Configuration only update the container but not Slim settings. The second way by update file configuration like explained above.
Safe Memory Usage
Like explained above, Slim Lite Configuration will save the items of configuration in Slim settings and container. This will need more usage of computer memory. So to safe the memory, we can to remove Slim Lite Configuration from container by placed the code below
elsewhere after
do this way will not destroy Slim settings.
Benefits
Conceptually, it is reasonable if configuration items are set in settings. It is means configuration should put in Slim settings. In Slim Lite Configuration, all items of configuration are appended in Slim settings. So basically, when you destroy Slim Lite Configuration from container, Slim settings will not change and the configuration is still exist. This is very useful, because we only focus on access of configuration via Slim settings only and of course we can safe memory. There is a condition where specific request URI has different configuration, and at this point Slim Lite Configuration as middleware is able to do this condition.
Testing
Credits
License
The MIT License. See the License
All versions of slim-lite-configuration with dependencies
hassankhan/config Version ^0.10.0
league/flysystem Version ^1.0
spatie/array-to-xml Version ^2.1
symfony/yaml Version ^3.1