{"id":19818442,"url":"https://github.com/bscheshirwork/docker-codeception-yii2","last_synced_at":"2026-05-19T05:36:57.956Z","repository":{"id":74313352,"uuid":"88739066","full_name":"bscheshirwork/docker-codeception-yii2","owner":"bscheshirwork","description":"dockerized codeception for yii2 applications","archived":false,"fork":false,"pushed_at":"2020-02-29T03:51:40.000Z","size":47,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-11T08:13:14.140Z","etag":null,"topics":["codeception","docker-image","yii2"],"latest_commit_sha":null,"homepage":null,"language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bscheshirwork.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-19T11:53:10.000Z","updated_at":"2020-11-20T16:43:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"4650668e-1132-499c-b206-0eb906c2ee68","html_url":"https://github.com/bscheshirwork/docker-codeception-yii2","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bscheshirwork%2Fdocker-codeception-yii2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bscheshirwork%2Fdocker-codeception-yii2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bscheshirwork%2Fdocker-codeception-yii2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bscheshirwork%2Fdocker-codeception-yii2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bscheshirwork","download_url":"https://codeload.github.com/bscheshirwork/docker-codeception-yii2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241174416,"owners_count":19922314,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["codeception","docker-image","yii2"],"created_at":"2024-11-12T10:15:39.513Z","updated_at":"2025-10-30T08:19:15.747Z","avatar_url":"https://github.com/bscheshirwork.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Codeception\n\nBased at :whale:[official images](https://hub.docker.com/r/codeception/codeception/) \nand expand it.\n\nSupported tags and respective `Dockerfile` links\n================================================\n\n\n## for yii2 \n\n- `php7.4.3-fpm-yii2`, `php-fpm-yii2` ([Dockerfile](./Dockerfile))\n\nFROM `bscheshir/php:fpm-4yii2-xdebug` [bscheshir/docker-php](https://github.com/bscheshirwork/docker-php)\n\ntag: `php{sourceref}-fpm-yii2`\n\n`docker pull bscheshir/codeception:php7.4.3-fpm-yii2`\n\n\n## How to create it\n\u003e Note: for https://github.com/Codeception/Codeception.git `master` is deprecated. Use last tag instead (like a 4.0)\n```sh\ncd /home/dev/projects/docker-codeception-yii2/build/\ngit fetch parent\ngit checkout 4.0\ngit pull parent 4.0\ncp ../Dockerfile ../composer.json ./ \ndocker build --pull --no-cache -t bscheshir/codeception:php7.4.3-fpm-alpine-yii2 -t bscheshir/codeception:php-fpm-alpine-yii2 -- .\ndocker push bscheshir/codeception:php7.4.3-fpm-alpine-yii2\ndocker push bscheshir/codeception:php-fpm-alpine-yii2\ngit checkout -- .\n```\n\nWhere\n`Dockerfile`: based on php7 for Yii2 docker image\n```sh\nsed -i -e \"s/^FROM.*/FROM bscheshir\\/php:7.4.3-fpm-4yii2/\" Dockerfile\n```\n\n`composer.json`: require `codeception/specify`, `codeception/verify`\n\n```json\n    \"require\": {\n...\n        \"codeception/specify\": \"*\",\n        \"codeception/verify\": \"*\"\n    }\n```\n\n\u003e Note: change workdir from `/project` to `/var/www/html`. \nThis workdir is same in `php` and `nginx` container (in other yii2-based projects).\nCan be use acceptance tests with same absolute path and merged \"local\" and \"c3.php local\" codecoverage. \n\n## codecept.phar\nThis repo can't modify `codecept.phar`. Origin link for PHP 7.x: `wget http://codeception.com/codecept.phar`\n\nIf you need you changes in \"mothership\" part of c3.php on \"remote\" server \nuse [robo](http://robo.li/) like this (set `php.ini` option `phar.readonly = false`)\n```sh\ndocker-compose -f ~/projects/docker-yii2-app-advanced-rbac/docker-codeception-run/docker-compose.yml run --rm --entrypoint bash codecept\ncd /repo \nwget http://robo.li/robo.phar\nsudo chmod +x robo.phar \u0026\u0026 mv robo.phar /usr/bin/robo\nrobo build:phar\n```\n\n## Usage\n\nDevelopment bash\n```sh\ndocker-codeception-run$ docker-compose run --rm --entrypoint bash codecept\n```\n\nsee [Parallel Execution](http://codeception.com/docs/12-ParallelExecution)\n\n[How to start testing](https://github.com/yiisoft/yii2-app-advanced/blob/master/docs/guide/start-testing.md)\n\n\nyii2-advanced tests inside `backend` `frontend` `console` folder\n```sh\n/usr/local/bin/docker-compose -i /home/dev/projects/docker-yii2-app-advanced-rbac/docker-codeception-run/docker-compose.yml run --rm --entrypoint bash codecept\nroot@e870b32bc227:/project# cd frontend/; codecept run acceptance HomeCest\n```\n\nexternal run\n```sh\n/usr/local/bin/docker-compose -f /path/to/codeception/docker-compose.yml run --rm codecept run -g paracept_1 --html result_1.html\n```\n\n### volumes\nComposition volumes `project` and `.composer/cache` (in `docker-compose.yml`):\n```yml\n  codecept:\n    image: bscheshir/codeception:php7.4.3-fpm-yii2\n    depends_on:\n      - php\n    environment:\n      TZ: Europe/Moscow\n      XDEBUG_CONFIG: \"remote_host=${DEV_REMOTE_HOST} remote_port=${DEV_REMOTE_PORT_CODECEPTION} remote_enable=On\"\n      PHP_IDE_CONFIG: \"serverName=${DEV_SERVER_NAME_CODECEPTION}\"\n    volumes:\n      - ../php-code:/project\n      - ~/.composer/cache:/root/.composer/cache\n```\nwhere `.env` content is\n```ini\nDEV_REMOTE_HOST=192.168.0.241\nDEV_REMOTE_PORT_CODECEPTION=9002\nDEV_SERVER_NAME_CODECEPTION=codeception\n```\n\n## autocomplit\nFor smart IDE autocomplete copy source from the running container to `.codecept` using `docker cp` tools\n```sh\ndocker cp dockercodeceptionrun_codecept_run_1:/repo/ .codecept\n```\n\n### Selenium\nselenium in `docker-compose.yml`\n```yml\n  browser:\n    image: selenium/standalone-firefox-debug:3.141.59\n    ports:\n      - '4444'\n      - '5900'\n```\nor\n```yml\n  browser:\n    image: selenium/standalone-chrome-debug:3.141.59\n    volumes:\n      - /dev/shm:/dev/shm # the docker run instance may use the default 64MB, that may not be enough in some cases\n    ports:\n      - '4444'\n      - '5900'\n```\n\n`codecept` service depends on `selenium` service\n\n\nconfigure `acceptance.suite.yml` in `frontend/tests` like\n```yml\nactor: AcceptanceTester\nmodules:\n    enabled:\n# See docker-codeception-run/docker-compose.yml: \"ports\" of service \"nginx\" is null; the selenium service named \"firefox\"\n# See nginx-conf/nginx.conf: listen 80 for frontend; listen 8080 for backend\n        - WebDriver:\n            url: http://nginx:80/\n            host: firefox\n            port: 4444\n            browser: firefox\n        - Yii2:\n            part: init\n```\nor\n```yml\nactor: AcceptanceTester\nmodules:\n    enabled:\n# See docker-codeception-run/docker-compose.yml: \"ports\" of service \"nginx\" is null; the selenium service named \"chrome\"\n# See nginx-conf/nginx.conf: listen 80 for frontend; listen 8080 for backend\n        - WebDriver:\n            url: http://nginx:8080/\n            host: chrome\n            port: 4444\n            browser: chrome\n        - \\bscheshirwork\\Codeception\\Module\\DbYii2Config:\n            dump: ../common/tests/_data/dump.sql #relative path from \"codeception.yml\"\n        - Yii2:\n            part:\n              - email\n              - ORM\n              - Fixtures\n            cleanup: false # don't wrap test in transaction\n        - common\\tests\\Helper\\Acceptance\n\n```\n\n### yii2 index-test.php docker selenium access\nAfter run yii2 `init` script you must change local entrypoint files \n`php-code/backend/web/index-test.php`, `php-code/frontend/web/index-test.php` for granted access from service firefox.\n```php\nif (!in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'])) {\n    die('You are not allowed to access this file.');\n}\n```\n-\u003e\n```php\n//check if not in same subnet /16 (255.255.0.0)\nif ((ip2long(@$_SERVER['REMOTE_ADDR']) ^ ip2long(@$_SERVER['SERVER_ADDR'])) \u003e= 2 ** 16) {\n    die('You are not allowed to access this file.');\n}\n```\n\n### yii2 [docker-compose.yml](https://github.com/bscheshirwork/docker-yii2-app-advanced/blob/master/docker-codeception-run/docker-compose.yml)\n```yml\nversion: '2'\nservices:\n  php:\n    image: bscheshir/php:7.4.3-fpm-4yii2-xdebug\n    restart: always\n    volumes:\n      - ../php-code:/var/www/html #php-code\n      - ~/.composer/cache:/root/.composer/cache\n    depends_on:\n      - db\n    environment:\n      TZ: Europe/Moscow\n      XDEBUG_CONFIG: \"remote_host=${DEV_REMOTE_HOST} remote_port=${DEV_REMOTE_PORT} remote_enable=On var_display_max_data=1024 var_display_max_depth=5\"\n      PHP_IDE_CONFIG: \"serverName=${DEV_SERVER_NAME}\"\n  nginx:\n    image: nginx:1.17.8-alpine\n    restart: always\n    depends_on:\n      - php\n    volumes_from:\n      - php\n    volumes:\n      - ../nginx-conf:/etc/nginx/conf.d #nginx-conf\n      - ../nginx-logs:/var/log/nginx #nginx-logs\n  db:\n    image: mysql:8.0.19\n    entrypoint:\n      - '/entrypoint.sh'\n      - '--default-authentication-plugin=mysql_native_password' # https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin\n    restart: always\n    ports:\n      - \"33006:3306\"\n    volumes:\n      - ../mysql-data-test/db:/var/lib/mysql #mysql-data\n    environment:\n      TZ: Europe/Moscow\n      MYSQL_ROOT_PASSWORD: yii2advanced\n      MYSQL_DATABASE: yii2advanced\n      MYSQL_USER: yii2advanced\n      MYSQL_PASSWORD: yii2advanced\n  codecept:\n    image: bscheshir/codeception:php7.4.3-fpm-yii2\n    depends_on:\n      - nginx\n      - browser\n    environment:\n      TZ: Europe/Moscow\n      XDEBUG_CONFIG: \"remote_host=${DEV_REMOTE_HOST} remote_port=${DEV_REMOTE_PORT_CODECEPTION} remote_enable=On\"\n      PHP_IDE_CONFIG: \"serverName=${DEV_SERVER_NAME_CODECEPTION}\"\n    volumes:\n      - ../php-code:/project\n      - ~/.composer/cache:/root/.composer/cache\n  browser:\n    image: selenium/standalone-chrome-debug:3.141.59\n    volumes:\n      - /dev/shm:/dev/shm # the docker run instance may use the default 64MB, that may not be enough in some cases\n    ports:\n      - '4444'\n      - '5900'\n```\n\n## debug\n\ncopy source from the running container to `.codecept` using `docker cp` tools (include actual vendors)\n```\ndocker cp dockercodeceptionrun_codecept_run_1:/repo/ .codecept\n```\n\nFor xdebug tests\n\nIn PHPStorm set this settings:\n\nAdd `service` named by PHP_IDE_CONFIG\n`Settings \u003e Languages \u0026 Frameworks \u003e PHP \u003e Servers: [Name =\u003e codeception]`\nIn this service set the `path mapping`.\n\n`Settings \u003e Languages \u0026 Frameworks \u003e PHP \u003e Servers: [Use path mapping =\u003e True, /home/user/yourprojectname/.codecept =\u003e /repo, /home/user/yourprojectname/php-code =\u003e /project]`\n\nChange port 9000 to `XDEBUG_CONFIG` `remote_port` value\n\n`Settings \u003e Languages \u0026 Frameworks \u003e PHP \u003e Debug: [Debug port =\u003e 9002]`\n\n\nIf you need change source inside container use `docker cp`\n```\ndocker cp .codecept/src/Codeception/Lib/Connector/Yii2.php dockercodeceptionrun_codecept_run_1_hash:/repo/src/Codeception/Lib/Connector/Yii2.php\ndocker cp .codecept/src/Codeception/Module/Yii2.php dockercodeceptionrun_codecept_run_1_hash:/repo/src/Codeception/Module/Yii2.php\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbscheshirwork%2Fdocker-codeception-yii2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbscheshirwork%2Fdocker-codeception-yii2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbscheshirwork%2Fdocker-codeception-yii2/lists"}