Download the PHP package mmghv/dependency-pocket without Composer

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

DependencyPocket

Build Status Latest Stable Version Latest Unstable Version License

A new form of "Dependency Injection" in PHP

Not to be confused with Dependency Injection Container or Ioc Container like Symfony DI Container, Pimple or Laravel Service Container,

DependencyPocket is not a DI Container in that way, It's rather a new form of Dependency Injection. Essentially, there're two ways of dependency injection : Constructor Injection and Setter Injection, I'd like to think of this technique as the third type, the Pocket Injection.

Installation

Using composer

usage

We use this pocket inside our classes to hold the dependencies, we first create a new pocket :

Then we add the dependencies, We first define them (defining the Name and the Type of each dependency) :

Then we set our dependencies (set dependencies values) :

Then when we want to get a dependency we simply do :

Or we can use Property Overloading to easily access our dependencies from our class (or subclasses) :

When it's useful and the technique to use it

Basically Its useful when your class has many dependencies which not all of them are required so you don't want your constructor to have all these dependencies but still need a way to easily change them in the subclasses and tests.

Imagine you have a class with 5 dependencies but only 2 of them are essential and the other 3 can be set to some default values, Then you extend this class and the subclass can resolve one of the two essential dependencies to a default value and needs to replace one of the optional dependencies of the parent class, You need to be able to do that and want your final class to have only one dependency in the constructor but still be able to change any default ones from any future subclasses as well as the ability to mock any of these dependencies in the tests.

Using DependencyPocket you can achieve that like the following without using a setter for each dependency and also mocking dependencies for tests is easier than using Setter Injection method :

Then when we instantiate the ArticleManager class we only need to pass one dependency like this :

But also we have the ability to easily replace any default dependencies when we want like this :

Contributing

This is a relatively new technique so any contributions (suggestions, enhancements to the technique used) are welcome. PSR-2 standards are used and tests should cover any changes in case of PRs.

License & Copyright

Copyright © 2016, Mohamed Gharib. Released under the MIT license.


All versions of dependency-pocket with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.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 mmghv/dependency-pocket contains the following files

Loading the files please wait ....