isholao / container
PHP 容器
1.0
2017-11-21 04:50 UTC
Requires
- php: >=7.1.0
- psr/container: 1.*
Requires (Dev)
- phpunit/phpunit: v6.4
This package is not auto-updated.
Last update: 2024-09-29 05:08:03 UTC
README
安装
使用 composer 安装
composer require isholao/container
需要 PHP 7.1 或更高版本。
使用方法
以下是一个基本使用示例
<?php require '/path/to/vendor/autoload.php'; $c = new \Isholao\Container\Container(); $c->set('name','ishola'); // $c->name = 'ishola'; if($c->has('name')) { echo $c->get('name'); // $c->name; } $c->protected('response', function (){}); $c->response();
保护一个项目。使用 protect 方法定义它
<?php require '/path/to/vendor/autoload.php'; $c = new \Isholao\Container\Container(); $c->protect('name','ishola'); $c->name = 'ishola'; // throw error