Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ivantcholakov/codeigniter-registry
Registry library for CodeIgniter
https://github.com/ivantcholakov/codeigniter-registry
codeigniter php registry-library
Last synced: 3 months ago
JSON representation
Registry library for CodeIgniter
- Host: GitHub
- URL: https://github.com/ivantcholakov/codeigniter-registry
- Owner: ivantcholakov
- License: mit
- Created: 2014-01-05T16:19:18.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-04-11T06:01:20.000Z (over 9 years ago)
- Last Synced: 2024-10-02T08:14:07.226Z (3 months ago)
- Topics: codeigniter, php, registry-library
- Language: PHP
- Size: 145 KB
- Stars: 7
- Watchers: 1
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Registry library for CodeIgniter
================================You may use this library for storing and accessing application-level global data.
This library is intended to be compatible with CI 2.x and CI 3.x.Installation
------------Put the file Registry.php within application/libraries/ folder of your project.
Usage Example
-------------```php
//---------------------------------------------------------------------------
// Context #1:$ci = get_instance(); // Use $this instead of $ci inside a controller's method.
$ci->load->library('registry'); // You may autoload this library at will.$title = 'Page Title';
$subtitle = 'Page Subtitle';
$metatitle = 'Page Title (Meta)';
$metadescription = 'Page Description (Meta)';
$metakeywords = 'page, keywords, meta';$ci->registry
// Method chaining is possible.
// Set values individually:
->set('page_title', $title)
->set('page_subtitle', $subtitle)
// Set multiple values.
->set(compact('metatitle', 'metadescription', 'metakeywords'))
;unset($title, $subtitle, $metatitle, $metadescription, $metakeywords);
//---------------------------------------------------------------------------
// Context #2:$ci = get_instance();
$ci->load->library('registry');// Get values individually.
$title = $ci->registry->get('page_title');
$subtitle = $ci->registry->get('page_subtitle');// Get multiple values.
extract($ci->registry->get(array('metatitle', 'metadescription', 'metakeywords')));// Test:
var_dump(compact('title', 'subtitle', 'metatitle', 'metadescription', 'metakeywords'));//---------------------------------------------------------------------------
// Also:// Check whether a particular value is present.
$test = $ci->registry->has('test_key');
var_dump($test);// Gets everything from the registry (for debugging purpose).
$registry = $ci->registry->get_all();
var_dump($registry);// Unset values.
$ci->registry
->delete('page_title')
->delete('page_subtitle')
->delete(array('metatitle', 'metadescription', 'metakeywords'))
;
var_dump($ci->registry->get_all());// Use destroy method only for testing purposes
$ci->registry->destroy();
var_dump($ci->registry->get_all());//---------------------------------------------------------------------------
```License Information
-------------------Author: Ivan Tcholakov [email protected], 2014-2015.
License: The MIT License (MIT), http://opensource.org/licenses/MIT