Revision #33 has been created by
rackycz on Oct 14, 2025, 7:22:43 AM with the memo:
edit
« previous (#32) next (#34) »
Changes
Title
unchanged
Yii3 - How to start
Category
unchanged
Tutorials
Yii version
unchanged
3.0
Tags
unchanged
Content
changed
(draft - all will be retested later)
# Intro
In Yii3 it is not as easy to start as it was with Yii2. You have to install and configure basic things on your own. Yii3 uses the modern approach based on independent packages and dependency injection, but it makes it harder for newcomers. I am here to show all how I did it.
> All the code is available in my new [GitHub repository](https://github.com/rackycz/yii3api). I will be using it as a boiler-plate for my future projects so it should be always up to date and working.
Instead of installing local WAMP- or XAMPP-server I will be using Docker. Do not forget about a modern IDE like PhpStorm, which comes bunled with all you will ever need.
## PSR Standards by Framework Interoperability Group
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.
## Dependency injection + container
Check [this YouTube video](https://www.youtube.com/watch?v=TqMXzEK0nsA) for explanation
## __construct vs __invoke
It may be confusing that some classes contain both methods. Note that "property promotion" should be only used in `__construct()`.
Magic method `__invoke` is only used if you create an instance and then use it as a function. Example:
```php
$obj = new MyObj();
$obj(); // Now the __invoke() is executed
```
To be honest, I still do not fully understand the real purpose of this situation.
# Yii3 - How to start
Yii3 offers more basic applications: Web, Console, API. I will be using the API application:
- https://github.com/yiisoft/app-api
- Other apps are linked on the page[...]