Revision #42 has been created by rackycz on Mar 5, 2021, 1:37:57 AM with the memo:
Docker
« previous (#41) next (#43) »
Changes
Title
unchanged
Yii v2 snippet guide III
Category
unchanged
Tutorials
Yii version
unchanged
2.0
Tags
unchanged
tutorial,yii2,beginer
Content
changed
[...]
- To get PHP version call: "php -version"
- If you are not allowed to run "mysql -v", you can run "mysql -u {username} -p" .. if you know the login
- Current IP: hostname -I
In "scotch/box" I do not use PhpMyAdmin , but [Adminer](https://www.adminer.org/en). It is one simple PHP script and it will run without any installations.
Just copy the adminer.php script to your docroot and access it via browser. Use the same login as in configurafion of Yii. Server will be localhost.
**Running Yii project in Docker (now without xDebug)**
---
*Note: I am showing the advanced application. Basic application will not be too different I think.*
- Download Yii the application template and extract it to any folder
- Open command line and navigate to the project folder
- Run command docker-compose up -d
- Argument -d will run docker on the background as a service
- Advantage is that command line will not be blocked, but you will be able to call more commands
- Run command init to initialize the application
- You can also call composer install using one of following commands:
- docker-compose run --rm frontend composer install
- docker-compose run --rm backend composer install
Now you will be able to open URLs:
- Frontend: http://localhost:20080
- Backend: http://localhost:21080
- ... see docker-compose.yml to understand these port numbers
Open common\config\main-local.php and set following DB connection:
- host=mysql
- dbname=yii2advanced
- username=yii2advanced
- password=secret
- Values are taken from docker-compose.yml
Run migrations ieng one of following commands:
- docker-compose run --rm frontend php yii migrate
- docker-compose run --rm backend php yii migrate
Now go to Frontend and click "signup" in the right upper corner
- This will create a new user and will send an email. It will appear in folder frontend\runtime\mail
- Now you have to activate it. FIrst way is to use the the email
- Open file frontend\runtime\mail\*.eml
- copy whole href which is inside and modify it by changing these substrings: "=3D" "=" "&" "%2F"
- Original format:
- http://l=ocalhost:20080/index.php?r=3Dsite%2Fverify-email&token=3D07tYL8tqNjsyr8=eZBoN_mXOgwtq1XqvB_1614901373
- Desired format:
- http://localhost:20080/index.php?r=site/verify-email&token=07tYL8tqNjsyr8eZBoN_mXOgwtq1XqvB_1614901373
- If the link is correct, activation will suceed
Second way is to directly modify table in DB:
- Download adminer - It is a single-file DB client: www.adminer.org/en
- Copy Adminer to frontend\web\adminer.php
- Open Adminer using: http://localhost:20080/adminer.php
- If your DB has no password, adminer fill refuse to work. You would have to "crack" it.
- Use following login and go to DB yii2advanced:
- Server=mysql
- username=yii2advanced
- password=secret
- Values are taken from docker-compose.yml
- Set status=10 to your first user
Now you have your account and you can log in to Backend
*I was not able to use xDebug. It just does not work now. I will update as soon as I find out.*