mixerapi/core

MixerAPI Core libraries

Maintainers

Details

github.com/mixerapi/core

Source

Issues

Installs: 111 598

Dependents: 5

Suggesters: 0

Security: 0

Stars: 3

Watchers: 2

Forks: 3

Open Issues: 0

Type:cakephp-plugin

v2.0.1 2024-02-17 14:57 UTC

README

Latest Version on Packagist Build Coverage Status MixerApi CakePHP Minimum PHP Version

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:

Installation

composer require mixerapi/core

See the CakePHP documentation for loading plugins.

Event Listener Loader

The Event Listener Loader will automatically load all listeners which implement Cake\Event\EventListenerInterface within a given namespace. Example:

# 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.

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.

use MixerApi\Core\Utility\NamespaceUtility;

$controllers = NamespaceUtility::findClasses('\App\Controller', ['/absolute/path/to/src']);