|Info||Example||View files (5)||Download .zip||Reputation||Support forum (1)||Blog||Links|
|Ratings||Unique User Downloads||Download Rankings|
|Not yet rated by the users||Total: 271||All time: 7,675 This week: 220|
|common-gateway 1.0||BSD License||5.3||PHP 5, Data types|
This package can set and get values of common data structures.
There is a way described here of how to organize common data to be available throughout a program. Common data (also called Global data) in this context are the functions and variables (or methods and properties) accessed during one server request. Permanent data saved between sessions are not covered here. In larger projects, it becomes more important how to manage common data to be easily reachable in any part of the program.
All the common accessing is collected into one point. Thru this point - a gateway - all the global usings can be controlled and observed. The common gateway is realized by two classes: the gateway itself, containing some static properties and methods, and the common data class, holding common methods and properties. Common methods are called from the gateway via __callStatic() magic method. Common properties are accessed via property path methods. Common work area is supplied also for temporary and/or time-critical data. The methods do not check for errors - it's presumed to be an error handling responsibility.
Since the gateway can be referred many times in the program then the names concerning a gateway are selected to be short.
Note. A more rough way would be to implement all the common properties via ¤::$_ but it makes properties vulnerable for occasional over-writings.
Common/Global state is unavoidable when you work with any information, we should not disregard it, but instead we need to decide how to work with it. PHP core functions must be extended by customer ones to perform standard/elemantary actions. Collecting them into one class/object instead of scattering into many classes achieves more comprehensiveness. Certain data (database link, text arrays, configurations etc.), once retrieved or initialized, need to be easily reachable in any part of the project code. Making them centrally accessible releases from a pain to pass frequently-used variables continuously throughout several objects/methods/functions.
The design patterns like DI container, Service Locator, Singletone all allow the same thing - make some data centrally available. The gateway approach is a solution following OOP paradigm as far as possible. Developer is responsible for decision - what is a subject to class or common method/property. The gateway class can be complemented with several functionality to have more control over common data.
The following files are included:
The common data gateway is implemented in vRegistry solutions (see [vregistry.com]).
20 June 2015
07 October 2016
common.php - corrections for the php7 compatibility
|common.php||Class||Common data class skeleton|
|example.php||Example||Typical using samples|
|Version Control||Unique User Downloads||Download Rankings|
|Applications that use this package|
If you know an application of this package, send a message to the author to add a link here.