🎶 Nette Dependency Injection (DI) extensions & NEON syntax overview in examples
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
2.3
2.4
3.0
.editorconfig
.gitignore
.travis.yml
LICENCE.md
LICENSE
README.md

README.md

Nette dependency injection cookbook

Build Status


This repository is for education. The main goal is to show how to define services in cool Nette Dependency-Injection Container (nette/di). The examples are written in NEON (take a look at ne-on.org) and in PHP classes called CompilerExtension.

Related blogposts:

Versions

Nette DI PHP
3.0 >7.1
2.4 >7.1
2.3 <7.2

Latest reference

Example

NEON

services:
  facebookAuthorizator: 
    class: App\Model\Security\FacebookAuthorizators(@redisCache)
    
  redisCache: Predis\PredisClient

PHP

$builder->addDefinition('facebookAuthorizator')
    ->setClass('App\Model\Security\FacebookAuthorizators(@redisCache)');

$builder->addDefinition('redisCache')
    ->setClass('Predis\PredisClient');

Roadmap

  • [?] Create some online tool using now.sh (@zeit).