Difference between #39 and #41 of
Yii3 - How to start

Changes

Title unchanged

Yii3 - How to start

Category unchanged

Tutorials

Yii version unchanged

3.0

Tags unchanged

Content changed

[...]
## Dependency injection + container
Check [this YouTube video](https://www.youtube.com/watch?v=TqMXzEK0nsA) for explanation

## invoke()
The `__invoke()`
 public method is called when you call the **instance** as a method. Like this:(Therefore the constructor was already executed)

```php
[...]
```

Note that "property promotion" should be only used in `__construct()`.
 
 
 
## Hash annotations for class attributes
PHP 8 introduces annotations like this (not only 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:

In my case the resulting file looks like this:
[...]
2 0
5 followers
Viewed: 42 299 times
Version: 3.0
Category: Tutorials
Tags:
Written by: rackycz rackycz
Last updated by: rackycz rackycz
Created on: Oct 8, 2025
Last updated: 2 months ago
Update Article

Revisions

View all history