oxidprojects / dependency-injection
The missing dependency injection for OXID eShop
Installs: 1 714
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 9
Forks: 0
Open Issues: 1
Type:add-on
Requires
Requires (Dev)
- mikey179/vfsstream: ^1.6
- php-coveralls/php-coveralls: ^2.1
- phpunit/phpunit: ^6
- symfony/config: *
- symfony/yaml: *
This package is auto-updated.
Last update: 2024-11-23 15:01:22 UTC
README
The missing dependency injection for OXID eShop
Install
composer require "oxidprojects/dependency-injection"
How to use:
-
Create
services.yaml
in a module: (eg.source/modules/tm/Sunshine/services.yaml
)services: tm\ModuleOutput: class: 'tm\ModuleOutput'
-
project_container()
is a global function.<?php class Controller extends FrontendController { public function render() { $output = project_container()->get(ModuleOutput::class); $this->addTplParam('title', $output->html('Hello dependency injection')); return 'template'; } }
Weblinks
- You have all the Power of Symfony Service Container.
- See which other methods are available to inject classes. You must not use every time the
__construct()
method.