oxidprojects/dependency-injection

The missing dependency injection for OXID eShop

0.1.4 2023-02-23 11:24 UTC

This package is auto-updated.

Last update: 2024-12-23 15:08:09 UTC


README

Build Status Coverage Status

The missing dependency injection for OXID eShop

Install

composer require "oxidprojects/dependency-injection"

How to use:

  1. Create services.yaml in a module: (eg. source/modules/tm/Sunshine/services.yaml)

    services:
      tm\ModuleOutput:
        class: 'tm\ModuleOutput'
  2. 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