2017 © Pedro Peláez
 

library strix

Minimal container for modern PHP applications following the PSR11 standard

image

anned20/strix

Minimal container for modern PHP applications following the PSR11 standard

  • Monday, October 2, 2017
  • by anned20
  • Repository
  • 1 Watchers
  • 17 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Packagist Latest Stable Version Build Status Scrutinizer Code Quality, (*1)

Strix

Minimal container for modern PHP applications following the PSR-11 standard, (*2)

Installation

composer require anned20/strix, (*3)

Usage

<?php

require __DIR__.'/vendor/autoload.php';

use anned20\Strix\Container;
use anned20\Strix\Exception\AlreadyInContainerException;
use anned20\Strix\Exception\NotFoundException;

// Create new container
$container = new Container();

// Use the container for variables
$container->add('config', ['hello' => 'world']);

// Use the container for closures
$container->add('function', function () {
    return rand();
});

// Let's use the config
$hello = $container->get('config')['hello'];

// And the function
$rand = $container->get('function')();

// Factories can be made too!
$container->add('factory', function () {
    return new SomeClass();
});

// Just like services
$myService = new SomeClass();

$container->add('service', $myService);

// Whoops!
$container->add('config', ['foo' => 'bar']); // AlreadyInContainerException thrown

// Let's check before adding
if (!$container->has('config')) {
    $container->add('config', ['foo' => 'bar']);
}

// But I want to overwrite the old one! No problem!
if ($container->has('config')) {
    $container->delete('config');
}

$container->add('config', ['foo' => 'bar']);

// Whoops!
$bye = $container->get('bye'); // NotFoundException thrown

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

Strix is a PSR-11 compliant container, (*4)

Copyright © 2017 Anne Douwe Bouma, (*5)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:, (*6)

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software., (*7)

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE., (*8)

The Versions

02/10 2017

dev-master

9999999-dev

Minimal container for modern PHP applications following the PSR11 standard

  Sources   Download

MIT

The Requires

 

The Development Requires

by Anne Douwe Bouma

container minimal psr-11 container-interop container-interface

02/10 2017

v1.0.2

1.0.2.0

Minimal container for modern PHP applications following the PSR11 standard

  Sources   Download

MIT

The Requires

 

The Development Requires

by Anne Douwe Bouma

container minimal psr-11 container-interop container-interface

02/10 2017

v1.0.1

1.0.1.0

Minimal container for modern PHP applications following the PSR11 standard

  Sources   Download

MIT

The Requires

 

The Development Requires

by Anne Douwe Bouma

container minimal psr-11 container-interop container-interface

01/10 2017

v1.0.0

1.0.0.0

Minimal container for modern PHP applications following the PSR11 standard

  Sources   Download

MIT

The Requires

 

The Development Requires

by Anne Douwe Bouma