Skip to content

Demo app for Track management for COD. Used yii2, docker, codeception, phpunit. REST API, bulk update, backoffice

License

Notifications You must be signed in to change notification settings

ioncode/TrackCOD

 
 

Repository files navigation

Track management


Build Status

This demo application based on the official Yii 2.0 Framework image on DockerHub for PHP.

About

These Docker images are built on top of the official PHP Docker image, they contain additional PHP extensions required to run Yii 2.0 framework, including basic demo application. The Dockerfile(s) of this repository are designed to build from different PHP-versions by using build arguments.

Windows EOL settings

Please, check your settings git config --get core.autocrlf and disable autocrlf

Setup

cp .env.example .env

Adjust the versions in .env if you want to build a specific version. See .env-dist for details.

Note: Please make sure to use a matching combination of DOCKERFILE_FLAVOUR and PHP_BASE_IMAGE_VERSION

Configuration

  • GITHUB_API_TOKEN access key for repositories on GitHub
  • GITLAB_ACCESS_TOKEN access key for repositories in GitLab
  • PHP_ENABLE_XDEBUG whether to load an enable Xdebug, defaults to 0 (false) not available in -min images
  • PHP_USER_ID (Debian only) user ID, when running commands as webserver (www-data), see also #15

Building

docker-compose build

Run services

docker-compose up

Testing application requirements

docker-compose run --rm php-dev php /tests/requirements.php

Install dependencies

docker-compose run --rm php-dev composer install

Apply DB migration

docker-compose run --rm php-dev yii migrate

Backoffice

Visit web interface http://localhost:8202/track, auth not required

backoffice

REST API

http://localhost:8202/api/tracks 

Authorization: use Bearer 101-token for development

POST new track

curl -i -X POST \
   -H "Authorization:Bearer 101-token" \
   -H "Content-Type:application/json" \
   -d \
'{
  "track_number": "UANNmin5max255",
  "status": "new"
}' \
 'http://localhost:8202/api/tracks'

View track by ID

curl -i -X GET \
   -H "Authorization:Bearer 101-token" \
 'http://localhost:8202/api/tracks/1'

in response you see track structure

{
    "id": 1,
    "track_number": "UANNmin5max255",
    "created_at": "2025-06-22 09:36:05",
    "updated_at": null,
    "status": "new"
}

PATCH existing track

curl -i -X PATCH \
   -H "Authorization:Bearer 101-token" \
   -H "Content-Type:application/json" \
   -d \
'{
  "status": "completed"
}' \
 'http://localhost:8202/api/tracks/1'

Delete track

curl -i -X DELETE \
   -H "Authorization:Bearer 101-token" \
 'http://localhost:8202/api/tracks/1'

filter tracks by status

curl -i -X GET \
   -H "Authorization:Bearer 101-token" \
   -H "Content-Type:application/json" \
 'http://localhost:8202/api/tracks?filter%5Bstatus%5D=new'

Bulk update

curl -i -X PATCH \
   -H "Authorization:Bearer 101-token" \
   -H "Content-Type:application/json" \
   -d \
'[
  {
    "status": "completed",
    "id":2
  },
  {
    "status": "in_progress",
    "id":3
  }
]' \
 'http://localhost:8202/api/tracks/bulkupdate'

bulkupdate

Logger

Track creation, modification & deletion is logged by LogBehavior to separate logfile _host-volumes\app\runtime\logs\track.log

UNIT tests

current settings & best practices uses separate database to run tests isolated from development & production, so you need to prepare db or change settings in test_db

connect to db service, using password root
docker-compose run --rm db mysql -h db -u root -p
create database & user for tests
create database test;
CREATE USER 'test' IDENTIFIED BY 'test';
GRANT ALL ON test.* TO 'test';
exit;
apply migrations on test db
docker-compose run --rm php-dev php tests/bin/yii migrate
run all tests (including framework base tests)
docker-compose run --rm php-dev /app/vendor/bin/codecept run

Track unit tests for model & REST API controller

docker-compose run --rm php-dev /app/vendor/bin/codecept run unit :Track

tests

Xdebug

To enable Xdebug, set PHP_ENABLE_XDEBUG=1 in .env file

Xdebug is configured to call ip xdebug.remote_host on 9005 port (not use standard port to avoid conflicts), so you have to configure your IDE to receive connections from that ip.

Documentation

More information can be found in the docs folder.

FAQ

  • We do not officially support Alpine images, due to numerous issues with PHP requirements and because framework tests are not passing.
  • Depending on the (Debian) base-image (usually PHP <7.4) you might need to set X_LEGACY_GD_LIB=1
  • test

Available versions for yiisoftware/yii2-php

The following images are built on a weekly basis for arm64 and amd64. For regular commits on master we only build images for amd64 suffixed with -latest/-latest-min.

Minimal images

8.3-apache-min, 8.3-fpm-min, 8.3-fpm-nginx-min
8.2-apache-min, 8.2-fpm-min, 8.2-fpm-nginx-min
8.1-apache-min, 8.1-fpm-min, 8.1-fpm-nginx-min

Development images

8.3-apache, 8.3-fpm, 8.3-fpm-nginx
8.2-apache, 8.2-fpm, 8.2-fpm-nginx
8.1-apache, 8.1-fpm, 8.1-fpm-nginx

About

Demo app for Track management for COD. Used yii2, docker, codeception, phpunit. REST API, bulk update, backoffice

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 89.6%
  • Shell 4.2%
  • Hack 3.2%
  • CSS 1.2%
  • Other 1.8%