Sunday, August 25, 2019
Home > php scripts > Registry Elegance

Registry Elegance

Value: five$
Score: three.75


This script is supposed to retailer and retrieve variables in a central position. The values can also be saved in 3 ways.

  1. Temp: Variables are available withing one script execution (like customary variables).
  2. Consultation: Variables which are available from all of the pages for one consumer (stored in consultation).
  3. Utility: Variables are accesible for all customers from all pages (stored in report).

This fashion you might have your entire variables in a single position and feature a central position the get and set your other form of variables.


  • Set and retrieve variables with the similar means.
  • Static strategies really easy to make use of
  • Binding variables within the registry to stay a reference 
  • Set and get to/from periods/report/variables with the similar means
  • Auto serializing of arrays and gadgets sooner than stored to report

How one can use

The elegance is really easy to make use of as it makes use of static strategies and makes use of the singleton trend so there’s all the time just one example from the category.

For instance we need to save the username in a consultation so it’s available from each web page for your web page.

Registry::Set("username", "Sitebase", Registry::VAR_SESSION);

If I now need to get right of entry to the username of the present consumer. You do that:

echo Registry::Get("username");

A 2d instance is surroundings a variable this is available on each web page and for each customer at the web page. The variables are saved in a ini report (in upcoming free up it’s going to even be imaginable to avoid wasting to database). First we want to upload a driving force for the Ini report to the registry. This you do as soon as for your index.php report.

$Motive force = new Registry_Drivers_Ini();
$Motive force->SetFile("knowledge.ini");
Registry::SetDriver($Motive force);

To save lots of a variable to the ini report you do that:

Registry::Set("localhost", "host", Registry::VAR_APPLICATION);

If I now need to get right of entry to the the host variable you do that:

echo Registry::Get("host");

If you employ an array or object as variable then those will automaticly be serialized sooner than saving to the ini report. This fashion you’ll save no matter form of variable you wish to have within the ini report.

Purchase Now