Download the PHP package deefour/producer without Composer
On this page you can find all versions of the php package deefour/producer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download deefour/producer
More information about deefour/producer
Files in deefour/producer
Package producer
Short Description Simple rule-based class resolution
License MIT
Homepage https://github.com/deefour/producer
Informations about the package producer
Producer
A small class factory.
Getting Started
Run the following to add Producer to your project's composer.json
. See Packagist for specific versions.
>=PHP5.5.0
is required.
Overview
A Producer
is a class that resolves the FQCN of related Producible
classes. The Factory
accepts a Producer
and "type", and can instantiate a concrete Producible
class based on the resolved FQCN returned.
Producers and Producibles
The production factory only accepts classes that implement Deefour\Producer\Contracts\Producer
. An exception will be thrown if the resolved class does not implement Deefour\Producer\Contracts\Producible
.
Given the following classes
the production factory can produce an instance of each producible above when given a podcast and "type".
Resolving Producibles
The default producible resolver on the produciton factory looks like this
This can be customized by implementing a resolve()
method on the producer passed into the factory.
This deefour/producer
package also comes with a more opinionated resolver at Deefour\Producer\ResolvesProducibles
.
this will pluralize the "type" passed in and append that to the namespace of the producer doing the class resolution.
Making Producibles
The default producible instantiator on the production factory looks like this
This can be customized by implementing a make()
method on the producer passed into the factory.
Note: The Deefour\Producer\ResolvesProducibles
trait does not implement the make()
method.
Contribute
- Issue Tracker: https://github.com/deefour/producer/issues
- Source Code: https://github.com/deefour/producer
Changelog
1.0.0 - October 7, 2015
- Release 1.0.0.
0.1.1 - August 8, 2015
- Added
ProductionFactory
interface to allow more lenient type-hinting within other packages. - Docblock cleanup.
0.1.0 - August 4, 2015
- Initial release.
License
Copyright (c) 2015 Jason Daly (deefour). Released under the MIT License.