Download the PHP package spiffy/spiffy-inject without Composer

On this page you can find all versions of the php package spiffy/spiffy-inject. 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 spiffy-inject

Spiffy\Inject

Build Status Code Coverage Scrutinizer Code Quality

Installation

Spiffy\Inject can be installed using composer which will setup any autoloading for you.

composer require spiffy/spiffy-inject

Additionally, you can download or clone the repository and setup your own autoloading.

Introduction

Spiffy\Inject is a light-weight, HHVM compatible, and dependency lite dependency injection (DI) container. You can read more about DI on Wikipedia or Martin Fowler's website. Spiffy\Inject aims to help you manage your parameters and services.

Parameters

Services

The primary purpose of Spiffy\Inject is for managing your services. You can create services in one of three ways:

All services are set through the nject method regardless of which style you choose. Each style has it's own advantages and disadvantages. It's you to you to decide which is the best approach to take for your application.

Setting Services

Testing if a service exists

Getting Services

Array Configuration

The array configuration has some additional options available to make it extremely flexible.

Constructor injection

Setter injection

Referencing other services and parameters

Spiffy\Inject's array configuration includes the ability to reference other services when the string is prepended with special characters. By default you reference services with the @ symbol and parameters with the $ symbol. These can be modified using the setServiceIdentifier and setParamIdentifier methods respectively.

ServiceFactories

If you return an instance of Spiffy\Inject\ServiceFactory from an array configuration it will automatically create the instance for you and return that instead. This let's you inject parameters into Service Factories easily and reuse factories while still returning the instance you want.

Annotations combined with a generator

SpiffyInject provides annotations that you can use to assist in creating configurations for services.

Now that you have an annotated class use the metadata factory to create metadata for the class and a generator to generate the Injector configuration.

Reading files, creating metadata, and generating configuration is a heavy process and is not intended for production. You should cache the results of the generation and use the cache in production.

Decorating your services

Sometimes you want to over-ride the services set your DI container without modifying the original configuration. Spiffy\Inject handles this by providing you with two types of decorators.

Decorate

The decorate method allows you to take the service created and apply any modifications to it prior to having it returned. The decorate closure receives the injector and service as arguments.

Alternatively, you can provide an instance of a class implementing the Spiffy\Inject\ServiceDecorator interface:

Wrap

The wrap method is much more powerful than decorate. Wrapping let's you completely change the object that's created or completely bypass the original configuration. The wrap closure receives three arguments: the injector, the name of the service, and the callable that creates the service.

Alternatively, you can provide an instance of a class implementing the Spiffy\Inject\ServiceWrapper interface:

Why nvoke and nject?

Because it's damn cute, that's why! If you prefer, though, you can use set() instead as nject() and get() instead of nvoke().


All versions of spiffy-inject with dependencies

PHP Build Version
Package Version
Requires doctrine/annotations Version ~1.1
php Version >=5.4
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 spiffy/spiffy-inject contains the following files

Loading the files please wait ....