https://github.com/mixerapi/core
Core library for MixerAPI [READ-ONLY]
https://github.com/mixerapi/core
Last synced: 8 months ago
JSON representation
Core library for MixerAPI [READ-ONLY]
- Host: GitHub
- URL: https://github.com/mixerapi/core
- Owner: mixerapi
- License: other
- Created: 2020-09-05T17:27:59.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-02-17T14:58:57.000Z (almost 2 years ago)
- Last Synced: 2025-04-18T13:20:58.017Z (8 months ago)
- Language: PHP
- Homepage: https://mixerapi.com
- Size: 96.7 KB
- Stars: 3
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# MixerAPI Core
[](https://packagist.org/packages/mixerapi/core)
[](https://github.com/mixerapi/core/actions/workflows/master.yml)
[](https://coveralls.io/github/mixerapi/core?branch=master)
[](http://mixerapi.com)
[](https://book.cakephp.org/4/en/index.html)
[](https://php.net/)
Core library for easily sharing commonly used classes and utilities across MixerAPI plugins. There is likely
minimal value installing this package without the full mixerapi plugin.
This branch is for CakePHP 5.x only. Supported versions:
| Version | Branch | Cake Version | PHP Version |
|---------|------------------------------------------------|--------------|-------------|
| 2.* | master | ^5.0 | ^8.1 |
| 1.* | [v1](https://github.com/mixerapi/core/tree/v1) | ^4.2 | ^8.0 |
## Installation
```console
composer require mixerapi/core
```
See the CakePHP documentation for [loading plugins](https://book.cakephp.org/5/en/plugins.html).
### Event Listener Loader
The Event Listener Loader will automatically load all listeners which implement `Cake\Event\EventListenerInterface`
within a given namespace. Example:
```php
# src/Application.php
use Cake\Http\BaseApplication;
use MixerApi\Core\Event\EventListenerLoader;
class Application extends BaseApplication
{
public function bootstrap(): void
{
// ...other code
(new EventListenerLoader())->load();
// other code...
}
}
```
The default behavior loads all listeners in `App\Event`. You can pass a different namespace argument
as `load($namespace)` if your listeners are located elsewhere.
### Namespace Utility
Returns one or more classes in a given namespace.
```php
use MixerApi\Core\Utility\NamespaceUtility;
$controllers = NamespaceUtility::findClasses('\App\Controller');
```
By default, this will load classes from your `src/` and `plugin/*/src` directories. This should be left as-is unless
your application has a very specific need. You can override the default file path list if necessary.
```php
use MixerApi\Core\Utility\NamespaceUtility;
$controllers = NamespaceUtility::findClasses('\App\Controller', ['/absolute/path/to/src']);
```