brainexe / annotations
1.0.11
2017-01-09 20:32 UTC
Requires
- doctrine/annotations: 1.3.*
- symfony/config: ~3.2
- symfony/dependency-injection: ~3.2
Requires (Dev)
- phpunit/phpunit: ~5.3
README
composer require brainexe/annotations 1.0.*
注解
此存档中的文件均根据MIT许可证发布。您可以在LICENSE文件中找到此许可证的副本。
示例
// Logger.php /** * @Service(public=false) */ class Logger { /** * @Inject("%log.file%") */ public function __construct($logFile); public function log(); } // Command.php class Command { /** * @var Logger */ private $logger; /** * @Inject("@Logger") */ __construct(Logger $logger) { $this->logger = $logger; } public function run() { $this->logger->log("Start"); // do something... $this->logger->log("Done"); } } // run.php use BrainExe\Annotations\Loader; $container = new ContainerBuilder(); $container->setParameter("log.file", "logs/file.log"); $loader = new Loader($container) $loader->load('src/'); /** @var Command */ $command = $dic->get('Command'); $command->run();
测试
phpunit