PHP REGISTRY
developed by Richard Standbrook
Released under the GLP

CHANGELOG

Download:

Homepage:

Topics:

 


USING THE PHPREG EDITOR
Back to topics

A) Set up the registry editor

  1. Create a new file (phpregedit.php for instance). Make sure it is somewhere safe, password protected.
  2. Add the following code;

    <?php
    include('phpreg.php');
    $regedit = new phpregedit;

    $regedit->editor();
    ?>

  3. Browse to this file on your server. You will now be shown an interface
    that will allow you to add and edit keys.

B) Adding keys using the editor

  1. Browse to the phpregedit.php file on your server.
  2. Type in the path to the registry file.
    1. You can create a new file by entering a filename that doesnot exist

      NOTE THAT PHPREG CANNOT CREATE SYSTEM DIRECTORIES

  3. At the top of the editor there are two text boxes, one button and a checkbox

    1. The first text box is the KEY, how you will identify the registry key.
      This could be one word `GLOBALS` for instance, or a deep key `GLOBAL/DB/USERNAME` this structure
      will be set up automaticly.

    2. The second text box is the value, what they key is this can be any characters.

    3. The button will post the form to set the key

    4. The checkbox can be ticked before submiting, to make the KEY an extension of the CURRENT path
      if you are in the path `GLOABLS` and you set a key `DB` with the `extend key` box ticked this will
      cause the structure `GLOBALS/DB` to be setup, you can the browse to `GLOBALS/DB` and set keys like, `host` etc

C) Editing keys

  1. Follow steps 1 and 2 in part B.
  2. To edit a value, locate the key, and change its value in the text box next to it.
  3. Click the `update keys` button in the bottom right.

D) Deleting Keys

  1. Same as C
  2. Tick the checkbox next to any keys you wish to remove
  3. Click the `delete keys` button at the bottom left.

    NOTE THAT ANY AND ALL CHILD KEY WILL BE REMOVED TO

 

USING PHPREG IN YOUR APPLICATIONS
Back to topics

A) Opening a phpreg file

  1. Add the following code to your application, replace reg_file with the path to and name of your file
    if the file does not exsit, phpreg will atempt to create it.

    NOTE THAT PHPREG CANNOT CREATE SYSTEM DIRECTORIES

    <?php

    include('phpreg.php');
    $reg = new phpreg;

    $reg->open("reg_file");

    ?>


B) Defining existing keys

  1. Follow the steps in A to open your file
  2. Add the following code

    $reg->define_keys();

    Any keys you have previously set will be defined as constants for example, if you set up a structure such as;
    |- GLOBAL/ 
    ¦       |- DB/ 
    ¦       |- USER = root
    ¦ |- HOST = localhost ¦ |- VERSION = 0.1.2
    ¦
    To access the key USER for the database you would do the following.

    echo constant("GLOBALS/DB/USER");

    This would out put "root". You cannot call extended keys like this;

    echo GLOBALS/DB/USER;

    The foward slashes `/` will trip up PHP and cause an error. However, if you were to use a root level key you can call it without the constant() function using the structure above the following is posible

    echo VERSION

    This would output "0.1.2"

C) Setting a new, or changing an exsiting, key

  1. Follow the steps to open a file in part A
  2. Use the following code to add a new key

    $reg->set_key("KEY_ID","key value");

    you can also use the following

    $reg->set_key("EXTENDED/KEY_ID","key value");

    The structure is automatically set up.

    Leaving the VALUE blank

    $reg->set_key("KEY_ID");

    Will create a extended key, this can also be done in the follwing way

    $reg->set_key("EXTENDED/KEY_ID");

    TO BE ABLE TO USE CONSTANTS OFKEYS SET WITH set_key() YOU MUST NEXT CALL define_keys()


D) Delete a key

  1. Open a file (see A)
  2. The following will work with keys from the file and any set with set_key()

    NOTE THAT ANY AND ALL CHILD KEY WILL BE REMOVED TO

    $reg->delete_key("KEY_ID");

    Also use the extened format

    $reg->delete_key("EXTEND/KEY_ID");


E) Saving the phpreg file

Up till now all the actions in "USING PHPREG IN YOUR APPLICATIONS"
have been on the `running reg`, that is nothing has been saved to a file.
when all changes have been made (or, indeed, when ever you want)
you can use

$reg->save("reg_file");

Replacing `reg_file` with the path and name of the file to save to.
if the file doesnt exsist phpreg will attempt to create it

NOTE THAT PHPREG CANNOT CREATE SYSTEM DIRECTORIES