Download the PHP package jopic/jdi without Composer

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

JDI - Jopic Dependency Injection

Build Status

This repository provides a very basic and easy to use dependency injection "framework" for PHP.

Installation

You basically only need to add the following dependency "jopic/jdi": "1.0.0" into your composer.json file.

Usage - Container Setup

At first you have to set up your dependency container:

$container = new Jopic\DI\Container();

Then you can set this container as the active container for dependency injection by:

\Jopic\DI\DependencyInjection::getInstance()->setContainer($container);

Usage - Container Object registration

To be able to inject objects to class fields the dependency injection container needs to know about injectable objects. Therefore you register them on the container by calling the register method.


$container->register("foo", function() {
    return new DummyObject();
});

Please note: it is important to register a closure function (needed for object instantiation).

Usage - Object Injection

Basically the only 3 things you need to do are:

  1. extend the abstract JDIBaseClass
  2. call parent::__construct($this); in your class constructor
  3. annotate inject fields of your class with @inject

Here is a short example of a Injectable class:

class SampleClass extends Jopic\DI\JDIBaseClass {
    /**
     * @inject
     */
    private $foo;

    public function __construct() {
        parent::__construct($this);
    }
}

This code assures that if a object with the name "foo" is registered in the dependency injection container it will be available in this class instances automatically.

Lazy Injection

If you define a property as protected, the class constructor of JDIBaseClass will automatically inject this property lazily. That means that the property closure gets executed just before the first property usage.

Here is a short example of a class with directly injected and lazily injected properties:

class SampleClass extends Jopic\DI\JDIBaseClass {
    /**
     * this value gets injected on constructor call
     * @inject
     */
    private $foo;

    /**
     * this value gets injected just before the first getFoo2() call
     * @inject
     **/
    protected $foo2;

    public function __construct() {
        parent::__construct($this);
    }

    public function getFoo() {
        return $this->foo;
    }

    public function getFoo2() {
        return $this->foo2;
    }
}

Request for comment

If you find any bugs or if you find something (or everything ;-) ) inconvenient please don't hesitate to contact me either directly via github or via e-mail (admin [at] jopic.at).


All versions of jdi with dependencies

PHP Build Version
Package Version
Requires doctrine/common Version *
hafriedlander/phockito 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 jopic/jdi contains the following files

Loading the files please wait ....