https://github.com/loadsys/cakephp-libregistry
Provides a non-Cake registry singleton to store and load library class instances across a Cake app. Similar to TableRegistry, but for stand-alone PHP libraries.
https://github.com/loadsys/cakephp-libregistry
Last synced: 7 months ago
JSON representation
Provides a non-Cake registry singleton to store and load library class instances across a Cake app. Similar to TableRegistry, but for stand-alone PHP libraries.
- Host: GitHub
- URL: https://github.com/loadsys/cakephp-libregistry
- Owner: loadsys
- License: mit
- Created: 2015-08-04T19:56:21.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-09-29T16:23:03.000Z (over 9 years ago)
- Last Synced: 2025-04-04T20:51:19.391Z (10 months ago)
- Language: PHP
- Size: 22.5 KB
- Stars: 2
- Watchers: 9
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# CakePHP LibRegistry Plugin
[](https://packagist.org/packages/loadsys/cakephp-libregistry)
[](LICENSE.md)
[](https://travis-ci.org/loadsys/CakePHP-LibRegistry)
[](https://coveralls.io/r/loadsys/cakephp-libregistry)
[](https://packagist.org/packages/loadsys/cakephp-libregistry)
The LibRegistry provides a mechanism for loading and storing instances of non-Cake PHP libraries. It works a lot like Cake 3's `TableRegistry`. Object instances can be requested by name and instantiated automatically, or can be loaded into the registry manually.
## Requirements
* CakePHP 3.0+
## Installation
### Composer
````bash
$ composer require loadsys/cakephp-libregistry:~1.0
````
## Usage
* Invoke the LibRegistry statically:
```php
'here']);
// (Where the class `src/Lib/MyObj.php` exists.)
$myObj->doSomethingNeat();
}
}
```
* A trait is also provided to load libraries into existing classes:
```php
loadLib('MyObj', ['configs' => 'here']);
$this->MyObj->doSomethingNeat();
// Works like loadComponent() in this context.
}
}
```
### Library classes
* Must exist in `src/Lib/` in your Cake app or plugin and must be namespaced appropriately.
* Must accept a single array of config values as the sole `__construct()` argument. Libraries that don't conform to this interface can't be instantiated via `LibRegistry::get()`, although they can still be stored in the Registry manually via `::set()`.
## Contributing
### Code of Conduct
This project has adopted the Contributor Covenant as its [code of conduct](CODE_OF_CONDUCT.md). All contributors are expected to adhere to this code. [Translations are available](http://contributor-covenant.org/).
### Reporting Issues
Please use [GitHub Isuses](https://github.com/loadsys/CakePHP-LibRegistry/issues) for listing any known defects or issues.
### Development
Please fork and issue a PR targeting the `master` branch for any new development.
The full test suite for the plugin can be run via this command:
```shell
$ vendor/bin/phpunit
```
Code must conform to the Loadsys coding standard, which is based on the CakePHP coding standard:
```shell
$ vendor/bin/phpcs --config-set installed_paths vendor/cakephp/cakephp-codesniffer,vendor/loadsys/loadsys_codesniffer
$ vendor/bin/phpcs -p --standard=Loadsys src
```
## License
[MIT](https://github.com/loadsys/CakePHP-LibRegistry/blob/master/LICENSE.md)
## Copyright
[Loadsys Web Strategies](http://www.loadsys.com) 2016