Contributte Cookbook
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 (opens new window)) 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
- Configuration (https://doc.nette.org/en/2.4/configuring (opens new window))
- Dependency injection (https://doc.nette.org/en/2.4/dependency-injection (opens new window))
- Define extensions (https://doc.nette.org/en/2.4/di-extensions (opens new window))
- Built-in extensions (https://doc.nette.org/cs/2.4/di-builtin-extensions (opens new window))
- DI usage (https://doc.nette.org/en/2.4/di-usage (opens new window))
# Example
# NEON
services:
facebookAuthorizator:
class: App\Model\Security\FacebookAuthorizators(@redisCache)
redisCache: Predis\PredisClient
1
2
3
4
5
2
3
4
5
# PHP
$builder->addDefinition('facebookAuthorizator')
->setClass('App\Model\Security\FacebookAuthorizators(@redisCache)');
$builder->addDefinition('redisCache')
->setClass('Predis\PredisClient');
1
2
3
4
5
2
3
4
5
# Roadmap
- [?] Create some online tool using now.sh (opens new window) (@zeit (opens new window)).