palmero/withforks

Make your own container classes

Installs: 332

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/palmero/withforks

v1.0.0 2018-12-27 18:42 UTC

This package is auto-updated.

Last update: 2025-09-28 09:40:29 UTC


README

A PSR-11 class-inheriting implementation

Example

use Palmero\Withforks;

class Container extends Withforks {

	protected function getSomeClass() {
		return new SomeClass(
			$this->getSettings()['someClass']
		);
	}

	protected function getSomeOtherClass() {
		return new SomeOtherClass(
			$this->getSettings()['someOtherClass']
		);
	}

}

To instantiate the container, just pass it an associative array with the configs required for each method:

$container = new Container([
	'someClass' => [
		'config' => true
	],
	'someOtherClass' => [
		'config' => "something"
	],
]);

You can access everything...:

  • The PSR-11 way: $container->has('someClass') and $container->get('someClass')
  • The Withforks way: $container->someClass