48468437 by Joshua Tundag

update README.md

1 parent 3a9aa681
Showing 1 changed file with 74 additions and 4 deletions
......@@ -3,18 +3,25 @@ Flag Manager for Baytech Sites.
## Define Flag Directory in your constants.php file
```
define('DEFAULT_PPG', '14');
```php
define('FLAGS_DIR', '<Desired directory to store flags.json file>');
```
## Initialize Flag Manager
```php
$flagManager = new \BTFlags\FlagManager();
```
## Register Flags
```php
$flagManager = new \BTFlags\FlagManager();
$flagManager->register();
```
### Data Structure
```
```php
$requestData = array(
'name' => null|string,
'is_encrypyed' => true|false,
......@@ -29,8 +36,28 @@ $requestData = array(
);
```
## CRUD
#### Tip:
```php
// application/config/hooks.php
$hook['post_controller_constructor'][] = array(
'class' => 'Flag',
'function' => 'register',
'filename' => 'Flag.php',
'filepath' => 'hooks',
);
// application/hooks/Flags.php
class Flag{
public function register(){
$flagManager = new \LawFormsUSA\Flags\FlagManager();
$flagManager->register();
}
}
```
## CRUD
```php
// Create a Flag
$created = $flagManager->create($requestData);
......@@ -42,4 +69,47 @@ $updated = $flagManager->update($requestData);
// Get all Flags
$flags = $flagManager->all();
```
## Retrieving a flag
```php
// Parameters:
// $flagName: String = Name of the flag.
// (Optional) $encrypted: bool = If the inputted $flagName is encrypted, set this to true, otherwise, false.
// (Optional) $default: String = Default value if flag is empty.
// (Option) $driver: String = Driver (cookie or session).
\BTFlags\Flags::get($flagName, [$encrypted, $default, $driver]);
```
#### Example Usage:
```php
// Getting an encrypted flag
// Example Flag:
// Name:
// 'mode' => 'edom'
// Accepted Values:
// 'live' => 'prod'
// 'test' => 'dev'
\BTFlags\Flags::get('edom', true);
// Getting a non-encrypted flag
\BTFlags\Flags::get('source');
```
#### Tip:
```php
// utility_helper.php
if (!function_exists('flag')){
function flag($flag, $default = null, $encrypted = false){
return \BTFlags\Flags::get($flag, $encrypted, $default);
}
}
// Use anywhere:
flag('mode');
flag('source');
flag('pmt', 'rec');
```
\ No newline at end of file
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!