# psr11_container **Repository Path**: lwlwilliam/psr11_container ## Basic Information - **Project Name**: psr11_container - **Description**: 最小化的 PSR-11 Container - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-06-27 - **Last Updated**: 2023-06-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ### Minimal PSF-11 Container 来源: [https://ryangjchandler.co.uk/posts/build-your-own-service-container-in-php-minimal-container](https://ryangjchandler.co.uk/posts/build-your-own-service-container-in-php-minimal-container) #### 使用 ```shell $ composer require psr11_container ``` ```php name = 'hello world'; $container->bind('hello', $object); print_r($container->get('hello')); print_r($container->get('hello2')); } catch (Throwable $e) { print_r($e); } ``` ```shell $ php test.php stdClass Object ( [name] => hello world ) Demo\exceptions\ServiceNotFoundException Object ( [message:protected] => hello2 [string:Exception:private] => [code:protected] => 0 [file:protected] => /Users/wu/www/github.com/lwlwilliam/test/php/container/src/Container.php [line:protected] => 20 [trace:Exception:private] => Array ( [0] => Array ( [file] => /Users/wu/www/github.com/lwlwilliam/test/php/container/examples/test.php [line] => 15 [function] => get [class] => Demo\Container [type] => -> [args] => Array ( [0] => hello2 ) ) ) [previous:Exception:private] => ) ```