Skip to content

This simple PHP class, `JsonConfigWrapper`, allows you to easily manage a JSON configuration file by providing methods for reading, updating, adding, and deleting configuration settings.

License

Notifications You must be signed in to change notification settings

Francois284Modz/JsonConfigWrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

JSON Configuration Wrapper

This simple PHP class, JsonConfigWrapper, allows you to easily manage a JSON configuration file by providing methods for reading, updating, adding, and deleting configuration settings.

Usage

  1. Include the JsonConfigWrapper class in your PHP project:

    include 'JsonConfigWrapper.php';

2.Initialize the JsonConfigWrapper with the path to your JSON configuration file:

$configFile = 'config.json';
$configWrapper = new JsonConfigWrapper($configFile);

3.Read the configuration settings:

$configData = $configWrapper->read();
  1. Retrieve a specific configuration setting:
    $websiteName = $configWrapper->retrieve('name');
  2. Modify a specific configuration setting:
    $configWrapper->create('name', 'New Website Name');
  3. Delete a specific configuration setting:
    $configWrapper->delete('name');
    7.Update the configuration
   settings:$configData['title'] = 'New Website Title';
$configWrapper->update($configData);

Example

// Initialize the wrapper with the path to your JSON config file
$configFile = 'config.json';
$configWrapper = new JsonConfigWrapper($configFile);

// Read the configuration settings
$configData = $configWrapper->read();

// Retrieve a specific configuration setting
$websiteName = $configWrapper->retrieve('name');

// Modify a specific configuration setting
$configWrapper->create('name', 'New Website Name');

// Delete a specific configuration setting
$configWrapper->delete('name');

// Update the configuration settings
$configData['title'] = 'New Website Title';
$configWrapper->update($configData);

This class makes it easy to manage your JSON configuration file dynamically within your PHP application.Feel free to customize the usage instructions and example as needed for your specific project.

About

This simple PHP class, `JsonConfigWrapper`, allows you to easily manage a JSON configuration file by providing methods for reading, updating, adding, and deleting configuration settings.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published