brainexe / annotations
Simple @annotation library based on doctrine annotations for symfony dependency injection container
Installs: 1 569
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
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.*
Annotations
The files in this archive are released under the MIT license. You can find a copy of this license in the LICENSE file.
Example
// 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();
Tests
phpunit