vpg / titon.common
The Titon common package provides global functionality like class traits and augmentation as well as dependency and configuration management.
Installs: 7 923
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 9
Forks: 0
Open Issues: 0
Requires
- php: >=5.4.0
- vpg/titon.utility: ^1.2
Replaces
- titon/common: *
This package is not auto-updated.
Last update: 2024-10-26 16:15:35 UTC
README
Provides common functionality for external packages, such as dependency management through registries and containers, global configuration with a static configuration management layer, and a base class for all modular abstract classes to inherit.
On top of those features, the common package provides multiple traits that allow horizontal inheritance of powerful patterns that solve basic use cases, like caching within class instances, class configurations, class dependencies, and more. Classes can be further enhanced through augmentations, which are self contained inner classes.
For example, we can inherit common class functionality like serialization, configuration, and more.
class Object extends Titon\Common\Base { use Titon\Common\Attachable, \\ Provides lazy-loaded inner class dependencies Titon\Common\Cacheable, \\ Provides memoization (method caching) Titon\Common\Instanceable; \\ Provides multiton instance support }
We can also lazy-load dependencies through the registry.
use Titon\Common\Registry; Registry::register('foo.bar', function() { return new Foo\Bar(); }); $foobar = Registry::get('foo.bar'); $foobar = Registry::factory('Foo\Bar'); // by namespace
And finally, configuration management has never been easier.
use Titon\Common\Config; Config::set('foo.bar', 'baz'); $baz = Config::get('foo.bar');
Features
Base
- Primary base classTraits
- Horizontal inheritanceAugments
- Class functionality encapsulationRegistry
- Static dependency containerContainer
- Dependency containerConfig
- Configuration management
Dependencies
Utility
Io
(optional for Config)
Requirements
- PHP 5.4.0