https://github.com/initphp/container
Simple Dependencies Container following PSR-11 standards
https://github.com/initphp/container
container php php7 psr-11 psr-container
Last synced: about 1 month ago
JSON representation
Simple Dependencies Container following PSR-11 standards
- Host: GitHub
- URL: https://github.com/initphp/container
- Owner: InitPHP
- License: mit
- Created: 2022-04-25T21:38:32.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-12-23T04:30:11.000Z (over 1 year ago)
- Last Synced: 2024-04-23T13:26:48.993Z (12 months ago)
- Topics: container, php, php7, psr-11, psr-container
- Language: PHP
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# InitPHP Dependencies Container
Simple Dependencies Container following PSR-11 standards.
_Note :_ This is a pre-release version of the library currently available. Report potential bugs and feature requests to the issue section of this repo.
## Requirements
- PHP 7.4 or higher
- [PSR-11 Container Interface Package](https://packagist.org/packages/psr/container) 2.0.2## Installation
```
composer require initphp/container:dev-main
```## Usage
Check the `Example` directory for an example usage.
```php
require_once "vendor/autoload.php";
use InitPHP\Container\Container;class UserModel
{
private string $name;public function set(string $name)
{
$this->name = $name;
}
public function get()
{
return $this->name ?? null;
}
}class User
{
private $model;public function __construct(UserModel $model)
{
$this->model = $model;
}public function getModel()
{
return $this->model;
}
}$container = new Container();
$user = $container->get(\Example\User::class);
$model = $user->getModel();
$model->set('Muhammet');
echo $user->getModel()->get();
```## Contributing
> All contributions to this project will be published under the MIT License. By submitting a pull request or filing a bug, issue, or feature request, you are agreeing to comply with this waiver of copyright interest.
1. Fork it ( https://github.com/initphp/container/fork )
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. Create a new Pull Request## Credits
- [Muhammet ŞAFAK](https://www.muhammetsafak.com.tr) <>
## License
Copyright © 2022 [MIT License](./LICENSE)