Skip to content

Commit a0ab513

Browse files
committed
Readme
1 parent a304f23 commit a0ab513

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

README.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
[![Build Status](https://travis-ci.org/anned20/strix.svg?branch=master)](https://travis-ci.org/anned20/strix)
2+
3+
# Strix
4+
5+
Minimal container for modern PHP applications following the PSR-11 standard
6+
7+
## Installation
8+
9+
`composer require anned20/strix`
10+
11+
## Usage
12+
13+
```php
14+
<?php
15+
16+
require __DIR__.'/vendor/autoload.php';
17+
18+
use anned20\Strix\Container;
19+
use anned20\Strix\Exception\AlreadyInContainerException;
20+
use anned20\Strix\Exception\NotFoundException;
21+
22+
// Create new container
23+
$container = new Container();
24+
25+
// Use the container for variables
26+
$container->add('config', ['hello' => 'world']);
27+
28+
// Use the container for closures
29+
$container->add('function', function () {
30+
return rand();
31+
});
32+
33+
// Let's use the config
34+
$hello = $container->get('config')['hello'];
35+
36+
// And the function
37+
$rand = $container->get('function')();
38+
39+
// Whoops!
40+
$container->add('config', ['foo' => 'bar']); // AlreadyInContainerException thrown
41+
42+
// Let's check before adding
43+
if (!$container->has('config')) {
44+
$container->add('config', ['foo' => 'bar']);
45+
}
46+
47+
// But I want to overwrite the old one! No problem!
48+
if ($container->has('config')) {
49+
$container->delete('config');
50+
}
51+
52+
$container->add('config', ['foo' => 'bar']);
53+
54+
// Whoops!
55+
$bye = $container->get('bye'); // NotFoundException thrown
56+
57+
```
58+
59+
## Contributing
60+
61+
1. Fork it!
62+
2. Create your feature branch: `git checkout -b my-new-feature`
63+
3. Commit your changes: `git commit -am 'Add some feature'`
64+
4. Push to the branch: `git push origin my-new-feature`
65+
5. Submit a pull request :D
66+
67+
## License
68+
69+
Strix is a PSR-11 compliant container
70+
71+
Copyright © 2017 Anne Douwe Bouma
72+
73+
Permission is hereby granted, free of charge, to any person obtaining
74+
a copy of this software and associated documentation files (the "Software"),
75+
to deal in the Software without restriction, including without limitation
76+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
77+
and/or sell copies of the Software, and to permit persons to whom the
78+
Software is furnished to do so, subject to the following conditions:
79+
80+
The above copyright notice and this permission notice shall be included
81+
in all copies or substantial portions of the Software.
82+
83+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
84+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
85+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
86+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
87+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
88+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
89+
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)