mirror of
https://github.com/m-lamonaca/dev-notes.git
synced 2025-05-14 15:16:27 +00:00
show line numbers in conde snippets
This commit is contained in:
parent
cd1df0e376
commit
255a68d673
82 changed files with 1249 additions and 1251 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
Explicit definition of a class dependencies with the injection through the constructor or *getters*/*setters*.
|
||||
|
||||
```php
|
||||
```php linenums="1"
|
||||
class Foo
|
||||
{
|
||||
public function __construct(PDO $pdo) // depends on PDO
|
||||
|
@ -24,7 +24,7 @@ The dependency injection container for humans. Installation: `composer require p
|
|||
- Use of [Reflection](https://www.php.net/manual/en/intro.reflection.php)
|
||||
- Configuration of the container through annotations & PHP code.
|
||||
|
||||
```php
|
||||
```php linenums="1"
|
||||
class Foo
|
||||
{
|
||||
private $bar;
|
||||
|
@ -42,7 +42,7 @@ $foo = $container->get('Foo'); // get instance of Foo (automatic DI of Bar)
|
|||
|
||||
### DIC Configuration
|
||||
|
||||
```php
|
||||
```php linenums="1"
|
||||
// Foo.php
|
||||
class Foo
|
||||
{
|
||||
|
@ -53,7 +53,7 @@ class Foo
|
|||
}
|
||||
```
|
||||
|
||||
```php
|
||||
```php linenums="1"
|
||||
// config.php
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
|
@ -68,7 +68,7 @@ return [
|
|||
];
|
||||
```
|
||||
|
||||
```php
|
||||
```php linenums="1"
|
||||
$builder = new \DI\ContainerBuilder();
|
||||
$builder->addDefinitions("config.php"); // load config
|
||||
$container = $builder->build(); // construct container
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue