First of all, learn what [PHP Standards Recommendations](https://en.wikipedia.org/wiki/PHP_Standard_Recommendation) by [Framework Interoperability Group (FIG)](https://www.php-fig.org/psr) are. It will help you understand why so many "weird" PSR imports are in the Yii3 code. In short: These interfaces help authors of different frameworks to write compatible classes so they can be reused in any other framework following these principles.
It may be confusing that some classes contain bothinvoke()
The `__invoke()` public method is called when you call the **instance** as a methods. Note that "property promotion" should be only used in `__construct()`.
Magic method `(Therefore the constructor was already executed)
```php
$obj = new MyObj(); // Now the __construct() is executed.
$obj(); // Now the __invoke()` is only used if you create an instance and thenexecuted (The instance is needed!)
```
I never used it as a function. Example:
```php
$obj = new MyObj();
$obj(); // Now the, but prepared a following example that shows when invoking can be applied:
```php
class MyUpper
{
public function __invoke($a) { return $this->go($a); }
public function go($a) { return strtoupper($a); }
}
$instance = new MyUpper();
$array = ['a', 'B', 1, '1'];
// __invoke() is executused:
```
To be honest, I still do not fully understand the real purpose of this situation.var_dump($instance($array[0]));
var_dump(array_map($instance, $array));
// These do the same without invoking:
var_dump(array_map('strtoupper', $array));
var_dump(array_map([$instance, 'go'], $array));
var_dump(array_map(function($a) use ($instance) { return $instance->go($a); }, ['a','B',1,'1']));
```
## Hash annotations for class attributes
[...]
## Running the demo application
You may be surprised that docker-compose.yml is missing in the root. Instead the "make up" and "make down" commands are prepared.
If you run both basic commands as mentioned in the documentation:
[...]
If you want to modify the data that was returned by the endpoint, just open the action-class `src/Api/IndexAction.php` and add one more element to the returned array.
> You may be missing 'docker compose stop' or 'make stop', because 'make down' removes your containers and drops your DB. In that case you can add it to the Makefile in the root (see below). If you then type 'make help' you will see the new command.
```sh
ifeq ($(PRIMARY_GOAL),stop)
stop: ## Stop the dev environment
$(DOCKER_COMPOSE_DEV) stop
endif
```
## Adding DB into your project
Your project now does not contain any DB. Let's add MariaDB and Adminer (DB browser) into file docker/dev/compose.yml: