Download the PHP package jesusslim/kos without Composer

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

kos

php concise container/di

usage

Install

kos in packagist:https://packagist.org/packages/jesusslim/kos

Install:

composer require jesusslim/kos

Methods

getInstance()

get instance of kos\Container.

map($key,$class = null)

map a class or closure to container.

Container::getInstance()->map(Foo::class);
Container::getInstance()->map('foo',Foo::class);
Container::getInstance()->map('bar',function($foo,$bar){return $foo + $bar;});

mapInstance($key,$instance)

map an instance to container.

Container::getInstance()->mapInstance('foo',new Foo());

isMapped($key)

get($key,$params = [])

if $key is mapped in container as an instance,return the instance;

if $key is mapped in container as a class,return the an instance of the class;

if $key is mapped in container as a closure,return the result of the closure;

if $key is not mapped in container,reflect $key and return the instance/result;

the values in $params can be used as the params of the constructor of class or the params of closure;

class Foo{

    private $bar;

    public function __construct($bar)
    {
        $this->bar = $bar;
    }

    public function getBar(){
        return $this->bar;
    }
}
$container = Container::getInstance();

$container->map(Foo::class);
$container->mapInstance('bar',677);
$container->map('sum',function(Foo $foo,$inc){
    return $foo->getBar()+$inc;
});

$foo = $container->get(Foo::class);
/* @var Foo $foo */
echo $foo->getBar();
//result is 677

$foo = $container->get(Foo::class,['bar' => 688]);
echo $foo->getBar();
//result is 688;

echo $container->get('sum',['inc' => 100]);
//result is 777

invoke(Closure $closure,$params = [])

invoke a closure , the params of the closure will be filled by the container.

echo $container->invoke(function(Foo $foo,$inc){
    return $foo->getBar()+$inc;
},['inc' => 100]);
//result is 777

invokeClass($class,$method,$params = [])

invoke a class->method , the params of the closure will be filled by the container.

echo $container->invokeClass(Foo::class,'getBar',[]);
//result is 677

others

kos is a concise container/DI lib for simple use.

and pinject is a lib for the complex use,like caching instances,ArrayAccess implements and chaining operations/workflow with container.


All versions of kos with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.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 jesusslim/kos contains the following files

Loading the files please wait ....