Download the PHP package gquental/cakephp-service-container without Composer

On this page you can find all versions of the php package gquental/cakephp-service-container. 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 cakephp-service-container

cakephp-service-container

This project was created to provide the feature of a container of services and also dependency injection in the CakePHP framework.

Installation

In order to install it, there is two options, install it through composer or manually.

composer

You just need to require the package gquental/cakephp-service-container in your composer.json and then run the install command. After this process is completed, a folder called ServiceContainer will be created inside your CakePHP plugins folder.

manually

Just clone the project inside your CakePHP plugins folder and name the directory ServiceContainer

Usage

Configuration file

The first step after the Plugin is properly installed is to create the configuration file and then register it in the CakePHP config bootstrap file (app/Config/bootstrap.php).

For example, if you name the file services.php, you will need to write this line in your bootstrap file:

Configuration file example

Using the ServiceContainer Component

In order to call the services inside the container, you will need to use the CakePHP component provided by the Plugin, in order to do so you will need to put the following entry in the components array.

With the component prepared, you can call a service by calling the getService method.

Dependency injection

Lets say that in your container we have two classes, the User and the Contact class. The contact class needs as a dependency the user instance and also a integer with the maximum number of phones that it should have.

We can pass all of this dependencies through the service container instead of instancing it manually in the Contact class. In order to do so we will to pass arguments to the Contact class in the services container configuration file.

In the arguments we can pass primitive values or another service already in the configuration file, only by passing a string with the name of the service preceded by a @, like this for the user class: "@User".

Below you will find the examples of how to create this situation

app/Config/services.php

someController.php

Lib/UserEntity.php

Lib/ContactEntity.php


All versions of cakephp-service-container with dependencies

PHP Build Version
Package Version
Requires composer/installers Version 1.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 gquental/cakephp-service-container contains the following files

Loading the files please wait ....