A simple application 'option' interface
This is a relatively straightforward library for storing and retrieving various "options" in your application. This is great for stuff that is not appropriate for environment variables, but that might not need an entire application model.
You can install this package via composer.
composer require judahnator/option
First thing you need to do is pass what driver you plan to use into the Option class constructor.
For debugging and demonstration purposes, we will use the
MemoryDriver provided with this library. You can also write
your own drivers, there is a section for that later in this readme.
<?php use judahnator\Option\Drivers\MemoryDriver; use judahnator\Option\Option; $option = new Option(new MemoryDriver());
- To get an option:
- To check if an option exists:
- To set (or overwrite) an option:
$option->set('foo', 'foos value')
- To delete an option:
There are two drivers provided by default with this library.
The first accepts an argument for where you want your options stored. The later is purely in-memory, and is best used for only debugging or demonstration purposes.
Creating your own Option driver is simple as well. Create a new class
that extends the
You can now use that as a driver for the Option class.