Difference between #2 and #3 of
Yii3 - How to start

Revision #3 has been created by rackycz rackycz on Oct 8, 2025, 12:45:06 PM with the memo:

edit
« previous (#2) next (#4) »

Changes

Title unchanged

Yii3 - How to start

Category unchanged

Tutorials

Yii version unchanged

3.0

Tags unchanged

Content changed

[...]
Note:
- Instead of installing local WAMP- or XAMPP-server I will be using Docker.
- Do not forget about a modern IDE like PhpStorm, which comes budled with all you will ever need.

#
 1) Intro

Yii3 offers more basic applications: Web, Console, API. I will be using the API application:
[...]
- https://docs.docker.com/get-started/introduction/get-docker-desktop/

#
 2) Running the demo application

You may be surprised that docker-compose.yml is missing in the root. Instead the "make" commands are prepared.
[...]
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.

#
 3) 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:
[...]
The web will be, from now on, available on URL http://localhost:9080 which is more handy than just ":80" I think.

#
 4) Enabling MariaDB (MySQL) and migrations Now when your project contains MariaDB, you may wanna use it in the code ... ## a) Installing composer packages

After some time of searching you will discover you need to install these composer packages:
[...]
> If you are using PhpStorm, find the small icon "Services" in the left lower corner (looks ca like a cog wheel), find item "Docker-compose: app-api", inside click the "app" service, then "yii3api_php" container and then hit the button "terminal" on the righthand side.

##
 b) Setting up composer packages

Follow their documentations. Quick links:
[...]
```php
<&lt;?php declare(strict_types=1); ``` ## c) Create folder for migrations - src/Migration When this is done, call "composer du" or "make composer du" and then try "make yii list". You should see the migration commands. # 5) Creating a migration

Run the command to create a migration:
[...]
```

#
 6) Running the migrations
Try to run "make yii migrate:up" and you will see error "could not find driver", because file "docker/Dockerfile" does not install the "pdo_mysql" extention. Add it to the where "install-php-extensions" is called.

Then call:
- make down
- make build
[...]
1 0
2 followers
Viewed: 580 times
Version: 3.0
Category: Tutorials
Tags:
Written by: rackycz rackycz
Last updated by: rackycz rackycz
Created on: Oct 8, 2025
Last updated: 2 days ago
Update Article

Revisions

View all history