PHP
php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
/**
This is an example of autowiring in
a server application with many routes.
Notice, that there is no explicit
instantiation for the following classes:
MessageConstroller
MessageService
MessageRepository
Benefit:
You can add new routes with new
controllers and their dependencies will
be instantiated automatically.
No need to instantiate dependencies explicity.
*/
declare(strict_types=1);
class Message
{
public string $text = '';
public function __construct(
string $text
) {
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run