-
Notifications
You must be signed in to change notification settings - Fork 0
Getting Started
In web based application engineering, the singleton pattern is a design pattern that restricts the instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the system. The concept is sometimes generalized to systems that operate more efficiently when only one object exists, or that restrict the instantiation to a certain number of objects. The term comes from the mathematical concept of a singleton.
With the singleton pattern make all the libraries of classes and properties into one super global object without instantiation.
O2Glob is a part of O2System Core Framework that published as a standalone Mini Singleton Framework. With O2Glob make you more easier to built an application with super global object support and also has additional magic functionality.
- To do this first, you must has composer installation at your server. Please read the manual, documentation on the composer website for more details.
- Open php shell and write (for further information about the package please visit O2Glob Packagist Page
php cd your/public/www/
php composer require: "o2system/o2glob:rc-1.*"
1: Create your first application structure like this example (recommended)
- App
--- Controllers
--- Libraries
--- vendor
- O2Glob
- index.php
- .htaccess
2: Copy and paste this code bellow into your index.php file
/*
*---------------------------------------------------------------
* APPLICATION ROOT PATH
*---------------------------------------------------------------
*/
// Path to base path folder
define('ROOT_PATH', str_replace("\\", '/', pathinfo(__FILE__, PATHINFO_DIRNAME).'/'));
/*
* --------------------------------------------------------------------
* LOAD O2GLOB
* --------------------------------------------------------------------
*/
require_once ROOT_PATH.'O2Glob/O2Glob.php';
That's all, and now you can started to create your application
Edit your composer.json file and run composer update at your php shell
require : {
"o2system/o2glob" : "rc-1.*"
}
Or you can download the zip file of O2Glob and extract it into your third_party folder of your application or your framework
Now let's learn, how to easily built a Singleton Class and learn how to call a class methods and properties.