Download the PHP package molajo/ioc without Composer

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

======= Inversion of Control (IoC) Package

Build Status

The Molajo Inversion of Control (IoC) package offers a full-featured, dependency injection solution and a services layer for PHP applications.

Usage

These are the basic steps to implementing the Inversion of Control (IoC) package:

  1. Create a Service Folder to store custom dependency injection handlers.
  2. Update the Front Controller for the Inversion of Control Container (IoCC).
  3. Request Services from the IoCC within the Application.
  4. Create Custom Factory Methods for Services.

1. Service Folder

Create a folder within your application to store Service Factory Methods. Each Customer Handler has a folder containing a class file named ClassnameFactoryMethod.php. When instantiating the IoCC, you'll provide the namespace of the Services Folder.

The default namespace for a services folder is Molajo\Services. Whatever value is used, it will be passed in as a parameter when instantiating the Container class.

2. Front Controller

The Front Controller should be the only point of entry into the Inversion of Control Container (IoCC).

Use Statement

Add a use statement for the IoC Container class.

Class Property

Define a class property in which to store the IoCC instance.

IoCC Methods

Add these four methods: getService, setService, cloneService, and removeService to the Front Controller.

Instantiate the Container

In the Front Controller boot process, instantiate the Container using the code that begins with $connect and ends before "// Automatically Load These Services". The four closure statements passed into the Container will be used outside of the Front Controller to access the IoCC methods defined in the previous step. Note, also, the location of the $services_folder is passed into the Container.

3. Application Service Requests

The four closures provide a way to access the Front Controller entry points into the IoCC.

When the IoC Container creates a Factory Method instance, it injects it with all four closures before injecting the handler into the DI Adapter. The handler can use those class properties to interact with the IoCC. In this example, the handler requests the dependent Application Service.

getService Parameters

  1. $service Fully qualified namespace (ex. Molajo\\Services\\Database\\DatabaseInjector) or the name of the Services sub-folder (ex. Database).
  2. $options Optional associative array contain runtime parameters required by the service.

Existing, If Exists, or New Instance

When the Container processes a getService request, it first determines if the named service exists in the registry. If it is, the existing service is returned. If it does not exist, a new instance will be created unless the if_exists $options entry was specified in the request.

Example 1: No fully qualified namespace

When the fully qualified namespace is not defined, the Container looks for a folder with that name in the Services library. In this example, the $options array defines runtime variables for the instantiation process.

Example 2: if_exists Option

This request instructs the Container only return an instance of the User if that instance already exists.

Example 3: Standard Factory Method

A Service Factory Method is not always needed. Classes can be created by the Standard Factory Method. It will match the values defined in the $options associative array with the Constructor parameters and use that data to create the class. For the service name, use the fully qualified class name.

setService

Replaces the existing Container registry entry for this service with the value sent in.

cloneService

Clones the existing Container registry entry for this service and returns the cloned value.

removeService

Removes the existing Container registry entry for this service.

4 - Custom Factory Methods

To create a Custom Dependency Injection Handler:

  1. Add a folder to the Services Folder defined in Step 1. The folder name is the name of the service.
  2. Create a PHP file in that folder named ServiceNameFactoryMethod.php.

Standard Properties

The Custom Factory Method has access to the following class properties:

  1. $getService - Closure to request a service of the IoCC, defined above
  2. $setService - Closure to set a service contained within the IoCC registry, defined above
  3. $cloneService - Closure to clone a service contained within the IoCC registry, defined above
  4. $removeService - Closure to remove a service contained within the the IoCC registry, defined above
  5. $service - The name specified in the getService statement
  6. $service_namespace - Set the fully qualified namespace for the Class to be instantiated in the constructor
  7. $store_instance_indicator - defaults to false, set to true in the constructor to store the instance in the IoCC registry
  8. $static_instance_indicator - defaults to false, set to true in the constructor to request a static instance
  9. $store_properties_indicator - defaults to false, set to true in the constructor to store the properties, not the instance, in the IoCC registry
  10. $product_result - populated with the instantiated class
  11. $options - associative array provided by the getService call

Custom Factory Method Starter

Below is a basic starting pattern for a Custom Dependency Injection Handler. The event methods available to the Factory Method are: onBeforeInstantiation, Instantiate, onAfterInstantiation, initialise, onAfterServiceInitialise, and getProductValue. Each method can be used to inject code at different points in the class creation process. The like-named AbstractHandler method will be used for any omitted methods in the custom class. It is a good idea to become familiar with that class.

The Molajo\Services folder is also a good source of examples of Custom DI Injectors.

Install using Composer from Packagist

Step 1: Install composer in your project

Step 2: Create a composer.json file in your project root

Step 3: Install via composer

Requirements and Compliance


All versions of ioc with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4
commonapi/ioc Version dev-master
commonapi/resource Version dev-master
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 molajo/ioc contains the following files

Loading the files please wait ....