Download the PHP package locomotivemtl/charcoal-factory without Composer

On this page you can find all versions of the php package locomotivemtl/charcoal-factory. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package charcoal-factory

Charcoal Factory

Factories create (or build) dynamic PHP objects. Factories can resolve a type to a FQN and create instance of this class with an optional given set of arguments, while ensuring a default base class.

Build Status

Table of contents

How to install

The preferred (and only supported) way of installing charcoal-factory is with composer:

Dependencies

👉 Development dependencies, which are optional when using charcoal-factory, are described in the Development section of this README file.

Factories

Usage

Factories have only one purpose: to create / instanciate new PHP objects. Factory options should be set directly from the constructor:

Constructor options (class dependencies) are:

Name Type Default Description
base_class string '' Optional. A base class (or interface) to ensure a type of object.
default_class string '' Optional. A default class, as fallback when the requested object is not resolvable.
arguments array [] Optional. Constructor arguments that will be passed along to created instances.
callback Callable null Optional. A callback function that will be called upon object creation.
resolver Callable null[1] Optional. A class resolver. If none is provided, a default will be used.
resolver_options array null Optional. Resolver options (prefix, suffix, capitals and replacements). This is ignored / unused if resolver is provided.

[1] If no resolver is provided, a default \Charcoal\Factory\GenericResolver will be used.

The resolver

The type (class identifier) sent to the create() method can be parsed / resolved with a custom Callable resolver.

If no resolver is passed to the constructor, a default \Charcoal\Factory\GenericResolver is used. This default resolver transforms, for example, my/custom/foo-bar into \My\Custom\FooBar.

Class map / aliases

Class aliases can be added by setting them in the Factory constructor:

Ensuring a type of object

Ensuring a type of object can be done by setting the base_class property.

The recommended way of setting the base class is by setting it in the constructor:

👉 Note that Interfaces can also be used as a factory's base class.

Setting a default type of object

It is possible to set a default type of object (default class) by setting the default_class property.

The recommended way of setting the default class is by setting it in the constructor:

⚠ Setting a default class name changes the standard Factory behavior. When an invalid class name is used, instead of throwing an Exception, an object of the default class type will always be returned.

Constructor arguments

It is possible to set "automatic" constructor arguments that will be passed to every created object.

The recommended way of setting constructor arguments is by passing an array of arguments to the constructor:

Executing an object callback

It is possible to execute an object callback upon object instanciation. A callback is any Callable that takes the newly created object by reference as its function parameter.

The recommended way of adding an object callback is by passing a Callable to the constructor:

Development

To install the development environment:

To run the scripts (phplint, phpcs and phpunit):

Development dependencies

Continuous Integration

Service Badge Description
Travis Build Status Runs code sniff check and unit tests. Auto-generates API documentation.
Scrutinizer Scrutinizer Code Quality Code quality checker. Also validates API documentation quality.
Coveralls Coverage Status Unit Tests code coverage.
Sensiolabs SensioLabsInsight Another code quality checker, focused on PHP.

Coding Style

All Charcoal modules follow the same coding style and charcoal-factory is no exception. For PHP:

Coding style validation / enforcement can be performed with composer phpcs. An auto-fixer is also available with composer phpcbf.

Authors

License

Charcoal is licensed under the MIT license. See LICENSE for details.

Changelog

0.3.2

0.3.1

Released 2016-03-22

0.3

Released 2016-01-28

0.2

Released 2016-01-26

Minor (but BC-breaking) changes to Charcoal-Factory

0.1

Released 2015-11-25


All versions of charcoal-factory with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package locomotivemtl/charcoal-factory contains the following files

Loading the files please wait ....