Download the PHP package program-2/reason without Composer

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

Reason A PHP Dependency Injection Class

Introduction

Reason is a brief dependency injection Class that also supports a direct

object injection system for PHP of 36 lines,

with no need to configuration, that uses reflection.

It can also be used for the last part of

an Inversion of Control (IoC) system to route

a control flow and inputs to their destination.

Aims

1- to be as small as possible.

2- to be able to handle the dependency of a dependency.

3- to be fast. reflection is much faster than annotation.

Instalation

Load Reason along with all dependency classes in your project.

How to use it (3 ways explained)

-

First way

(the recommended way; beacause it will not occupy

the parameters palce of methods, it only occupies parameters

place of construct method which is allocated for dependency injection purposes.)

1- Put "Reason $Reason" as parameter of the construc method of the class:

  public function __construct(Reason $Reason)
  {
    //
  }

2- Instantiate the Class where/when needed with "Reason":

  ((new Reason)->inject('Class'));

Inside the construct method you will have access to injected $Reason object

so you can make $Reason available within the class

with programing techniques like using a property to share it:

  $Reason->inject('Class');

example:

 $obj = $Reason->inject('DataBaseClass');

 $obj->query(..);

(Here the dependencies of dependencies will also be injected as well)

-

Second way

(calling a method and injecting the type-hinted Reason)

1- Put "Reason $Reason" as parameter of the method:

  public function Method(Reason $Reason)
  {
    //
  }

2- Instantiate the methods where/when needed with "Reason":

  ((new Reason)->inject('Class','Method'));

Inside the methods use injected $Reason object to get an instance of any dependency:

  $Reason->inject('Class','Method');

(Here the dependencies of dependencies will also be injected as well)

Notice:

As you don't have access to pass parameters to methods directly

in the second way, any needed values can be passed throuth one(1) array of

keys/values as the third(3rd) parameter position:

  ((new Reason)->inject('Class', 'Method', array('john'=>'4')));

and when injected into objects:

  $Reason->inject('Class', 'Method', array('john'=>'4'));   

then accessible:

  $john;

-

Third way

( use it for "unlimitted number of direct object injection" only if your dependency

classes themselves are independent so they don't have Reason inside their own class definition.

Please note that Reason itself can be among these type-hinted classes. )

1- Put "AnyDependencyClass $AnyDependencyClass" as parameter of the method:

  Class 
  {
      public function Method(Class1 $Class1, Class2 $Class2, Reason $Reason, ...)
      {
        //
      }
  }

2- Instantiate the methods where/when needed with "Reason":

  ((new Reason)->inject('Class','Method'));

Inside the methods directly use your injected object:

  $Class1;

  $Class2;

  $Reason;

Notice:

It is possible to pass Reason Manually like any of the parameter

of the method if the method accepts any paratemer:

 ((new Reason)->inject('Class'))->Method(new Reason);

or make it inside a method of a class:

 $reason = new Reason;

thus reserving the parameters place for the programing purpose,

but ways increase the coupling degree a little.

Credit

Developed by Ehsan Yousefi https://fsdeveloper.ir]

Updates

" 8/4/2019 1.0.0 first release" - Backwards incompatible

"25/4/2019 2.0.0 new features added >> ways(No.1 & No.3)" - Backwards incompatible


All versions of reason with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2
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 program-2/reason contains the following files

Loading the files please wait ....