From 5937fcbd52517857c00b44e49bc34106166f9148 Mon Sep 17 00:00:00 2001 From: leocavalcante Date: 2024年1月31日 18:04:50 -0300 Subject: [PATCH 001/130] fix(phpctl.ini): Map volume only if it exists --- src/docker.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/docker.sh b/src/docker.sh index 033d277..51121b5 100644 --- a/src/docker.sh +++ b/src/docker.sh @@ -23,6 +23,12 @@ images() { run() { echo -e "Running 033円[0;32m$PHPCTL_IMAGE033円[0m" + + local phpctlini="" + if [ -s phpctl.ini ]; then + phpctlini="-v $(pwd)/phpctl.ini:/etc/php$PHP_VERSION/conf.d/zzzphp.ini" + fi + # shellcheck disable=SC2046 # shellcheck disable=SC2154 $PHPCTL_RUNTIME run \ @@ -33,7 +39,7 @@ run() { -v /var/run/docker.sock:/var/run/docker.sock \ -v ~/.gitconfig:/root/.gitconfig:ro \ -v "$(pwd)":/usr/local/src -w /usr/local/src \ - -v "$(pwd)"/phpctl.ini:/etc/php"$PHP_VERSION"/conf.d/zzzphp.ini \ + $phpctlini \ --net host --entrypoint sh \ ${args[@]} "1ドル" "$PHPCTL_IMAGE" -c "${*:2}" } From bdcd57032c73ef743f72764c317a6b9c9217f0f7 Mon Sep 17 00:00:00 2001 From: leocavalcante Date: 2024年1月31日 18:22:12 -0300 Subject: [PATCH 002/130] chore(deps): Bump --- examples/pest/composer.lock | 194 ++++++++++++++++++------------------ 1 file changed, 98 insertions(+), 96 deletions(-) diff --git a/examples/pest/composer.lock b/examples/pest/composer.lock index fe3c9f4..fbc6d7a 100644 --- a/examples/pest/composer.lock +++ b/examples/pest/composer.lock @@ -104,16 +104,16 @@ }, { "name": "doctrine/deprecations", - "version": "1.1.2", + "version": "1.1.3", "source": { "type": "git", "url": "https://github.com/doctrine/deprecations.git", - "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931" + "reference": "dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/4f2d4f2836e7ec4e7a8625e75c6aa916004db931", - "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab", + "reference": "dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab", "shasum": "" }, "require": { @@ -145,9 +145,9 @@ "homepage": "https://www.doctrine-project.org/", "support": { "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/1.1.2" + "source": "https://github.com/doctrine/deprecations/tree/1.1.3" }, - "time": "2023-09-27T20:04:15+00:00" + "time": "2024-01-30T19:34:25+00:00" }, { "name": "fidry/cpu-core-counter", @@ -401,25 +401,27 @@ }, { "name": "nikic/php-parser", - "version": "v4.18.0", + "version": "v5.0.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999" + "reference": "4a21235f7e56e713259a6f76bf4b5ea08502b9dc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/1bcbb2179f97633e98bbbc87044ee2611c7d7999", - "reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/4a21235f7e56e713259a6f76bf4b5ea08502b9dc", + "reference": "4a21235f7e56e713259a6f76bf4b5ea08502b9dc", "shasum": "" }, "require": { + "ext-ctype": "*", + "ext-json": "*", "ext-tokenizer": "*", - "php": ">=7.0" + "php": ">=7.4" }, "require-dev": { "ircmaxell/php-yacc": "^0.0.7", - "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0" + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" }, "bin": [ "bin/php-parse" @@ -427,7 +429,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.9-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -451,44 +453,44 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.18.0" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.0.0" }, - "time": "2023-12-10T21:03:43+00:00" + "time": "2024-01-07T17:17:35+00:00" }, { "name": "nunomaduro/collision", - "version": "v8.0.1", + "version": "v8.1.0", "source": { "type": "git", "url": "https://github.com/nunomaduro/collision.git", - "reference": "0225cf94fc9aaf645bbc42b5fc838aace025e0e3" + "reference": "0d655ffbf3edf9b366e0eea5ab9c7871e0ab3357" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nunomaduro/collision/zipball/0225cf94fc9aaf645bbc42b5fc838aace025e0e3", - "reference": "0225cf94fc9aaf645bbc42b5fc838aace025e0e3", + "url": "https://api.github.com/repos/nunomaduro/collision/zipball/0d655ffbf3edf9b366e0eea5ab9c7871e0ab3357", + "reference": "0d655ffbf3edf9b366e0eea5ab9c7871e0ab3357", "shasum": "" }, "require": { "filp/whoops": "^2.15.4", "nunomaduro/termwind": "^2.0.0", "php": "^8.2.0", - "symfony/console": "^7.0.1" + "symfony/console": "^7.0.2" }, "conflict": { "laravel/framework": "<11.0.0 ||>=12.0.0", - "phpunit/phpunit": "<10.5.1 ||>=11.0.0" + "phpunit/phpunit": "<10.5.1 ||>=12.0.0" }, "require-dev": { + "larastan/larastan": "^2.8.1", "laravel/framework": "^11.0.0", - "laravel/pint": "^1.13.6", - "laravel/sail": "^1.26.2", + "laravel/pint": "^1.13.8", + "laravel/sail": "^1.27.0", "laravel/sanctum": "^4.0.0", - "laravel/tinker": "dev-develop", - "nunomaduro/larastan": "^3.0.0", + "laravel/tinker": "^2.9.0", "orchestra/testbench-core": "^9.0.0", - "pestphp/pest": "^2.27.0", - "sebastian/environment": "^6.0.1" + "pestphp/pest": "^2.31.0 || ^3.0.0", + "sebastian/environment": "^6.0.1 || ^7.0.0" }, "type": "library", "extra": { @@ -550,7 +552,7 @@ "type": "patreon" } ], - "time": "2023-12-08T16:03:53+00:00" + "time": "2024-01-12T13:38:24+00:00" }, { "name": "nunomaduro/termwind", @@ -642,36 +644,36 @@ }, { "name": "pestphp/pest", - "version": "v2.30.0", + "version": "v2.33.2", "source": { "type": "git", "url": "https://github.com/pestphp/pest.git", - "reference": "97dc32f9d24b84dd071d9e89438a19e43c833f6f" + "reference": "eeade88ad236f881f044430e0e9fefaad255718f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pestphp/pest/zipball/97dc32f9d24b84dd071d9e89438a19e43c833f6f", - "reference": "97dc32f9d24b84dd071d9e89438a19e43c833f6f", + "url": "https://api.github.com/repos/pestphp/pest/zipball/eeade88ad236f881f044430e0e9fefaad255718f", + "reference": "eeade88ad236f881f044430e0e9fefaad255718f", "shasum": "" }, "require": { "brianium/paratest": "^7.3.1", - "nunomaduro/collision": "^7.10.0|^8.0.1", + "nunomaduro/collision": "^7.10.0|^8.1.0", "nunomaduro/termwind": "^1.15.1|^2.0.0", "pestphp/pest-plugin": "^2.1.1", - "pestphp/pest-plugin-arch": "^2.5.0", + "pestphp/pest-plugin-arch": "^2.7.0", "php": "^8.1.0", - "phpunit/phpunit": "^10.5.5" + "phpunit/phpunit": "^10.5.9" }, "conflict": { - "phpunit/phpunit": ">10.5.5", + "phpunit/phpunit": ">10.5.9", "sebastian/exporter": "<5.1.0", "webmozart/assert": "<1.11.0" }, "require-dev": { "pestphp/pest-dev-tools": "^2.16.0", - "pestphp/pest-plugin-type-coverage": "^2.6.0", - "symfony/process": "^6.4.0|^7.0.0" + "pestphp/pest-plugin-type-coverage": "^2.8.0", + "symfony/process": "^6.4.0|^7.0.2" }, "bin": [ "bin/pest" @@ -734,7 +736,7 @@ ], "support": { "issues": "https://github.com/pestphp/pest/issues", - "source": "https://github.com/pestphp/pest/tree/v2.30.0" + "source": "https://github.com/pestphp/pest/tree/v2.33.2" }, "funding": [ { @@ -746,7 +748,7 @@ "type": "github" } ], - "time": "2023-12-28T10:36:40+00:00" + "time": "2024-01-29T12:50:00+00:00" }, { "name": "pestphp/pest-plugin", @@ -820,26 +822,26 @@ }, { "name": "pestphp/pest-plugin-arch", - "version": "v2.5.0", + "version": "v2.7.0", "source": { "type": "git", "url": "https://github.com/pestphp/pest-plugin-arch.git", - "reference": "8d850753f0192c3fa1ed6c6cac6f76b718d131db" + "reference": "d23b2d7498475354522c3818c42ef355dca3fcda" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pestphp/pest-plugin-arch/zipball/8d850753f0192c3fa1ed6c6cac6f76b718d131db", - "reference": "8d850753f0192c3fa1ed6c6cac6f76b718d131db", + "url": "https://api.github.com/repos/pestphp/pest-plugin-arch/zipball/d23b2d7498475354522c3818c42ef355dca3fcda", + "reference": "d23b2d7498475354522c3818c42ef355dca3fcda", "shasum": "" }, "require": { - "nunomaduro/collision": "^7.10.0|^8.0.0", + "nunomaduro/collision": "^7.10.0|^8.1.0", "pestphp/pest-plugin": "^2.1.1", "php": "^8.1", - "ta-tikoma/phpunit-architecture-test": "^0.7.5" + "ta-tikoma/phpunit-architecture-test": "^0.8.4" }, "require-dev": { - "pestphp/pest": "^2.27.0", + "pestphp/pest": "^2.33.0", "pestphp/pest-dev-tools": "^2.16.0" }, "type": "library", @@ -875,7 +877,7 @@ "unit" ], "support": { - "source": "https://github.com/pestphp/pest-plugin-arch/tree/v2.5.0" + "source": "https://github.com/pestphp/pest-plugin-arch/tree/v2.7.0" }, "funding": [ { @@ -887,7 +889,7 @@ "type": "github" } ], - "time": "2023-12-05T19:01:10+00:00" + "time": "2024-01-26T09:46:42+00:00" }, { "name": "phar-io/manifest", @@ -1112,16 +1114,16 @@ }, { "name": "phpdocumentor/type-resolver", - "version": "1.7.3", + "version": "1.8.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419" + "reference": "fad452781b3d774e3337b0c0b245dd8e5a4455fc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419", - "reference": "3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/fad452781b3d774e3337b0c0b245dd8e5a4455fc", + "reference": "fad452781b3d774e3337b0c0b245dd8e5a4455fc", "shasum": "" }, "require": { @@ -1164,22 +1166,22 @@ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "support": { "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.7.3" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.8.0" }, - "time": "2023-08-12T11:01:26+00:00" + "time": "2024-01-11T11:49:22+00:00" }, { "name": "phpstan/phpdoc-parser", - "version": "1.24.5", + "version": "1.25.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "fedf211ff14ec8381c9bf5714e33a7a552dd1acc" + "reference": "bd84b629c8de41aa2ae82c067c955e06f1b00240" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/fedf211ff14ec8381c9bf5714e33a7a552dd1acc", - "reference": "fedf211ff14ec8381c9bf5714e33a7a552dd1acc", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/bd84b629c8de41aa2ae82c067c955e06f1b00240", + "reference": "bd84b629c8de41aa2ae82c067c955e06f1b00240", "shasum": "" }, "require": { @@ -1211,9 +1213,9 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.5" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.25.0" }, - "time": "2023-12-16T09:33:33+00:00" + "time": "2024-01-04T17:06:16+00:00" }, { "name": "phpunit/php-code-coverage", @@ -1538,16 +1540,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.5.5", + "version": "10.5.9", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "ed21115d505b4b4f7dc7b5651464e19a2c7f7856" + "reference": "0bd663704f0165c9e76fe4f06ffa6a1ca727fdbe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ed21115d505b4b4f7dc7b5651464e19a2c7f7856", - "reference": "ed21115d505b4b4f7dc7b5651464e19a2c7f7856", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/0bd663704f0165c9e76fe4f06ffa6a1ca727fdbe", + "reference": "0bd663704f0165c9e76fe4f06ffa6a1ca727fdbe", "shasum": "" }, "require": { @@ -1619,7 +1621,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.5" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.9" }, "funding": [ { @@ -1635,7 +1637,7 @@ "type": "tidelift" } ], - "time": "2023-12-27T15:13:52+00:00" + "time": "2024-01-22T14:35:40+00:00" }, { "name": "psr/container", @@ -2657,16 +2659,16 @@ }, { "name": "symfony/console", - "version": "v7.0.1", + "version": "v7.0.3", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "cdce5c684b2f920bb1343deecdfba356ffad83d5" + "reference": "c5010d50f1ee4b25cfa0201d9915cf1b14071456" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/cdce5c684b2f920bb1343deecdfba356ffad83d5", - "reference": "cdce5c684b2f920bb1343deecdfba356ffad83d5", + "url": "https://api.github.com/repos/symfony/console/zipball/c5010d50f1ee4b25cfa0201d9915cf1b14071456", + "reference": "c5010d50f1ee4b25cfa0201d9915cf1b14071456", "shasum": "" }, "require": { @@ -2730,7 +2732,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v7.0.1" + "source": "https://github.com/symfony/console/tree/v7.0.3" }, "funding": [ { @@ -2746,7 +2748,7 @@ "type": "tidelift" } ], - "time": "2023-12-01T15:10:06+00:00" + "time": "2024-01-23T15:02:46+00:00" }, { "name": "symfony/finder", @@ -3144,16 +3146,16 @@ }, { "name": "symfony/process", - "version": "v7.0.0", + "version": "v7.0.3", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "13bdb1670c7f510494e04fcb2bfa29af63db9c0d" + "reference": "937a195147e0c27b2759ade834169ed006d0bc74" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/13bdb1670c7f510494e04fcb2bfa29af63db9c0d", - "reference": "13bdb1670c7f510494e04fcb2bfa29af63db9c0d", + "url": "https://api.github.com/repos/symfony/process/zipball/937a195147e0c27b2759ade834169ed006d0bc74", + "reference": "937a195147e0c27b2759ade834169ed006d0bc74", "shasum": "" }, "require": { @@ -3185,7 +3187,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v7.0.0" + "source": "https://github.com/symfony/process/tree/v7.0.3" }, "funding": [ { @@ -3201,7 +3203,7 @@ "type": "tidelift" } ], - "time": "2023-11-20T16:43:42+00:00" + "time": "2024-01-23T15:02:46+00:00" }, { "name": "symfony/service-contracts", @@ -3287,16 +3289,16 @@ }, { "name": "symfony/string", - "version": "v7.0.0", + "version": "v7.0.3", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "92bd2bfbba476d4a1838e5e12168bef2fd1e6620" + "reference": "524aac4a280b90a4420d8d6a040718d0586505ac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/92bd2bfbba476d4a1838e5e12168bef2fd1e6620", - "reference": "92bd2bfbba476d4a1838e5e12168bef2fd1e6620", + "url": "https://api.github.com/repos/symfony/string/zipball/524aac4a280b90a4420d8d6a040718d0586505ac", + "reference": "524aac4a280b90a4420d8d6a040718d0586505ac", "shasum": "" }, "require": { @@ -3353,7 +3355,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v7.0.0" + "source": "https://github.com/symfony/string/tree/v7.0.3" }, "funding": [ { @@ -3369,32 +3371,32 @@ "type": "tidelift" } ], - "time": "2023-11-29T08:40:23+00:00" + "time": "2024-01-29T15:41:16+00:00" }, { "name": "ta-tikoma/phpunit-architecture-test", - "version": "0.7.5", + "version": "0.8.4", "source": { "type": "git", "url": "https://github.com/ta-tikoma/phpunit-architecture-test.git", - "reference": "9eb08437e8f0c0c75cc947a373cf49672c335827" + "reference": "89f0dea1cb0f0d5744d3ec1764a286af5e006636" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ta-tikoma/phpunit-architecture-test/zipball/9eb08437e8f0c0c75cc947a373cf49672c335827", - "reference": "9eb08437e8f0c0c75cc947a373cf49672c335827", + "url": "https://api.github.com/repos/ta-tikoma/phpunit-architecture-test/zipball/89f0dea1cb0f0d5744d3ec1764a286af5e006636", + "reference": "89f0dea1cb0f0d5744d3ec1764a286af5e006636", "shasum": "" }, "require": { - "nikic/php-parser": "^4.15.4", + "nikic/php-parser": "^4.18.0 || ^5.0.0", "php": "^8.1.0", "phpdocumentor/reflection-docblock": "^5.3.0", - "phpunit/phpunit": "^10.1.1", - "symfony/finder": "^6.2.7 || ^7.0.0" + "phpunit/phpunit": "^10.5.5 || ^11.0.0", + "symfony/finder": "^6.4.0 || ^7.0.0" }, "require-dev": { - "laravel/pint": "^1.9.0", - "phpstan/phpstan": "^1.10.13" + "laravel/pint": "^1.13.7", + "phpstan/phpstan": "^1.10.52" }, "type": "library", "autoload": { @@ -3426,9 +3428,9 @@ ], "support": { "issues": "https://github.com/ta-tikoma/phpunit-architecture-test/issues", - "source": "https://github.com/ta-tikoma/phpunit-architecture-test/tree/0.7.5" + "source": "https://github.com/ta-tikoma/phpunit-architecture-test/tree/0.8.4" }, - "time": "2023-10-12T15:31:50+00:00" + "time": "2024-01-05T14:10:56+00:00" }, { "name": "theseer/tokenizer", From 8d31c63cfba05a5caf0e75be456397a7ea9d6413 Mon Sep 17 00:00:00 2001 From: leocavalcante Date: 2024年1月31日 18:45:22 -0300 Subject: [PATCH 003/130] refactor(tests): Don't track patches --- tests/tools_test.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/tools_test.sh b/tests/tools_test.sh index 4275891..39d4fd1 100644 --- a/tests/tools_test.sh +++ b/tests/tools_test.sh @@ -1,31 +1,31 @@ function test_box() { - assert_contains "Box version 4.5.1" "$(./bin/phpctl box --version)" + assert_contains "Box version 4.5" "$(./bin/phpctl box --version)" } function test_couscous() { - assert_contains "Couscous 1.10.0" "$(./bin/phpctl couscous --version)" + assert_contains "Couscous 1.10" "$(./bin/phpctl couscous --version)" } function test_exakat() { - assert_contains "Version : 2.6.2" "$(./bin/phpctl exakat version)" + assert_contains "Version : 2.6" "$(./bin/phpctl exakat version)" } function test_infection() { - assert_contains "Infection - PHP Mutation Testing Framework version 0.27.9" "$(./bin/phpctl infection --version)" + assert_contains "Infection - PHP Mutation Testing Framework version 0.27" "$(./bin/phpctl infection --version)" } function test_php_cs_fixer() { - assert_contains "PHP CS Fixer 3.46.0" "$(./bin/phpctl php-cs-fixer --version)" + assert_contains "PHP CS Fixer 3.46" "$(./bin/phpctl php-cs-fixer --version)" } function test_phpstan() { - assert_contains "PHPStan - PHP Static Analysis Tool 1.10.55" "$(./bin/phpctl phpstan --version)" + assert_contains "PHPStan - PHP Static Analysis Tool 1.10" "$(./bin/phpctl phpstan --version)" } function test_phpunit() { - assert_contains "PHPUnit 10.5.9" "$(./bin/phpctl phpunit --version)" + assert_contains "PHPUnit 10.5" "$(./bin/phpctl phpunit --version)" } function test_pint() { - assert_contains "Pint 1.13.7" "$(./bin/phpctl pint --version)" + assert_contains "Pint 1.13" "$(./bin/phpctl pint --version)" } From f188ab0429010717864250c8f1fae7dac4525d5c Mon Sep 17 00:00:00 2001 From: leocavalcante Date: 2024年1月31日 18:45:42 -0300 Subject: [PATCH 004/130] feat(tests): phpctl.ini --- tests/php_test.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/php_test.sh b/tests/php_test.sh index ffa36a6..c52d10a 100644 --- a/tests/php_test.sh +++ b/tests/php_test.sh @@ -10,3 +10,9 @@ function test_php_accepts_arguments() { function test_composer() { assert_contains "version" "$(./bin/phpctl composer --version)" } + +function test_phpctl_ini() { + echo "memory_limit=1337M"> phpctl.ini + assert_contains "memory_limit => 1337M => 1337M" "$(./bin/phpctl php -i | grep memory_limit)" + rm phpctl.ini +} From e2003812a013632dfb405245e83624f122967e05 Mon Sep 17 00:00:00 2001 From: leocavalcante Date: 2024年1月31日 18:48:57 -0300 Subject: [PATCH 005/130] feat(composer): Global Closes #8 --- src/docker.sh | 16 +++++++++++++--- src/php.sh | 26 +++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/docker.sh b/src/docker.sh index 51121b5..b99c38a 100644 --- a/src/docker.sh +++ b/src/docker.sh @@ -1,5 +1,6 @@ build() { echo -e "Building 033円[0;32m$PHPCTL_IMAGE033円[0m" + # shellcheck disable=SC2068 # shellcheck disable=SC2154 $PHPCTL_RUNTIME build \ --build-arg PHP="$PHP_VERSION" \ @@ -24,12 +25,20 @@ images() { run() { echo -e "Running 033円[0;32m$PHPCTL_IMAGE033円[0m" - local phpctlini="" + local phpctl_ini="" if [ -s phpctl.ini ]; then - phpctlini="-v $(pwd)/phpctl.ini:/etc/php$PHP_VERSION/conf.d/zzzphp.ini" + phpctl_ini="-v $(pwd)/phpctl.ini:/etc/php$PHP_VERSION/conf.d/zzzphp.ini" + fi + + local composer_home="" + composer_home="$(composer-home)" + if [ -n "$composer_home" ]; then + composer_home="-v $composer_home:$composer_home" fi # shellcheck disable=SC2046 + # shellcheck disable=SC2068 + # shellcheck disable=SC2086 # shellcheck disable=SC2154 $PHPCTL_RUNTIME run \ --platform linux/x86_64 \ @@ -39,7 +48,8 @@ run() { -v /var/run/docker.sock:/var/run/docker.sock \ -v ~/.gitconfig:/root/.gitconfig:ro \ -v "$(pwd)":/usr/local/src -w /usr/local/src \ - $phpctlini \ + $phpctl_ini \ + $composer_home \ --net host --entrypoint sh \ ${args[@]} "1ドル" "$PHPCTL_IMAGE" -c "${*:2}" } diff --git a/src/php.sh b/src/php.sh index 30fd356..54cfbf0 100644 --- a/src/php.sh +++ b/src/php.sh @@ -5,7 +5,19 @@ php() { } composer() { - run -- composer ${@} + if [ "1ドル" = "global" ]; then + COMPOSER_HOME=$(composer-home) + if [ -z "$COMPOSER_HOME" ]; then + echo -e "033円[0;31mCOMPOSER_HOME not set.033円[0m" + exit 1 + fi + + cd "$COMPOSER_HOME" || exit 1 + echo -e "033円[0;32mChanged current directory to $COMPOSER_HOME033円[0m" + run -- composer ${@:2} + else + run -- composer ${@} + fi } repl() { @@ -17,3 +29,15 @@ server() { dir=${2:-.} run -- php -S 0.0.0.0:"$port" -t "$dir" } + +composer-home() { + if [ -z "$COMPOSER_HOME" ]; then + if [ -d ~/.config/composer ]; then + COMPOSER_HOME="$HOME/.config/composer" + elif [ -d ~/.composer ]; then + COMPOSER_HOME="$HOME/.composer" + fi + fi + + echo "$COMPOSER_HOME" +} From 045863685efb56dd5361cb95eeceaa6df7cbbc06 Mon Sep 17 00:00:00 2001 From: Leo Cavalcante Date: Fri, 2 Feb 2024 18:03:24 -0300 Subject: [PATCH 006/130] refactor(run): Output only if in verbose mode (#14) --- src/docker.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/docker.sh b/src/docker.sh index b99c38a..764e7c2 100644 --- a/src/docker.sh +++ b/src/docker.sh @@ -23,7 +23,9 @@ images() { } run() { - echo -e "Running 033円[0;32m$PHPCTL_IMAGE033円[0m" + if [ -n "$PHPCTL_VERBOSE" ]; then + echo -e "Running 033円[0;32m$PHPCTL_IMAGE033円[0m" + fi local phpctl_ini="" if [ -s phpctl.ini ]; then From 8f8f49ca243c3378c8426cad99a90221519ddc70 Mon Sep 17 00:00:00 2001 From: Leo Cavalcante Date: Fri, 2 Feb 2024 19:21:57 -0300 Subject: [PATCH 007/130] fix: Disable TTY in Git hook environments (#15) --- src/docker.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/docker.sh b/src/docker.sh index 764e7c2..36783c5 100644 --- a/src/docker.sh +++ b/src/docker.sh @@ -38,6 +38,11 @@ run() { composer_home="-v $composer_home:$composer_home" fi + if [ -n "$GIT_EXEC_PATH" ]; then + # In a Git hook environment, we need to disable TTY allocation + PHPCTL_TTY="--label=no-tty" + fi + # shellcheck disable=SC2046 # shellcheck disable=SC2068 # shellcheck disable=SC2086 From e7464a2d5214d465031877fb3f4a787baaccde06 Mon Sep 17 00:00:00 2001 From: Yuri Silva Date: Sun, 4 Feb 2024 16:57:25 -0300 Subject: [PATCH 008/130] feat(docker): Add host user (#16) --- Dockerfile | 5 +++++ README.md | 7 +++++++ bin/phpctl | 1 + src/docker.sh | 2 ++ 4 files changed, 15 insertions(+) diff --git a/Dockerfile b/Dockerfile index 9c2d0f1..dd2a835 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,5 +35,10 @@ RUN apk add --update --no-cache \ && ln -sf /usr/bin/php${PHP} /usr/bin/php \ && mv /etc/php/php.ini /etc/php${PHP}/conf.d/zzphp.ini \ && /usr/local/bin/install-tools +ARG HOST_USER +RUN apk add doas; \ + adduser ${HOST_USER}; \ + echo "${HOST_USER}" | chpasswd; \ + echo "permit ${HOST_USER} as root"> /etc/doas.d/doas.conf ENTRYPOINT [ "/usr/bin/php" ] CMD [ "-v" ] diff --git a/README.md b/README.md index 38d5303..0c4f572 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,13 @@ You can use Podman instead of Docker by setting the `PHPCTL_RUNTIME` variable to PHPCTL_RUNTIME=podman phpctl php -v ``` +### Host user + +By default, `phpctl` creates an user considering host user. You can change from `root` to host user through `PHPCTL_USER` variable. +```shell +PHPCTL_USER=your_user phpctl sh whoami +``` + ## The `phpctl.ini` file You can also add a `phpctl.ini` file at project's root directory to set any [`php.ini` directive](https://www.php.net/manual/en/ini.list.php). ```ini diff --git a/bin/phpctl b/bin/phpctl index 3b5bcbc..2c58b6b 100755 --- a/bin/phpctl +++ b/bin/phpctl @@ -10,6 +10,7 @@ PHP_VERSION=${PHP_VERSION:-82} PHPCTL_IMAGE=${PHPCTL_IMAGE:-opencodeco/phpctl:php$PHP_VERSION} PHPCTL_TTY=${PHPCTL_TTY:--it} PHPCTL_RUNTIME=${PHPCTL_RUNTIME:-docker} +PHPCTL_USER=${PHPCTL_USER:-root} for file in "$PHPCTL_DIR"/src/*.sh; do # shellcheck source=src/php.sh diff --git a/src/docker.sh b/src/docker.sh index 36783c5..d41652e 100644 --- a/src/docker.sh +++ b/src/docker.sh @@ -5,6 +5,7 @@ build() { $PHPCTL_RUNTIME build \ --build-arg PHP="$PHP_VERSION" \ --build-arg COMPOSER_AUTH="$COMPOSER_AUTH" \ + --build-arg HOST_USER="$(whoami)" \ ${build[@]} -t "$PHPCTL_IMAGE" . } @@ -51,6 +52,7 @@ run() { --platform linux/x86_64 \ --rm "$PHPCTL_TTY" \ --name "phpctl_$(openssl rand -hex 6)" \ + --user "$PHPCTL_USER" \ $(env | awk -F= '/^[[:alpha:]]/{print 1ドル}' | sed 's/^/-e/') \ -v /var/run/docker.sock:/var/run/docker.sock \ -v ~/.gitconfig:/root/.gitconfig:ro \ From 322b3a86206f0247b7ef7f180ef8176a0d555916 Mon Sep 17 00:00:00 2001 From: leocavalcante Date: Sun, 4 Feb 2024 17:21:22 -0300 Subject: [PATCH 009/130] feat(doctor): Prints all PHPCTL_* environment variables --- src/doctor.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/doctor.sh b/src/doctor.sh index c9bcef5..61722e6 100644 --- a/src/doctor.sh +++ b/src/doctor.sh @@ -1,4 +1,9 @@ doctor() { - echo -e "033円[0;32mPHP_VERSION033円[0m=$PHP_VERSION" - echo -e "PHPCTL_IMAGE=033円[0;33m$PHPCTL_IMAGE033円[0m" + echo -e "PHP_VERSION=033円[0;32m$PHP_VERSION033円[0m" + + for var in $(set | awk -F= '/^[[:alpha:]]/{print 1ドル}'); do + if [[ $var == PHPCTL_* ]]; then + echo -e "$var=033円[0;32m${!var}033円[0m" + fi + done } From 126693cd9cff5e0c665f858480f11f4cbd127722 Mon Sep 17 00:00:00 2001 From: leocavalcante Date: Sun, 4 Feb 2024 17:33:12 -0300 Subject: [PATCH 010/130] chore(docs): Docs --- docs/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 docs/README.md diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..7b0473c --- /dev/null +++ b/docs/README.md @@ -0,0 +1,3 @@ +# phpctl docs + +This is the very start of a dedicated documentation site for `phpctl`. From 5fd1f88b2c484ef080f087efb86819c34b3200bc Mon Sep 17 00:00:00 2001 From: Leo Cavalcante Date: Sun, 4 Feb 2024 17:38:46 -0300 Subject: [PATCH 011/130] Create CNAME --- docs/CNAME | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/CNAME diff --git a/docs/CNAME b/docs/CNAME new file mode 100644 index 0000000..4c18aa5 --- /dev/null +++ b/docs/CNAME @@ -0,0 +1 @@ +phpctl.dev \ No newline at end of file From c34b971b9dd035bbb8b40e1641003104fd05f8c8 Mon Sep 17 00:00:00 2001 From: Leo Cavalcante Date: Sun, 4 Feb 2024 17:40:48 -0300 Subject: [PATCH 012/130] chore(docs): Index page --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index 7b0473c..7d19e1f 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,3 +1,3 @@ -# phpctl docs +# Welcome This is the very start of a dedicated documentation site for `phpctl`. From 1a165383e829b23d71cf3b430a2eaa860b675615 Mon Sep 17 00:00:00 2001 From: Leo Cavalcante Date: Sun, 4 Feb 2024 17:49:58 -0300 Subject: [PATCH 013/130] chore(docs): Config --- docs/_config.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/_config.yml diff --git a/docs/_config.yml b/docs/_config.yml new file mode 100644 index 0000000..8bbf794 --- /dev/null +++ b/docs/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-hacker From 286f56fe6ddc9143ea818a85ca2ae2c5534192aa Mon Sep 17 00:00:00 2001 From: leocavalcante Date: Sun, 4 Feb 2024 18:55:25 -0300 Subject: [PATCH 014/130] refactor(installation): Dynamic symbolic linking --- Makefile | 14 +------------- installer.sh | 41 ++++++----------------------------------- scripts/symlink-bins.sh | 5 +++++ 3 files changed, 12 insertions(+), 48 deletions(-) create mode 100755 scripts/symlink-bins.sh diff --git a/Makefile b/Makefile index 26d428f..84b7309 100644 --- a/Makefile +++ b/Makefile @@ -11,16 +11,4 @@ test: .PHONY: install install: - @sudo ln -sf $(shell pwd)/bin/composer /usr/local/bin/composer - @sudo ln -sf $(shell pwd)/bin/php /usr/local/bin/php - @sudo ln -sf $(shell pwd)/bin/php-cs-fixer /usr/local/bin/php-cs-fixer - @sudo ln -sf $(shell pwd)/bin/phpctl /usr/local/bin/pctl - @sudo ln -sf $(shell pwd)/bin/phpctl /usr/local/bin/phpctl - @sudo ln -sf $(shell pwd)/bin/phpstan /usr/local/bin/phpstan - @sudo ln -sf $(shell pwd)/bin/phpunit /usr/local/bin/phpunit - @sudo ln -sf $(shell pwd)/bin/infection /usr/local/bin/infection - @sudo ln -sf $(shell pwd)/bin/pest /usr/local/bin/pest - @sudo ln -sf $(shell pwd)/bin/pint /usr/local/bin/pint - @sudo ln -sf $(shell pwd)/bin/exakat /usr/local/bin/exakat - @sudo ln -sf $(shell pwd)/bin/frankenphp /usr/local/bin/frankenphp - @sudo ln -sf $(shell pwd)/bin/rector /usr/local/bin/rector + @sudo ./scripts/symlink-bins.sh diff --git a/installer.sh b/installer.sh index 511c6f9..88941e7 100755 --- a/installer.sh +++ b/installer.sh @@ -3,28 +3,12 @@ INSTALL_DIR=~/.phpctl if [ -z "1ドル" ]; then SUDO=sudo - SYMLINK_DIR=/usr/local/bin/ + SYMLINK_DIR=/usr/local/bin else SUDO="" SYMLINK_DIR=1ドル fi -symlink() { - $SUDO ln -sf "${INSTALL_DIR}/bin/composer" "${SYMLINK_DIR}/composer" - $SUDO ln -sf "${INSTALL_DIR}/bin/php" "${SYMLINK_DIR}/php" - $SUDO ln -sf "${INSTALL_DIR}/bin/php-cs-fixer" "${SYMLINK_DIR}/php-cs-fixer" - $SUDO ln -sf "${INSTALL_DIR}/bin/phpctl" "${SYMLINK_DIR}/pctl" - $SUDO ln -sf "${INSTALL_DIR}/bin/phpctl" "${SYMLINK_DIR}/phpctl" - $SUDO ln -sf "${INSTALL_DIR}/bin/phpstan" "${SYMLINK_DIR}/phpstan" - $SUDO ln -sf "${INSTALL_DIR}/bin/infection" "${SYMLINK_DIR}/infection" - $SUDO ln -sf "${INSTALL_DIR}/bin/phpunit" "${SYMLINK_DIR}/phpunit" - $SUDO ln -sf "${INSTALL_DIR}/bin/pest" "${SYMLINK_DIR}/pest" - $SUDO ln -sf "${INSTALL_DIR}/bin/pint" "${SYMLINK_DIR}/pint" - $SUDO ln -sf "${INSTALL_DIR}/bin/exakat" "${SYMLINK_DIR}/exakat" - $SUDO ln -sf "${INSTALL_DIR}/bin/frankenphp" "${SYMLINK_DIR}/frankenphp" - $SUDO ln -sf "${INSTALL_DIR}/bin/rector" "${SYMLINK_DIR}/rector" -} - echo "033円[0;33mInstalling phpctl at 033円[0m$INSTALL_DIR" if [ -d "$INSTALL_DIR" ]; then echo "The install directory is not empty. Attempting to remove it..." @@ -50,25 +34,12 @@ fi echo -n " 033円[0;32mDo you want to continue? (y/n)033円[0m " read -r answer if [ "$answer" != "${answer#[Yy]}" ]; then - symlink + $SUDO ${INSTALL_DIR}/scripts/symlink-bins.sh else echo "033円[0;31mTo use phpctl globally, link the cloned script to your bin directory, like:033円[0m" echo "" - echo " ${SUDO} ln -sf ${INSTALL_DIR}/bin/php ${SYMLINK_DIR}/php" - echo " ${SUDO} ln -sf ${INSTALL_DIR}/bin/composer ${SYMLINK_DIR}/composer" - echo " ${SUDO} ln -sf ${INSTALL_DIR}/bin/phpctl ${SYMLINK_DIR}/phpctl" - echo " ${SUDO} ln -sf ${INSTALL_DIR}/bin/phpctl ${SYMLINK_DIR}/pctl" - echo "" - echo "033円[0;31mYou can also complement with another useful binaries:033円[0m" - echo "" - echo " ${SUDO} ln -sf ${INSTALL_DIR}/bin/phpunit ${SYMLINK_DIR}/phpunit" - echo " ${SUDO} ln -sf ${INSTALL_DIR}/bin/php-cs-fixer ${SYMLINK_DIR}/php-cs-fixer" - echo " ${SUDO} ln -sf ${INSTALL_DIR}/bin/phpstan ${SYMLINK_DIR}/phpstan" - echo " ${SUDO} ln -sf ${INSTALL_DIR}/bin/infection ${SYMLINK_DIR}/infection" - echo " ${SUDO} ln -sf ${INSTALL_DIR}/bin/pest ${SYMLINK_DIR}/pest" - echo " ${SUDO} ln -sf ${INSTALL_DIR}/bin/pint ${SYMLINK_DIR}/pint" - echo " ${SUDO} ln -sf ${INSTALL_DIR}/bin/exakat ${SYMLINK_DIR}/exakat" - echo " ${SUDO} ln -sf ${INSTALL_DIR}/bin/frankenphp ${SYMLINK_DIR}/frankenphp" - echo " ${SUDO} ln -sf ${INSTALL_DIR}/bin/rector ${SYMLINK_DIR}/rector" - echo "" + for file in ./bin/*; do + bin=$(basename "$file") + echo " ${SUDO} ln -sf ${INSTALL_DIR}/bin/$bin ${SYMLINK_DIR}/$bin" + done fi diff --git a/scripts/symlink-bins.sh b/scripts/symlink-bins.sh new file mode 100755 index 0000000..e5a9327 --- /dev/null +++ b/scripts/symlink-bins.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +for file in ./bin/*; do + bin=$(basename "$file") + ln -sf "$(pwd)/bin/$bin" "/usr/local/bin/$bin" +done From 1f4ba5ff60e63d5d56ab52e20da442106c60779c Mon Sep 17 00:00:00 2001 From: leocavalcante Date: Sun, 4 Feb 2024 19:13:07 -0300 Subject: [PATCH 015/130] fix(installation): Install directory --- installer.sh | 2 +- scripts/symlink-bins.sh | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/installer.sh b/installer.sh index 88941e7..e593d99 100755 --- a/installer.sh +++ b/installer.sh @@ -34,7 +34,7 @@ fi echo -n " 033円[0;32mDo you want to continue? (y/n)033円[0m " read -r answer if [ "$answer" != "${answer#[Yy]}" ]; then - $SUDO ${INSTALL_DIR}/scripts/symlink-bins.sh + $SUDO ${INSTALL_DIR}/scripts/symlink-bins.sh ${INSTALL_DIR} else echo "033円[0;31mTo use phpctl globally, link the cloned script to your bin directory, like:033円[0m" echo "" diff --git a/scripts/symlink-bins.sh b/scripts/symlink-bins.sh index e5a9327..fe5fdf4 100755 --- a/scripts/symlink-bins.sh +++ b/scripts/symlink-bins.sh @@ -1,5 +1,4 @@ #!/usr/bin/env bash -for file in ./bin/*; do - bin=$(basename "$file") - ln -sf "$(pwd)/bin/$bin" "/usr/local/bin/$bin" +for file in "${1:-.}"/bin/*; do + ln -sf "$file" "/usr/local/bin/$(basename "$file")" done From 17e6fa08d6eb57b25bf3646bb09a37ebbcebb0f6 Mon Sep 17 00:00:00 2001 From: leocavalcante Date: Sun, 4 Feb 2024 19:21:57 -0300 Subject: [PATCH 016/130] fix(installation): Install directory --- installer.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer.sh b/installer.sh index e593d99..c3fb5e0 100755 --- a/installer.sh +++ b/installer.sh @@ -38,7 +38,7 @@ if [ "$answer" != "${answer#[Yy]}" ]; then else echo "033円[0;31mTo use phpctl globally, link the cloned script to your bin directory, like:033円[0m" echo "" - for file in ./bin/*; do + for file in "${INSTALL_DIR}"/bin/*; do bin=$(basename "$file") echo " ${SUDO} ln -sf ${INSTALL_DIR}/bin/$bin ${SYMLINK_DIR}/$bin" done From 8838d4d2a91b29cdd13f679bd76579c5dcd9ac9d Mon Sep 17 00:00:00 2001 From: leocavalcante Date: Sun, 4 Feb 2024 19:36:39 -0300 Subject: [PATCH 017/130] feat(tests): Installation --- tests/alpine/Dockerfile | 4 ++++ tests/alpine/Makefile | 21 +++++++++++++++++++++ tests/alpine/README.md | 5 +++++ 3 files changed, 30 insertions(+) create mode 100644 tests/alpine/Dockerfile create mode 100644 tests/alpine/Makefile create mode 100644 tests/alpine/README.md diff --git a/tests/alpine/Dockerfile b/tests/alpine/Dockerfile new file mode 100644 index 0000000..0b45e0b --- /dev/null +++ b/tests/alpine/Dockerfile @@ -0,0 +1,4 @@ +FROM alpine +RUN apk add bash docker git make openssl sudo +WORKDIR /usr/local/src +COPY Makefile . diff --git a/tests/alpine/Makefile b/tests/alpine/Makefile new file mode 100644 index 0000000..72a3e89 --- /dev/null +++ b/tests/alpine/Makefile @@ -0,0 +1,21 @@ +.PHONY: default +default: build run + +.PHONY: build +build: + docker build -t phpctl-alpine-test . + +.PHONY: run +run: + docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock phpctl-alpine-test sh + +.PHONY: install +install: + sh <(wget -qO- https://raw.githubusercontent.com/opencodeco/phpctl/main/installer.sh) + +.PHONY: test +test: + ls -lha /usr/local/bin + phpctl doctor + php --version + composer --version diff --git a/tests/alpine/README.md b/tests/alpine/README.md new file mode 100644 index 0000000..6be9d74 --- /dev/null +++ b/tests/alpine/README.md @@ -0,0 +1,5 @@ +This tests the `phpctl` installation in a blank Alpine distribution. + +Run `make` then inside the container run `make install`. + +To check the installation, run `make test`. From d2de144b226ecf90c64ac6a0f385d4f822b1d815 Mon Sep 17 00:00:00 2001 From: leocavalcante Date: Sun, 4 Feb 2024 19:40:15 -0300 Subject: [PATCH 018/130] refactor(bin): Infection permissions --- bin/infection | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 bin/infection diff --git a/bin/infection b/bin/infection old mode 100644 new mode 100755 From e2163f771ce9ed29f1ea8610cede11b9496d9e5c Mon Sep 17 00:00:00 2001 From: leocavalcante Date: Sun, 4 Feb 2024 19:40:39 -0300 Subject: [PATCH 019/130] feat(install): Move to docs to be available in phpctl.dev --- docs/install.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 docs/install.sh diff --git a/docs/install.sh b/docs/install.sh new file mode 100755 index 0000000..c3fb5e0 --- /dev/null +++ b/docs/install.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env sh + +INSTALL_DIR=~/.phpctl +if [ -z "1ドル" ]; then + SUDO=sudo + SYMLINK_DIR=/usr/local/bin +else + SUDO="" + SYMLINK_DIR=1ドル +fi + +echo "033円[0;33mInstalling phpctl at 033円[0m$INSTALL_DIR" +if [ -d "$INSTALL_DIR" ]; then + echo "The install directory is not empty. Attempting to remove it..." + rm -rI $INSTALL_DIR +fi + +echo -n "" +git clone --quiet https://github.com/opencodeco/phpctl.git $INSTALL_DIR & +PID=$! +while kill -0 $PID 2> /dev/null; do + for CHAR in '-' '/' '|' '\'; do + printf "\b$CHAR" + sleep 0.1 + done +done + +echo "\b " +if [ -z "1ドル" ]; then + echo -n "Sudo will be prompted to symlink the phpctl files." +else + echo -n "Files will be symlinked to ${SYMLINK_DIR}." +fi +echo -n " 033円[0;32mDo you want to continue? (y/n)033円[0m " +read -r answer +if [ "$answer" != "${answer#[Yy]}" ]; then + $SUDO ${INSTALL_DIR}/scripts/symlink-bins.sh ${INSTALL_DIR} +else + echo "033円[0;31mTo use phpctl globally, link the cloned script to your bin directory, like:033円[0m" + echo "" + for file in "${INSTALL_DIR}"/bin/*; do + bin=$(basename "$file") + echo " ${SUDO} ln -sf ${INSTALL_DIR}/bin/$bin ${SYMLINK_DIR}/$bin" + done +fi From e4ad460a016900a35363ef3f292601c3e4342916 Mon Sep 17 00:00:00 2001 From: leocavalcante Date: Sun, 4 Feb 2024 19:44:02 -0300 Subject: [PATCH 020/130] refactor(installer): Working from phpctl.dev --- README.md | 4 ++-- installer.sh | 45 ------------------------------------------- tests/alpine/Makefile | 2 +- 3 files changed, 3 insertions(+), 48 deletions(-) delete mode 100755 installer.sh diff --git a/README.md b/README.md index 0c4f572..ccdfc1d 100644 --- a/README.md +++ b/README.md @@ -32,12 +32,12 @@ Take the advantage of goodie commands like `phpctl create` to start a new projec ### Install If you want to install it system-wide (at `/usr/local/bin`), run: ```shell -sh <(wget -qO- https://raw.githubusercontent.com/opencodeco/phpctl/main/installer.sh) +sh <(wget -qO- https://phpctl.dev/install.sh) ``` You can also pass an argument to install at a custom location (e.g. `~/bin`), but you have to make sure that folder is in your `$PATH` variable. ```shell -sh <(wget -qO- https://raw.githubusercontent.com/opencodeco/phpctl/main/installer.sh) ~/bin +sh <(wget -qO- https://phpctl.dev/install.sh) ~/bin ``` #### Update diff --git a/installer.sh b/installer.sh deleted file mode 100755 index c3fb5e0..0000000 --- a/installer.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env sh - -INSTALL_DIR=~/.phpctl -if [ -z "1ドル" ]; then - SUDO=sudo - SYMLINK_DIR=/usr/local/bin -else - SUDO="" - SYMLINK_DIR=1ドル -fi - -echo "033円[0;33mInstalling phpctl at 033円[0m$INSTALL_DIR" -if [ -d "$INSTALL_DIR" ]; then - echo "The install directory is not empty. Attempting to remove it..." - rm -rI $INSTALL_DIR -fi - -echo -n "" -git clone --quiet https://github.com/opencodeco/phpctl.git $INSTALL_DIR & -PID=$! -while kill -0 $PID 2> /dev/null; do - for CHAR in '-' '/' '|' '\'; do - printf "\b$CHAR" - sleep 0.1 - done -done - -echo "\b " -if [ -z "1ドル" ]; then - echo -n "Sudo will be prompted to symlink the phpctl files." -else - echo -n "Files will be symlinked to ${SYMLINK_DIR}." -fi -echo -n " 033円[0;32mDo you want to continue? (y/n)033円[0m " -read -r answer -if [ "$answer" != "${answer#[Yy]}" ]; then - $SUDO ${INSTALL_DIR}/scripts/symlink-bins.sh ${INSTALL_DIR} -else - echo "033円[0;31mTo use phpctl globally, link the cloned script to your bin directory, like:033円[0m" - echo "" - for file in "${INSTALL_DIR}"/bin/*; do - bin=$(basename "$file") - echo " ${SUDO} ln -sf ${INSTALL_DIR}/bin/$bin ${SYMLINK_DIR}/$bin" - done -fi diff --git a/tests/alpine/Makefile b/tests/alpine/Makefile index 72a3e89..9f2d7ba 100644 --- a/tests/alpine/Makefile +++ b/tests/alpine/Makefile @@ -11,7 +11,7 @@ run: .PHONY: install install: - sh <(wget -qO- https://raw.githubusercontent.com/opencodeco/phpctl/main/installer.sh) + sh <(wget -qO- https://phpctl.dev/install.sh) .PHONY: test test: From 8fcb1ae82e857a6babb5cfbbb24fc6193dd7e006 Mon Sep 17 00:00:00 2001 From: leocavalcante Date: Sun, 4 Feb 2024 20:02:00 -0300 Subject: [PATCH 021/130] refactor(test): Install test for Alpine and Ubuntu --- tests/{alpine => install}/Makefile | 2 +- tests/{alpine => install}/README.md | 2 +- tests/{alpine/Dockerfile => install/alpine.Dockerfile} | 0 tests/install/ubuntu.Dockerfile | 4 ++++ 4 files changed, 6 insertions(+), 2 deletions(-) rename tests/{alpine => install}/Makefile (84%) rename tests/{alpine => install}/README.md (60%) rename tests/{alpine/Dockerfile => install/alpine.Dockerfile} (100%) create mode 100644 tests/install/ubuntu.Dockerfile diff --git a/tests/alpine/Makefile b/tests/install/Makefile similarity index 84% rename from tests/alpine/Makefile rename to tests/install/Makefile index 9f2d7ba..9906387 100644 --- a/tests/alpine/Makefile +++ b/tests/install/Makefile @@ -3,7 +3,7 @@ default: build run .PHONY: build build: - docker build -t phpctl-alpine-test . + docker build -t phpctl-install-test -f ${OS}.Dockerfile . .PHONY: run run: diff --git a/tests/alpine/README.md b/tests/install/README.md similarity index 60% rename from tests/alpine/README.md rename to tests/install/README.md index 6be9d74..a77d308 100644 --- a/tests/alpine/README.md +++ b/tests/install/README.md @@ -1,5 +1,5 @@ This tests the `phpctl` installation in a blank Alpine distribution. -Run `make` then inside the container run `make install`. +Run `make OS=` then inside the container run `make install`. To check the installation, run `make test`. diff --git a/tests/alpine/Dockerfile b/tests/install/alpine.Dockerfile similarity index 100% rename from tests/alpine/Dockerfile rename to tests/install/alpine.Dockerfile diff --git a/tests/install/ubuntu.Dockerfile b/tests/install/ubuntu.Dockerfile new file mode 100644 index 0000000..acac919 --- /dev/null +++ b/tests/install/ubuntu.Dockerfile @@ -0,0 +1,4 @@ +FROM ubuntu +RUN apt update && apt install -y bash docker git make openssl sudo +WORKDIR /usr/local/src +COPY Makefile . From a941c135fd5ef8e7c27d282db85e88475dbf5fc0 Mon Sep 17 00:00:00 2001 From: leocavalcante Date: Sun, 4 Feb 2024 20:57:30 -0300 Subject: [PATCH 022/130] refactor(install): Use bash --- docs/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/install.sh b/docs/install.sh index c3fb5e0..f410008 100755 --- a/docs/install.sh +++ b/docs/install.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash INSTALL_DIR=~/.phpctl if [ -z "1ドル" ]; then From 8565e01acf0eaf7a666badca4e7b112f40ef733f Mon Sep 17 00:00:00 2001 From: leocavalcante Date: Sun, 4 Feb 2024 21:06:25 -0300 Subject: [PATCH 023/130] refactor(install): Installer name --- docs/{install.sh => phpctl-installer.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/{install.sh => phpctl-installer.sh} (100%) diff --git a/docs/install.sh b/docs/phpctl-installer.sh similarity index 100% rename from docs/install.sh rename to docs/phpctl-installer.sh From 38572e8637c1ad28f2cbda9e41acbe68d9957c10 Mon Sep 17 00:00:00 2001 From: leocavalcante Date: Sun, 4 Feb 2024 21:14:00 -0300 Subject: [PATCH 024/130] refactor(tests): Installer --- README.md | 16 ++++++++++------ tests/install/Makefile | 8 +++++--- tests/install/ubuntu.Dockerfile | 2 +- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index ccdfc1d..7d0c12d 100644 --- a/README.md +++ b/README.md @@ -22,23 +22,27 @@ Take the advantage of goodie commands like `phpctl create` to start a new projec ## Getting started -> [!TIP] +> [!TIP] > Pro-tip: use it with [`stack`](https://github.com/opencodeco/stack) to spin up infrastructure components like MySQL, Redis, RabbitMQ etc. ### Requirements +- Bash - Git - Docker ### Install If you want to install it system-wide (at `/usr/local/bin`), run: ```shell -sh <(wget -qO- https://phpctl.dev/install.sh) +wget -q https://phpctl.dev/phpctl-installer.sh +bash phpctl-installer.sh +rm phpctl-installer.sh ``` -You can also pass an argument to install at a custom location (e.g. `~/bin`), but you have to make sure that folder is in your `$PATH` variable. -```shell -sh <(wget -qO- https://phpctl.dev/install.sh) ~/bin -``` +> [!TIP] +> You can also pass an argument to install at a custom location (e.g. `~/bin`), but you have to make sure that folder is in your `$PATH` variable. +> ```shell +> bash phpctl-installer.sh ~/bin +> ``` #### Update You can re-run the installer or use the `self-update` command: diff --git a/tests/install/Makefile b/tests/install/Makefile index 9906387..cb8f060 100644 --- a/tests/install/Makefile +++ b/tests/install/Makefile @@ -3,15 +3,17 @@ default: build run .PHONY: build build: - docker build -t phpctl-install-test -f ${OS}.Dockerfile . + docker build -t phpctl-${OS}-test -f ${OS}.Dockerfile . .PHONY: run run: - docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock phpctl-alpine-test sh + docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock phpctl-${OS}-test bash .PHONY: install install: - sh <(wget -qO- https://phpctl.dev/install.sh) + wget -q https://phpctl.dev/phpctl-installer.sh + bash phpctl-installer.sh + rm phpctl-installer.sh .PHONY: test test: diff --git a/tests/install/ubuntu.Dockerfile b/tests/install/ubuntu.Dockerfile index acac919..a6cb345 100644 --- a/tests/install/ubuntu.Dockerfile +++ b/tests/install/ubuntu.Dockerfile @@ -1,4 +1,4 @@ FROM ubuntu -RUN apt update && apt install -y bash docker git make openssl sudo +RUN apt update && apt install -y bash docker.io git make openssl sudo wget WORKDIR /usr/local/src COPY Makefile . From 4d19ebdfedb527cdbc255903f7dd70aafc30b31a Mon Sep 17 00:00:00 2001 From: leocavalcante Date: Sun, 4 Feb 2024 21:20:40 -0300 Subject: [PATCH 025/130] chore(docs): Install --- README.md | 5 ++--- docs/README.md | 15 +++++++++++++-- tests/install/Makefile | 5 ++--- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 7d0c12d..3e89d60 100644 --- a/README.md +++ b/README.md @@ -33,9 +33,8 @@ Take the advantage of goodie commands like `phpctl create` to start a new projec ### Install If you want to install it system-wide (at `/usr/local/bin`), run: ```shell -wget -q https://phpctl.dev/phpctl-installer.sh -bash phpctl-installer.sh -rm phpctl-installer.sh +wget -q https://phpctl.dev/phpctl-installer.sh && \ +bash phpctl-installer.sh && rm phpctl-installer.sh ``` > [!TIP] diff --git a/docs/README.md b/docs/README.md index 7d19e1f..3c2b0ec 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,3 +1,14 @@ -# Welcome +# Frictionless PHP Development -This is the very start of a dedicated documentation site for `phpctl`. +Seamlessly run and switch between different versions of PHP, with different installed extensions, thanks to the power of containers. + +Take the advantage of goodies commands like `phpctl create` to start a new project, `phpctl repl` to start a REPL, `phpctl init` to initialize a new configuration file **and a lot more**. + +## Getting started + +### Installation + +```shell +wget -q https://phpctl.dev/phpctl-installer.sh && \ +bash phpctl-installer.sh && rm phpctl-installer.sh +``` diff --git a/tests/install/Makefile b/tests/install/Makefile index cb8f060..dfaa543 100644 --- a/tests/install/Makefile +++ b/tests/install/Makefile @@ -11,9 +11,8 @@ run: .PHONY: install install: - wget -q https://phpctl.dev/phpctl-installer.sh - bash phpctl-installer.sh - rm phpctl-installer.sh + wget -q https://phpctl.dev/phpctl-installer.sh && \ + bash phpctl-installer.sh && rm phpctl-installer.sh .PHONY: test test: From 3ecbd5a22ccd78ba5509c839286ce0b106f22549 Mon Sep 17 00:00:00 2001 From: Leo Cavalcante Date: Mon, 5 Feb 2024 10:29:26 -0300 Subject: [PATCH 026/130] chore(docs): Just the docs theme --- docs/_config.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/_config.yml b/docs/_config.yml index 8bbf794..679c14b 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -1 +1,4 @@ -theme: jekyll-theme-hacker +plugins: + - jekyll-remote-theme + +remote_theme: just-the-docs/just-the-docs From f521b0ec22ad81d2e7d4364b4c127c520bf1cc9e Mon Sep 17 00:00:00 2001 From: leocavalcante Date: Tue, 6 Feb 2024 19:31:18 -0300 Subject: [PATCH 027/130] fix(dev): Symbolic links from absolute path --- scripts/symlink-bins.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/symlink-bins.sh b/scripts/symlink-bins.sh index fe5fdf4..bb01640 100755 --- a/scripts/symlink-bins.sh +++ b/scripts/symlink-bins.sh @@ -1,4 +1,4 @@ #!/usr/bin/env bash for file in "${1:-.}"/bin/*; do - ln -sf "$file" "/usr/local/bin/$(basename "$file")" + ln -sf "$(realpath "$file")" "/usr/local/bin/$(basename "$file")" done From 6b2aa1f626f9e64bb241cfe457c2d10d923449a8 Mon Sep 17 00:00:00 2001 From: Neuber Oliveira Date: Wed, 7 Feb 2024 11:42:10 -0300 Subject: [PATCH 028/130] feat: Homebrew (#18) homebrew support add homebrew instructions on install section change self-update to check for homebrew instalation and give proper instructions Co-authored-by: Leo Cavalcante --- README.md | 9 ++++++++- src/self-update.sh | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3e89d60..9f208fe 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Take the advantage of goodie commands like `phpctl create` to start a new projec - Docker ### Install -If you want to install it system-wide (at `/usr/local/bin`), run: +You can install with default installer script for a system-wide (at `/usr/local/bin`), run: ```shell wget -q https://phpctl.dev/phpctl-installer.sh && \ bash phpctl-installer.sh && rm phpctl-installer.sh @@ -43,12 +43,19 @@ bash phpctl-installer.sh && rm phpctl-installer.sh > bash phpctl-installer.sh ~/bin > ``` +Homebrew +`brew install opencodeco/phpctl/phpctl` + +Or add the `oppencodeco` tap with `brew tap opencodeco/phpctl` and then `brew install phpctl` + #### Update You can re-run the installer or use the `self-update` command: ```shell phpctl self-update ``` +For those using Homebrew `brew upgrade opencodeco/phpctl/phpctl` or when run `brew update` + ## Usage Then you can use `phpctl` or `pctl` with a subcommand: ```shell diff --git a/src/self-update.sh b/src/self-update.sh index 1f42cce..0a0b37a 100644 --- a/src/self-update.sh +++ b/src/self-update.sh @@ -1,6 +1,22 @@ +is_brew_installed() { + command -v brew>/dev/null 2>&1 +} + +is_tap_installed() { + local tap_name="1ドル" + brew tap | grep -q "^$tap_name$" +} + self-update() { + local tap_to_check="opencodeco/phpctl" + local full_tap_pkg="$tap_to_check/phpctl" + + if is_brew_installed && is_tap_installed "$tap_to_check"; then + echo -e "033円[32mSeems phpctl was installed by Homebrew, to update it run033円[0m brew upgrade $full_tap_pkg" + else echo -e "Heading to 033円[33m$PHPCTL_DIR033円[0m to update..." cd "$PHPCTL_DIR" || exit 1 git pull origin HEAD echo -e "033円[32mUpdated!033円[0m" + fi } From 68669fe2017d035d9d2b5beb2b566e16205b8487 Mon Sep 17 00:00:00 2001 From: Leo Cavalcante Date: Wed, 7 Feb 2024 11:45:17 -0300 Subject: [PATCH 029/130] chore(docs): Homebrew --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9f208fe..1dd4f61 100644 --- a/README.md +++ b/README.md @@ -43,8 +43,10 @@ bash phpctl-installer.sh && rm phpctl-installer.sh > bash phpctl-installer.sh ~/bin > ``` -Homebrew -`brew install opencodeco/phpctl/phpctl` +#### Homebrew +```shell +brew install opencodeco/phpctl/phpctl +``` Or add the `oppencodeco` tap with `brew tap opencodeco/phpctl` and then `brew install phpctl` From 103265a6e317b6c0eb95e92c45806f4e1faadf62 Mon Sep 17 00:00:00 2001 From: leocavalcante Date: Fri, 9 Feb 2024 09:35:18 -0300 Subject: [PATCH 030/130] feat: Always add a INI file --- php.ini | 1 + src/docker.sh | 1 + 2 files changed, 2 insertions(+) create mode 100644 php.ini diff --git a/php.ini b/php.ini new file mode 100644 index 0000000..4fdcd22 --- /dev/null +++ b/php.ini @@ -0,0 +1 @@ +sys_temp_dir = /tmp diff --git a/src/docker.sh b/src/docker.sh index d41652e..3c95a51 100644 --- a/src/docker.sh +++ b/src/docker.sh @@ -57,6 +57,7 @@ run() { -v /var/run/docker.sock:/var/run/docker.sock \ -v ~/.gitconfig:/root/.gitconfig:ro \ -v "$(pwd)":/usr/local/src -w /usr/local/src \ + -v "$PHPCTL_DIR/php.ini:/etc/php$PHP_VERSION/conf.d/zphp.ini" \ $phpctl_ini \ $composer_home \ --net host --entrypoint sh \ From 2d3b7b67d8ba92981f747e152c29f64ee36cd151 Mon Sep 17 00:00:00 2001 From: leocavalcante Date: Fri, 9 Feb 2024 11:06:34 -0300 Subject: [PATCH 031/130] refactor: Do not print carriage returns in the first column --- Dockerfile | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index dd2a835..151fe35 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,10 @@ ARG ALPINE=3.19 FROM alpine:${ALPINE} ARG PHP +ARG HOST_USER COPY rootfs / RUN apk add --update --no-cache \ + doas \ git \ docker-cli \ php${PHP}-cli \ @@ -34,11 +36,10 @@ RUN apk add --update --no-cache \ php${PHP}-pecl-xdebug \ && ln -sf /usr/bin/php${PHP} /usr/bin/php \ && mv /etc/php/php.ini /etc/php${PHP}/conf.d/zzphp.ini \ - && /usr/local/bin/install-tools -ARG HOST_USER -RUN apk add doas; \ - adduser ${HOST_USER}; \ - echo "${HOST_USER}" | chpasswd; \ - echo "permit ${HOST_USER} as root"> /etc/doas.d/doas.conf + && /usr/local/bin/install-tools \ + && adduser ${HOST_USER} \ + && "${HOST_USER}" | chpasswd \ + && echo "permit ${HOST_USER} as root"> /etc/doas.d/doas.conf \ + && stty -onocr ENTRYPOINT [ "/usr/bin/php" ] CMD [ "-v" ] From a5b2bcaf8b92753192ba5c7db3ff4505c300fd83 Mon Sep 17 00:00:00 2001 From: leocavalcante Date: Fri, 9 Feb 2024 11:09:40 -0300 Subject: [PATCH 032/130] fix: User --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 151fe35..2e51525 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,7 +38,7 @@ RUN apk add --update --no-cache \ && mv /etc/php/php.ini /etc/php${PHP}/conf.d/zzphp.ini \ && /usr/local/bin/install-tools \ && adduser ${HOST_USER} \ - && "${HOST_USER}" | chpasswd \ + && echo "${HOST_USER}" | chpasswd \ && echo "permit ${HOST_USER} as root"> /etc/doas.d/doas.conf \ && stty -onocr ENTRYPOINT [ "/usr/bin/php" ] From 75efda5e1cc4373c4a87f1a959d094af545a351f Mon Sep 17 00:00:00 2001 From: leocavalcante Date: Fri, 9 Feb 2024 11:32:29 -0300 Subject: [PATCH 033/130] refactor(docker): Rollback --- Dockerfile | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2e51525..dd2a835 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,8 @@ ARG ALPINE=3.19 FROM alpine:${ALPINE} ARG PHP -ARG HOST_USER COPY rootfs / RUN apk add --update --no-cache \ - doas \ git \ docker-cli \ php${PHP}-cli \ @@ -36,10 +34,11 @@ RUN apk add --update --no-cache \ php${PHP}-pecl-xdebug \ && ln -sf /usr/bin/php${PHP} /usr/bin/php \ && mv /etc/php/php.ini /etc/php${PHP}/conf.d/zzphp.ini \ - && /usr/local/bin/install-tools \ - && adduser ${HOST_USER} \ - && echo "${HOST_USER}" | chpasswd \ - && echo "permit ${HOST_USER} as root"> /etc/doas.d/doas.conf \ - && stty -onocr + && /usr/local/bin/install-tools +ARG HOST_USER +RUN apk add doas; \ + adduser ${HOST_USER}; \ + echo "${HOST_USER}" | chpasswd; \ + echo "permit ${HOST_USER} as root"> /etc/doas.d/doas.conf ENTRYPOINT [ "/usr/bin/php" ] CMD [ "-v" ] From 29261894324ba4fffb41bc5aa77fda1da11451c2 Mon Sep 17 00:00:00 2001 From: Neuber Oliveira Date: Fri, 9 Feb 2024 11:35:20 -0300 Subject: [PATCH 034/130] add some missing -e option for echo in installer for colorize (#19) --- docs/phpctl-installer.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/phpctl-installer.sh b/docs/phpctl-installer.sh index f410008..1b14c74 100755 --- a/docs/phpctl-installer.sh +++ b/docs/phpctl-installer.sh @@ -9,7 +9,7 @@ else SYMLINK_DIR=1ドル fi -echo "033円[0;33mInstalling phpctl at 033円[0m$INSTALL_DIR" +echo -e "033円[0;33mInstalling phpctl at 033円[0m$INSTALL_DIR" if [ -d "$INSTALL_DIR" ]; then echo "The install directory is not empty. Attempting to remove it..." rm -rI $INSTALL_DIR @@ -24,19 +24,20 @@ while kill -0 $PID 2> /dev/null; do sleep 0.1 done done +printf "\r" + -echo "\b " if [ -z "1ドル" ]; then echo -n "Sudo will be prompted to symlink the phpctl files." else echo -n "Files will be symlinked to ${SYMLINK_DIR}." fi -echo -n " 033円[0;32mDo you want to continue? (y/n)033円[0m " +echo -e -n " 033円[0;32mDo you want to continue? (y/n)033円[0m " read -r answer if [ "$answer" != "${answer#[Yy]}" ]; then $SUDO ${INSTALL_DIR}/scripts/symlink-bins.sh ${INSTALL_DIR} else - echo "033円[0;31mTo use phpctl globally, link the cloned script to your bin directory, like:033円[0m" + echo -e "033円[0;31mTo use phpctl globally, link the cloned script to your bin directory, like:033円[0m" echo "" for file in "${INSTALL_DIR}"/bin/*; do bin=$(basename "$file") From 444daedfae6fbc647fb57272bbf35bd2203ec8b2 Mon Sep 17 00:00:00 2001 From: leocavalcante Date: Fri, 9 Feb 2024 11:40:24 -0300 Subject: [PATCH 035/130] feat: Disable newline conversion --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index dd2a835..113ed77 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,7 +34,8 @@ RUN apk add --update --no-cache \ php${PHP}-pecl-xdebug \ && ln -sf /usr/bin/php${PHP} /usr/bin/php \ && mv /etc/php/php.ini /etc/php${PHP}/conf.d/zzphp.ini \ - && /usr/local/bin/install-tools + && /usr/local/bin/install-tools \ + && stty -onlcr ARG HOST_USER RUN apk add doas; \ adduser ${HOST_USER}; \ From 5aff296a55f1c3de898bb7cd6cfb79b4e73460f1 Mon Sep 17 00:00:00 2001 From: leocavalcante Date: Fri, 9 Feb 2024 11:42:20 -0300 Subject: [PATCH 036/130] refactor(docker): Rollback Dockerfile --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 113ed77..dd2a835 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,8 +34,7 @@ RUN apk add --update --no-cache \ php${PHP}-pecl-xdebug \ && ln -sf /usr/bin/php${PHP} /usr/bin/php \ && mv /etc/php/php.ini /etc/php${PHP}/conf.d/zzphp.ini \ - && /usr/local/bin/install-tools \ - && stty -onlcr + && /usr/local/bin/install-tools ARG HOST_USER RUN apk add doas; \ adduser ${HOST_USER}; \ From 3a60011b36df2c7d69335ea1421cdd4588f0c575 Mon Sep 17 00:00:00 2001 From: leocavalcante Date: Fri, 9 Feb 2024 11:53:59 -0300 Subject: [PATCH 037/130] feat(notty): Add non-TTY as a helper --- Makefile | 2 +- bin/notty | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100755 bin/notty diff --git a/Makefile b/Makefile index 84b7309..d2eddbb 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ build: .PHONY: test test: - @PHPCTL_TTY=--label=no-tty COMPOSER_AUTH= TERM= ./lib/bashunit ./tests/ + @COMPOSER_AUTH= TERM= notty ./lib/bashunit ./tests/ .PHONY: install install: diff --git a/bin/notty b/bin/notty new file mode 100755 index 0000000..134f289 --- /dev/null +++ b/bin/notty @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +PHPCTL_TTY="--label=no-tty" $@ From 5e867c3de1cdb2ec2ffa6bd7ae7e0e6fde2b0a28 Mon Sep 17 00:00:00 2001 From: leocavalcante Date: 2024年2月14日 11:35:36 -0300 Subject: [PATCH 038/130] chore(docs): Swoole example --- examples/swoole/.gitignore | 1 + examples/swoole/composer.json | 5 ++++ examples/swoole/composer.lock | 51 +++++++++++++++++++++++++++++++++++ examples/swoole/server.php | 17 ++++++++++++ 4 files changed, 74 insertions(+) create mode 100644 examples/swoole/.gitignore create mode 100644 examples/swoole/composer.json create mode 100644 examples/swoole/composer.lock create mode 100644 examples/swoole/server.php diff --git a/examples/swoole/.gitignore b/examples/swoole/.gitignore new file mode 100644 index 0000000..48b8bf9 --- /dev/null +++ b/examples/swoole/.gitignore @@ -0,0 +1 @@ +vendor/ diff --git a/examples/swoole/composer.json b/examples/swoole/composer.json new file mode 100644 index 0000000..ab6d850 --- /dev/null +++ b/examples/swoole/composer.json @@ -0,0 +1,5 @@ +{ + "require-dev": { + "swoole/ide-helper": "^5.1" + } +} diff --git a/examples/swoole/composer.lock b/examples/swoole/composer.lock new file mode 100644 index 0000000..bf9890b --- /dev/null +++ b/examples/swoole/composer.lock @@ -0,0 +1,51 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "87773a601065b2642cf9f7714bfada34", + "packages": [], + "packages-dev": [ + { + "name": "swoole/ide-helper", + "version": "5.1.2", + "source": { + "type": "git", + "url": "https://github.com/swoole/ide-helper.git", + "reference": "33ec7af9111b76d06a70dd31191cc74793551112" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/swoole/ide-helper/zipball/33ec7af9111b76d06a70dd31191cc74793551112", + "reference": "33ec7af9111b76d06a70dd31191cc74793551112", + "shasum": "" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Team Swoole", + "email": "team@swoole.com" + } + ], + "description": "IDE help files for Swoole.", + "support": { + "issues": "https://github.com/swoole/ide-helper/issues", + "source": "https://github.com/swoole/ide-helper/tree/5.1.2" + }, + "time": "2024-02-01T22:28:11+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.6.0" +} diff --git a/examples/swoole/server.php b/examples/swoole/server.php new file mode 100644 index 0000000..339ceda --- /dev/null +++ b/examples/swoole/server.php @@ -0,0 +1,17 @@ +on(\Swoole\Constant::EVENT_REQUEST, function (\Swoole\Http\Request $req, \Swoole\Http\Response $res) { + $res->end('Hello, World!'); +}); + +$srv->on(\Swoole\Constant::EVENT_START, function (\Swoole\Http\Server $srv) { + echo "Server started at http://localhost:{$srv->port}\n"; +}); + +$srv->start(); From 8c945554061a0957d6f7fda402535d61028993c7 Mon Sep 17 00:00:00 2001 From: leocavalcante Date: 2024年2月14日 11:35:49 -0300 Subject: [PATCH 039/130] feat(docker): Init --- src/docker.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/src/docker.sh b/src/docker.sh index 3c95a51..11f990e 100644 --- a/src/docker.sh +++ b/src/docker.sh @@ -49,6 +49,7 @@ run() { # shellcheck disable=SC2086 # shellcheck disable=SC2154 $PHPCTL_RUNTIME run \ + --init \ --platform linux/x86_64 \ --rm "$PHPCTL_TTY" \ --name "phpctl_$(openssl rand -hex 6)" \ From 808e9af1f59afb1167fe9fb72922d2a0a998a652 Mon Sep 17 00:00:00 2001 From: leocavalcante Date: 2024年2月15日 15:39:58 -0300 Subject: [PATCH 040/130] wip: Archlinux --- tests/install/archlinux.Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 tests/install/archlinux.Dockerfile diff --git a/tests/install/archlinux.Dockerfile b/tests/install/archlinux.Dockerfile new file mode 100644 index 0000000..e703b39 --- /dev/null +++ b/tests/install/archlinux.Dockerfile @@ -0,0 +1,4 @@ +FROM archlinux +RUN pacman -Syu --noconfirm docker +WORKDIR /usr/local/src +COPY Makefile . From a2a356ad13fce74ee9c4ea5bfb44c4c024ed5e23 Mon Sep 17 00:00:00 2001 From: leocavalcante Date: 2024年2月15日 16:03:42 -0300 Subject: [PATCH 041/130] chore(tests): Archlinux --- tests/install/archlinux.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/install/archlinux.Dockerfile b/tests/install/archlinux.Dockerfile index e703b39..61380d5 100644 --- a/tests/install/archlinux.Dockerfile +++ b/tests/install/archlinux.Dockerfile @@ -1,4 +1,4 @@ FROM archlinux -RUN pacman -Syu --noconfirm docker +RUN pacman -Syu --noconfirm docker make wget sudo git WORKDIR /usr/local/src COPY Makefile . From 54aedd88426bfc41ee7568c2f41dbf1fff037330 Mon Sep 17 00:00:00 2001 From: leocavalcante Date: 2024年2月15日 16:17:44 -0300 Subject: [PATCH 042/130] chore: Line endings --- phpctl-installer.sh | 46 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 phpctl-installer.sh diff --git a/phpctl-installer.sh b/phpctl-installer.sh new file mode 100644 index 0000000..1b14c74 --- /dev/null +++ b/phpctl-installer.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +INSTALL_DIR=~/.phpctl +if [ -z "1ドル" ]; then + SUDO=sudo + SYMLINK_DIR=/usr/local/bin +else + SUDO="" + SYMLINK_DIR=1ドル +fi + +echo -e "033円[0;33mInstalling phpctl at 033円[0m$INSTALL_DIR" +if [ -d "$INSTALL_DIR" ]; then + echo "The install directory is not empty. Attempting to remove it..." + rm -rI $INSTALL_DIR +fi + +echo -n "" +git clone --quiet https://github.com/opencodeco/phpctl.git $INSTALL_DIR & +PID=$! +while kill -0 $PID 2> /dev/null; do + for CHAR in '-' '/' '|' '\'; do + printf "\b$CHAR" + sleep 0.1 + done +done +printf "\r" + + +if [ -z "1ドル" ]; then + echo -n "Sudo will be prompted to symlink the phpctl files." +else + echo -n "Files will be symlinked to ${SYMLINK_DIR}." +fi +echo -e -n " 033円[0;32mDo you want to continue? (y/n)033円[0m " +read -r answer +if [ "$answer" != "${answer#[Yy]}" ]; then + $SUDO ${INSTALL_DIR}/scripts/symlink-bins.sh ${INSTALL_DIR} +else + echo -e "033円[0;31mTo use phpctl globally, link the cloned script to your bin directory, like:033円[0m" + echo "" + for file in "${INSTALL_DIR}"/bin/*; do + bin=$(basename "$file") + echo " ${SUDO} ln -sf ${INSTALL_DIR}/bin/$bin ${SYMLINK_DIR}/$bin" + done +fi From 4d3153b6eaf11a06c2f32c39b4eedc1d55e15681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20Heleno?= Date: 2024年2月15日 17:48:45 -0300 Subject: [PATCH 043/130] feat: watchr (#21) * feat: watchr * feat: Tools toggling --------- Co-authored-by: Leo Cavalcante --- .github/workflows/docker.yml | 16 +++++++++++----- Dockerfile | 7 +++++++ README.md | 3 ++- bin/watchr | 2 ++ rootfs/usr/local/bin/install-tools | 10 +++++++++- src/docker.sh | 12 ++++++++++++ src/help.sh | 1 + src/tools.sh | 4 ++++ tests/tools_test.sh | 10 +++++++++- 9 files changed, 57 insertions(+), 8 deletions(-) create mode 100755 bin/watchr diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index cf04688..76d963d 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -11,10 +11,13 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php: - - 81 - - 82 - - 83 + include: + - php: 81 + without-watchr: 1 + - php: 82 + without-watchr: '' + - php: 83 + without-watchr: '' steps: - name: Checkout @@ -37,13 +40,16 @@ jobs: with: context: . load: true - build-args: PHP=${{ matrix.php }} + build-args: | + PHP=${{ matrix.php }} + WITHOUT_WATCHR=${{ matrix.without-watchr }} tags: opencodeco/phpctl:php${{ matrix.php }} - name: Test env: PHP_VERSION: ${{ matrix.php }} PHPCTL_TTY: --label=no-tty + WITHOUT_WATCHR: ${{ matrix.without-watchr }} run: | ./lib/bashunit ./tests/ - diff --git a/Dockerfile b/Dockerfile index dd2a835..4d70aee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,13 @@ ARG ALPINE=3.19 FROM alpine:${ALPINE} ARG PHP + +ARG WITH_EXAKAT +ENV WITH_EXAKAT=$WITH_EXAKAT + +ARG WITHOUT_WATCHR +ENV WITHOUT_WATCHR=$WITHOUT_WATCHR + COPY rootfs / RUN apk add --update --no-cache \ git \ diff --git a/README.md b/README.md index 1dd4f61..c159532 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,7 @@ phpctl sh echo 'Hello, World!' # To run arbitrary sh commands inside the contain | `exakat` | [Exakat](https://www.exakat.io) is a real time customizable static analyzer engine that analyse and fix code. | | `frankenphp` | [FrankenPHP](https://frankenphp.dev): the Modern PHP App Server, written in Go. | | `rector` | [Rector](https://getrector.com) is a tool that you can run on any project to get an instant upgrade or automated refactoring. | +| `watchr` | [watchr](https://github.com/flavioheleno/watchr): command-line utility to explore and validate domain names and certificates. | ### Scaffolders | Command | Description | @@ -235,7 +236,7 @@ You can always use your custom image with the `PHPCTL_IMAGE` variable, but feel ## Why it exists? > [!TIP] > After some years struggling with different PHP distributions into different operating systems, dealing with different PHP versions and sets of extensions, -> I came out with `phpctl` to use the power of containers to seamlessly run PHP :elephant: for developement environments. +> I came out with `phpctl` to use the power of containers to seamlessly run PHP :elephant: for developement environments. ## Contributing Click here to read the [contributing guidelines](CONTRIBUTING.md). diff --git a/bin/watchr b/bin/watchr new file mode 100755 index 0000000..47dc592 --- /dev/null +++ b/bin/watchr @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +phpctl watchr $@ diff --git a/rootfs/usr/local/bin/install-tools b/rootfs/usr/local/bin/install-tools index 9d81ef1..53ddd3a 100755 --- a/rootfs/usr/local/bin/install-tools +++ b/rootfs/usr/local/bin/install-tools @@ -61,17 +61,25 @@ psysh() { chmod a+x /usr/local/bin/psysh } +watchr() { + echo "Installing watchr" + wget -q https://github.com/flavioheleno/watchr/releases/download/v0.4.1/watchr.phar -O /usr/local/bin/watchr + chmod a+x /usr/local/bin/watchr +} + install() { box composer couscous - exakat + [ -n "$WITH_EXAKAT" ] && exakat infection php_cs_fixer phpstan phpunit pint psysh + [ -z "$WITHOUT_WATCHR" ] && watchr + echo "Done!" } install diff --git a/src/docker.sh b/src/docker.sh index 11f990e..fa4302c 100644 --- a/src/docker.sh +++ b/src/docker.sh @@ -1,4 +1,14 @@ build() { + local with_exakat="" + if [[ "$*" == *--with-exakat* ]]; then + with_exakat="--build-arg WITH_EXAKAT=1" + fi + + local without_watchr="" + if [[ "$*" == *--without-watchr* ]]; then + without_watchr="--build-arg WITHOUT_WATCHR=1" + fi + echo -e "Building 033円[0;32m$PHPCTL_IMAGE033円[0m" # shellcheck disable=SC2068 # shellcheck disable=SC2154 @@ -6,6 +16,8 @@ build() { --build-arg PHP="$PHP_VERSION" \ --build-arg COMPOSER_AUTH="$COMPOSER_AUTH" \ --build-arg HOST_USER="$(whoami)" \ + $with_exakat \ + $without_watchr \ ${build[@]} -t "$PHPCTL_IMAGE" . } diff --git a/src/help.sh b/src/help.sh index 50bf94e..6c1e336 100644 --- a/src/help.sh +++ b/src/help.sh @@ -43,5 +43,6 @@ help() { echo -e "033円[0;32m exakat 033円[0m Runs Exakat" echo -e "033円[0;32m frankenphp 033円[0m Runs FrankenPHP" echo -e "033円[0;32m rector 033円[0m Runs Rector" + echo -e "033円[0;32m watchr 033円[0m Runs watchr" echo -e "" } diff --git a/src/tools.sh b/src/tools.sh index 536f5d6..b617b96 100644 --- a/src/tools.sh +++ b/src/tools.sh @@ -69,3 +69,7 @@ pint() { rector() { run -- vendor/bin/rector ${@} } + +watchr() { + run -- watchr ${@} +} diff --git a/tests/tools_test.sh b/tests/tools_test.sh index 39d4fd1..3570144 100644 --- a/tests/tools_test.sh +++ b/tests/tools_test.sh @@ -7,7 +7,9 @@ function test_couscous() { } function test_exakat() { - assert_contains "Version : 2.6" "$(./bin/phpctl exakat version)" + if [ -n "$WITH_EXAKAT" ]; then + assert_contains "Version : 2.6" "$(./bin/phpctl exakat version)" + fi } function test_infection() { @@ -29,3 +31,9 @@ function test_phpunit() { function test_pint() { assert_contains "Pint 1.13" "$(./bin/phpctl pint --version)" } + +function test_watchr() { + if [ -z "$WITHOUT_WATCHR" ]; then + assert_contains "watchr command-line utility v0.4.1@b1b8dd5" "$(./bin/phpctl watchr --version)" + fi +} From c5788d15f25099109c7dcfcc275154fd7d71533c Mon Sep 17 00:00:00 2001 From: leocavalcante Date: 2024年2月15日 21:32:24 -0300 Subject: [PATCH 044/130] chore: Remove unused files --- phpctl-installer.sh | 46 --------------------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 phpctl-installer.sh diff --git a/phpctl-installer.sh b/phpctl-installer.sh deleted file mode 100644 index 1b14c74..0000000 --- a/phpctl-installer.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env bash - -INSTALL_DIR=~/.phpctl -if [ -z "1ドル" ]; then - SUDO=sudo - SYMLINK_DIR=/usr/local/bin -else - SUDO="" - SYMLINK_DIR=1ドル -fi - -echo -e "033円[0;33mInstalling phpctl at 033円[0m$INSTALL_DIR" -if [ -d "$INSTALL_DIR" ]; then - echo "The install directory is not empty. Attempting to remove it..." - rm -rI $INSTALL_DIR -fi - -echo -n "" -git clone --quiet https://github.com/opencodeco/phpctl.git $INSTALL_DIR & -PID=$! -while kill -0 $PID 2> /dev/null; do - for CHAR in '-' '/' '|' '\'; do - printf "\b$CHAR" - sleep 0.1 - done -done -printf "\r" - - -if [ -z "1ドル" ]; then - echo -n "Sudo will be prompted to symlink the phpctl files." -else - echo -n "Files will be symlinked to ${SYMLINK_DIR}." -fi -echo -e -n " 033円[0;32mDo you want to continue? (y/n)033円[0m " -read -r answer -if [ "$answer" != "${answer#[Yy]}" ]; then - $SUDO ${INSTALL_DIR}/scripts/symlink-bins.sh ${INSTALL_DIR} -else - echo -e "033円[0;31mTo use phpctl globally, link the cloned script to your bin directory, like:033円[0m" - echo "" - for file in "${INSTALL_DIR}"/bin/*; do - bin=$(basename "$file") - echo " ${SUDO} ln -sf ${INSTALL_DIR}/bin/$bin ${SYMLINK_DIR}/$bin" - done -fi From 0a2c30500c05e31fbcaaef618457630b092fbf6d Mon Sep 17 00:00:00 2001 From: Yuri Silva Date: 2024年2月18日 21:12:51 -0300 Subject: [PATCH 045/130] feat(tool): PHP Mess Detector (#23) --- README.md | 1 + bin/phpmd | 2 + examples/phpmd/.gitignore | 1 + examples/phpmd/README.md | 16 + examples/phpmd/composer.json | 10 + examples/phpmd/composer.lock | 1005 ++++++++++++++++++++++++++++ examples/phpmd/src/Example.php | 28 + rootfs/usr/local/bin/install-tools | 7 + src/help.sh | 1 + src/tools.sh | 8 + tests/tools_test.sh | 4 + 11 files changed, 1083 insertions(+) create mode 100755 bin/phpmd create mode 100644 examples/phpmd/.gitignore create mode 100644 examples/phpmd/README.md create mode 100644 examples/phpmd/composer.json create mode 100644 examples/phpmd/composer.lock create mode 100644 examples/phpmd/src/Example.php diff --git a/README.md b/README.md index c159532..588486b 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,7 @@ phpctl sh echo 'Hello, World!' # To run arbitrary sh commands inside the contain |----------------|-------------------------------------------------------------------------------------------------------------------------------| | `phpunit` | [PHPUnit](https://phpunit.de) is a programmer-oriented testing framework for PHP. | | `php-cs-fixer` | [PHP Coding Standards Fixer (PHP CS Fixer)](https://cs.symfony.com/) fixes your code to follow standards. | +| `phpmd` | [PHP Mess Detector](https://phpmd.org/) looks for several potential problems within your source code. | | `phpstan` | [PHPStan](https://phpstan.org/) finds bugs in your code without writing tests. It's open-source and free. | | `infection` | [Infection](https://infection.github.io) is a Mutation Testing Framework. | | `pest` | [Pest](https://pestphp.com) is a testing framework with a focus on simplicity. | diff --git a/bin/phpmd b/bin/phpmd new file mode 100755 index 0000000..9d11a09 --- /dev/null +++ b/bin/phpmd @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +phpctl phpmd $@ diff --git a/examples/phpmd/.gitignore b/examples/phpmd/.gitignore new file mode 100644 index 0000000..48b8bf9 --- /dev/null +++ b/examples/phpmd/.gitignore @@ -0,0 +1 @@ +vendor/ diff --git a/examples/phpmd/README.md b/examples/phpmd/README.md new file mode 100644 index 0000000..4342cec --- /dev/null +++ b/examples/phpmd/README.md @@ -0,0 +1,16 @@ +# PHP Mess Detector + +An example of [PHP Mess Detector](https://phpmd.org/) usage. + +Run `phpctl phpmd src text cleancode,controversial,design,naming,unusedcode` to get PHPMD output execution for [Example](./src/Example.php) class. + +You should have an output as following: +```shell +/usr/local/src/src/Example.php:6 LongVariable Avoid excessively long variable names like $thiIsAnAmazingVariable. Keep variable name length under 20. +/usr/local/src/src/Example.php:8 UnusedLocalVariable Avoid unused local variables such as '$anotherVariable'. +/usr/local/src/src/Example.php:11 CamelCaseMethodName The method snake_case_method is not named in camelCase. +/usr/local/src/src/Example.php:17 MissingImport Missing class import via use statement (line '17', column '23'). +/usr/local/src/src/Example.php:18 EmptyCatchBlock Avoid using empty try-catch blocks in uselessCatchBlock. +/usr/local/src/src/Example.php:24 UndefinedVariable Avoid using undefined variables such as '$age' which will lead to PHP notices. +/usr/local/src/src/Example.php:24 UnusedLocalVariable Avoid unused local variables such as '$age'. +``` \ No newline at end of file diff --git a/examples/phpmd/composer.json b/examples/phpmd/composer.json new file mode 100644 index 0000000..cd83c81 --- /dev/null +++ b/examples/phpmd/composer.json @@ -0,0 +1,10 @@ +{ + "autoload": { + "psr-4": { + "App\\": "src/" + } + }, + "require-dev": { + "phpmd/phpmd": "^2.15" + } +} diff --git a/examples/phpmd/composer.lock b/examples/phpmd/composer.lock new file mode 100644 index 0000000..0fe7da1 --- /dev/null +++ b/examples/phpmd/composer.lock @@ -0,0 +1,1005 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "ba732fb5b882b63abfb5116571fdf5b7", + "packages": [], + "packages-dev": [ + { + "name": "composer/pcre", + "version": "3.1.1", + "source": { + "type": "git", + "url": "https://github.com/composer/pcre.git", + "reference": "00104306927c7a0919b4ced2aaa6782c1e61a3c9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/pcre/zipball/00104306927c7a0919b4ced2aaa6782c1e61a3c9", + "reference": "00104306927c7a0919b4ced2aaa6782c1e61a3c9", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.3", + "phpstan/phpstan-strict-rules": "^1.1", + "symfony/phpunit-bridge": "^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Pcre\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "PCRE wrapping library that offers type-safe preg_* replacements.", + "keywords": [ + "PCRE", + "preg", + "regex", + "regular expression" + ], + "support": { + "issues": "https://github.com/composer/pcre/issues", + "source": "https://github.com/composer/pcre/tree/3.1.1" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2023-10-11T07:11:09+00:00" + }, + { + "name": "composer/xdebug-handler", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/composer/xdebug-handler.git", + "reference": "ced299686f41dce890debac69273b47ffe98a40c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/ced299686f41dce890debac69273b47ffe98a40c", + "reference": "ced299686f41dce890debac69273b47ffe98a40c", + "shasum": "" + }, + "require": { + "composer/pcre": "^1 || ^2 || ^3", + "php": "^7.2.5 || ^8.0", + "psr/log": "^1 || ^2 || ^3" + }, + "require-dev": { + "phpstan/phpstan": "^1.0", + "phpstan/phpstan-strict-rules": "^1.1", + "symfony/phpunit-bridge": "^6.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Composer\\XdebugHandler\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "John Stevenson", + "email": "john-stevenson@blueyonder.co.uk" + } + ], + "description": "Restarts a process without Xdebug.", + "keywords": [ + "Xdebug", + "performance" + ], + "support": { + "irc": "irc://irc.freenode.org/composer", + "issues": "https://github.com/composer/xdebug-handler/issues", + "source": "https://github.com/composer/xdebug-handler/tree/3.0.3" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2022-02-25T21:32:43+00:00" + }, + { + "name": "pdepend/pdepend", + "version": "2.16.2", + "source": { + "type": "git", + "url": "https://github.com/pdepend/pdepend.git", + "reference": "f942b208dc2a0868454d01b29f0c75bbcfc6ed58" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pdepend/pdepend/zipball/f942b208dc2a0868454d01b29f0c75bbcfc6ed58", + "reference": "f942b208dc2a0868454d01b29f0c75bbcfc6ed58", + "shasum": "" + }, + "require": { + "php": ">=5.3.7", + "symfony/config": "^2.3.0|^3|^4|^5|^6.0|^7.0", + "symfony/dependency-injection": "^2.3.0|^3|^4|^5|^6.0|^7.0", + "symfony/filesystem": "^2.3.0|^3|^4|^5|^6.0|^7.0", + "symfony/polyfill-mbstring": "^1.19" + }, + "require-dev": { + "easy-doc/easy-doc": "0.0.0|^1.2.3", + "gregwar/rst": "^1.0", + "squizlabs/php_codesniffer": "^2.0.0" + }, + "bin": [ + "src/bin/pdepend" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "PDepend\\": "src/main/php/PDepend" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "Official version of pdepend to be handled with Composer", + "keywords": [ + "PHP Depend", + "PHP_Depend", + "dev", + "pdepend" + ], + "support": { + "issues": "https://github.com/pdepend/pdepend/issues", + "source": "https://github.com/pdepend/pdepend/tree/2.16.2" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/pdepend/pdepend", + "type": "tidelift" + } + ], + "time": "2023-12-17T18:09:59+00:00" + }, + { + "name": "phpmd/phpmd", + "version": "2.15.0", + "source": { + "type": "git", + "url": "https://github.com/phpmd/phpmd.git", + "reference": "74a1f56e33afad4128b886e334093e98e1b5e7c0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpmd/phpmd/zipball/74a1f56e33afad4128b886e334093e98e1b5e7c0", + "reference": "74a1f56e33afad4128b886e334093e98e1b5e7c0", + "shasum": "" + }, + "require": { + "composer/xdebug-handler": "^1.0 || ^2.0 || ^3.0", + "ext-xml": "*", + "pdepend/pdepend": "^2.16.1", + "php": ">=5.3.9" + }, + "require-dev": { + "easy-doc/easy-doc": "0.0.0 || ^1.3.2", + "ext-json": "*", + "ext-simplexml": "*", + "gregwar/rst": "^1.0", + "mikey179/vfsstream": "^1.6.8", + "squizlabs/php_codesniffer": "^2.9.2 || ^3.7.2" + }, + "bin": [ + "src/bin/phpmd" + ], + "type": "library", + "autoload": { + "psr-0": { + "PHPMD\\": "src/main/php" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Manuel Pichler", + "email": "github@manuel-pichler.de", + "homepage": "https://github.com/manuelpichler", + "role": "Project Founder" + }, + { + "name": "Marc Würth", + "email": "ravage@bluewin.ch", + "homepage": "https://github.com/ravage84", + "role": "Project Maintainer" + }, + { + "name": "Other contributors", + "homepage": "https://github.com/phpmd/phpmd/graphs/contributors", + "role": "Contributors" + } + ], + "description": "PHPMD is a spin-off project of PHP Depend and aims to be a PHP equivalent of the well known Java tool PMD.", + "homepage": "https://phpmd.org/", + "keywords": [ + "dev", + "mess detection", + "mess detector", + "pdepend", + "phpmd", + "pmd" + ], + "support": { + "irc": "irc://irc.freenode.org/phpmd", + "issues": "https://github.com/phpmd/phpmd/issues", + "source": "https://github.com/phpmd/phpmd/tree/2.15.0" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/phpmd/phpmd", + "type": "tidelift" + } + ], + "time": "2023-12-11T08:22:20+00:00" + }, + { + "name": "psr/container", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "shasum": "" + }, + "require": { + "php": ">=7.4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "support": { + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/2.0.2" + }, + "time": "2021-11-05T16:47:00+00:00" + }, + { + "name": "psr/log", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/fe5ea303b0887d5caefd3d431c3e61ad47037001", + "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "support": { + "source": "https://github.com/php-fig/log/tree/3.0.0" + }, + "time": "2021-07-14T16:46:02+00:00" + }, + { + "name": "symfony/config", + "version": "v7.0.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/config.git", + "reference": "86a5027869ca3d6bdecae6d5d6c2f77c8f2c1d16" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/config/zipball/86a5027869ca3d6bdecae6d5d6c2f77c8f2c1d16", + "reference": "86a5027869ca3d6bdecae6d5d6c2f77c8f2c1d16", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/deprecation-contracts": "^2.5|^3", + "symfony/filesystem": "^6.4|^7.0", + "symfony/polyfill-ctype": "~1.8" + }, + "conflict": { + "symfony/finder": "<6.4", + "symfony/service-contracts": "<2.5" + }, + "require-dev": { + "symfony/event-dispatcher": "^6.4|^7.0", + "symfony/finder": "^6.4|^7.0", + "symfony/messenger": "^6.4|^7.0", + "symfony/service-contracts": "^2.5|^3", + "symfony/yaml": "^6.4|^7.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Config\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Helps you find, load, combine, autofill and validate configuration values of any kind", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/config/tree/v7.0.3" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-30T08:34:29+00:00" + }, + { + "name": "symfony/dependency-injection", + "version": "v7.0.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/dependency-injection.git", + "reference": "e915c6684b8e3ae90a4441f6823ebbb40edf0b92" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/e915c6684b8e3ae90a4441f6823ebbb40edf0b92", + "reference": "e915c6684b8e3ae90a4441f6823ebbb40edf0b92", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "psr/container": "^1.1|^2.0", + "symfony/deprecation-contracts": "^2.5|^3", + "symfony/service-contracts": "^3.3", + "symfony/var-exporter": "^6.4|^7.0" + }, + "conflict": { + "ext-psr": "<1.1|>=2", + "symfony/config": "<6.4", + "symfony/finder": "<6.4", + "symfony/yaml": "<6.4" + }, + "provide": { + "psr/container-implementation": "1.1|2.0", + "symfony/service-implementation": "1.1|2.0|3.0" + }, + "require-dev": { + "symfony/config": "^6.4|^7.0", + "symfony/expression-language": "^6.4|^7.0", + "symfony/yaml": "^6.4|^7.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\DependencyInjection\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Allows you to standardize and centralize the way objects are constructed in your application", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/dependency-injection/tree/v7.0.3" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-30T08:34:29+00:00" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v3.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/7c3aff79d10325257a001fcf92d991f24fc967cf", + "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.4-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.4.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-05-23T14:45:45+00:00" + }, + { + "name": "symfony/filesystem", + "version": "v7.0.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "2890e3a825bc0c0558526c04499c13f83e1b6b12" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/2890e3a825bc0c0558526c04499c13f83e1b6b12", + "reference": "2890e3a825bc0c0558526c04499c13f83e1b6b12", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-mbstring": "~1.8" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides basic utilities for the filesystem", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/filesystem/tree/v7.0.3" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-23T15:02:46+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.29.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ef4d7e442ca910c4764bce785146269b30cb5fc4", + "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "provide": { + "ext-ctype": "*" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.29.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-29T20:11:03+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.29.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9773676c8a1bb1f8d4340a62efe641cf76eda7ec", + "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "provide": { + "ext-mbstring": "*" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.29.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-29T20:11:03+00:00" + }, + { + "name": "symfony/service-contracts", + "version": "v3.4.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/service-contracts.git", + "reference": "fe07cbc8d837f60caf7018068e350cc5163681a0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/fe07cbc8d837f60caf7018068e350cc5163681a0", + "reference": "fe07cbc8d837f60caf7018068e350cc5163681a0", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "psr/container": "^1.1|^2.0" + }, + "conflict": { + "ext-psr": "<1.1|>=2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.4-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\Service\\": "" + }, + "exclude-from-classmap": [ + "/Test/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to writing services", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/service-contracts/tree/v3.4.1" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-12-26T14:02:43+00:00" + }, + { + "name": "symfony/var-exporter", + "version": "v7.0.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/var-exporter.git", + "reference": "1fb79308cb5fc2b44bff6e8af10a5af6812e05b8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/var-exporter/zipball/1fb79308cb5fc2b44bff6e8af10a5af6812e05b8", + "reference": "1fb79308cb5fc2b44bff6e8af10a5af6812e05b8", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "require-dev": { + "symfony/var-dumper": "^6.4|^7.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\VarExporter\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Allows exporting any serializable PHP data structure to plain PHP code", + "homepage": "https://symfony.com", + "keywords": [ + "clone", + "construct", + "export", + "hydrate", + "instantiate", + "lazy-loading", + "proxy", + "serialize" + ], + "support": { + "source": "https://github.com/symfony/var-exporter/tree/v7.0.3" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-23T15:02:46+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.6.0" +} diff --git a/examples/phpmd/src/Example.php b/examples/phpmd/src/Example.php new file mode 100644 index 0000000..7d96bc2 --- /dev/null +++ b/examples/phpmd/src/Example.php @@ -0,0 +1,28 @@ + 10) { + echo "Number is greater than 10"; + } + } +} diff --git a/rootfs/usr/local/bin/install-tools b/rootfs/usr/local/bin/install-tools index 53ddd3a..98c4a51 100755 --- a/rootfs/usr/local/bin/install-tools +++ b/rootfs/usr/local/bin/install-tools @@ -37,6 +37,12 @@ php_cs_fixer() { chmod a+x /usr/local/bin/php-cs-fixer } +phpmd() { + echo "Installing PHP Mess Detector" + wget -q https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar -O /usr/local/bin/phpmd + chmod a+x /usr/local/bin/phpmd +} + phpstan() { echo "Installing PHPStan" wget -q https://github.com/phpstan/phpstan/releases/download/1.10.55/phpstan.phar -O /usr/local/bin/phpstan @@ -74,6 +80,7 @@ install() { [ -n "$WITH_EXAKAT" ] && exakat infection php_cs_fixer + phpmd phpstan phpunit pint diff --git a/src/help.sh b/src/help.sh index 6c1e336..aea22b9 100644 --- a/src/help.sh +++ b/src/help.sh @@ -35,6 +35,7 @@ help() { echo -e "033円[0;33mTools:033円[0m" echo -e "033円[0;32m phpunit 033円[0m Runs PHPUnit" echo -e "033円[0;32m php-cs-fixer 033円[0m Runs PHP-CS-Fixer" + echo -e "033円[0;32m phpmd 033円[0m Runs PHP Mess Detector" echo -e "033円[0;32m phpstan 033円[0m Runs PHPStan" echo -e "033円[0;32m infection 033円[0m Runs Infection, a PHP Mutation Testing Framework" echo -e "033円[0;32m pest 033円[0m Runs Pest" diff --git a/src/tools.sh b/src/tools.sh index b617b96..a50fec5 100644 --- a/src/tools.sh +++ b/src/tools.sh @@ -42,6 +42,14 @@ php-cs-fixer() { fi; } +phpmd() { + if [ -f vendor/bin/phpmd ]; then + run -- vendor/bin/phpmd ${@} + else + run -- phpmd ${@} + fi; +} + phpstan() { if [ -f vendor/bin/phpstan ]; then run -- vendor/bin/phpstan ${@} diff --git a/tests/tools_test.sh b/tests/tools_test.sh index 3570144..7e2de81 100644 --- a/tests/tools_test.sh +++ b/tests/tools_test.sh @@ -20,6 +20,10 @@ function test_php_cs_fixer() { assert_contains "PHP CS Fixer 3.46" "$(./bin/phpctl php-cs-fixer --version)" } +function test_phpmd() { + assert_contains "PHPMD 2.15" "$(./bin/phpctl phpmd --version)" +} + function test_phpstan() { assert_contains "PHPStan - PHP Static Analysis Tool 1.10" "$(./bin/phpctl phpstan --version)" } From e42dd27c66640601bd199c9f59d78f55477395f5 Mon Sep 17 00:00:00 2001 From: Douglas Medeiros Date: 2024年2月29日 10:57:10 -0300 Subject: [PATCH 046/130] feat(ext): Decimal (#25) * feat: add decimal extension in Dockerfile * add: add module decimal in readme * fix order --- Dockerfile | 1 + README.md | 1 + 2 files changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 4d70aee..9b475ec 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,6 +33,7 @@ RUN apk add --update --no-cache \ php${PHP}-xmlreader \ php${PHP}-xmlwriter \ php${PHP}-zip \ + php${PHP}-pecl-decimal \ php${PHP}-pecl-mongodb \ php${PHP}-pecl-pcov \ php${PHP}-pecl-rdkafka \ diff --git a/README.md b/README.md index 588486b..182f8e8 100644 --- a/README.md +++ b/README.md @@ -190,6 +190,7 @@ Core ctype curl date +decimal dom fileinfo filter From 85c047895629e6f4c101586b06e4aa31312b8765 Mon Sep 17 00:00:00 2001 From: leocavalcante Date: Sun, 3 Mar 2024 21:02:05 -0300 Subject: [PATCH 047/130] chore(tools): Bump --- rootfs/usr/local/bin/install-tools | 16 ++++++++-------- tests/tools_test.sh | 20 ++++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/rootfs/usr/local/bin/install-tools b/rootfs/usr/local/bin/install-tools index 98c4a51..69502ea 100755 --- a/rootfs/usr/local/bin/install-tools +++ b/rootfs/usr/local/bin/install-tools @@ -2,13 +2,13 @@ box() { echo "Installing Box" - wget -q https://github.com/box-project/box/releases/download/4.5.1/box.phar -O /usr/local/bin/box + wget -q https://github.com/box-project/box/releases/download/4.6.1/box.phar -O /usr/local/bin/box chmod a+x /usr/local/bin/box } composer() { echo "Installing Composer" - wget https://raw.githubusercontent.com/composer/getcomposer.org/76a7060ccb93902cd7576b67264ad91c8a2700e2/web/installer -O - -q | php -- --quiet + wget https://raw.githubusercontent.com/composer/getcomposer.org/2034a5455a11de09418e4c944e6eb0518e4b0d5d/web/installer -O - -q | php -- --quiet mv composer.phar /usr/local/bin/composer chmod a+x /usr/local/bin/composer } @@ -27,13 +27,13 @@ exakat() { infection() { echo "Installing Infection" - wget -q https://github.com/infection/infection/releases/download/0.27.9/infection.phar -O /usr/local/bin/infection + wget -q https://github.com/infection/infection/releases/download/0.27.10/infection.phar -O /usr/local/bin/infection chmod a+x /usr/local/bin/infection } php_cs_fixer() { echo "Installing PHP CS Fixer" - wget -q https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/releases/download/v3.46.0/php-cs-fixer.phar -O /usr/local/bin/php-cs-fixer + wget -q https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/releases/download/v3.51.0/php-cs-fixer.phar -O /usr/local/bin/php-cs-fixer chmod a+x /usr/local/bin/php-cs-fixer } @@ -45,19 +45,19 @@ phpmd() { phpstan() { echo "Installing PHPStan" - wget -q https://github.com/phpstan/phpstan/releases/download/1.10.55/phpstan.phar -O /usr/local/bin/phpstan + wget -q https://github.com/phpstan/phpstan/releases/download/1.10.59/phpstan.phar -O /usr/local/bin/phpstan chmod a+x /usr/local/bin/phpstan } phpunit() { echo "Installing PHPUnit" - wget -q https://phar.phpunit.de/phpunit-10.phar -O /usr/local/bin/phpunit + wget -q https://phar.phpunit.de/phpunit-11.phar -O /usr/local/bin/phpunit chmod a+x /usr/local/bin/phpunit } pint() { echo "Installing Pint" - wget -q https://github.com/laravel/pint/releases/download/v1.13.7/pint.phar -O /usr/local/bin/pint + wget -q https://github.com/laravel/pint/releases/download/v1.14.0/pint.phar -O /usr/local/bin/pint chmod a+x /usr/local/bin/pint } @@ -69,7 +69,7 @@ psysh() { watchr() { echo "Installing watchr" - wget -q https://github.com/flavioheleno/watchr/releases/download/v0.4.1/watchr.phar -O /usr/local/bin/watchr + wget -q https://github.com/flavioheleno/watchr/releases/download/v0.5.2/watchr.phar -O /usr/local/bin/watchr chmod a+x /usr/local/bin/watchr } diff --git a/tests/tools_test.sh b/tests/tools_test.sh index 7e2de81..7789067 100644 --- a/tests/tools_test.sh +++ b/tests/tools_test.sh @@ -1,43 +1,43 @@ function test_box() { - assert_contains "Box version 4.5" "$(./bin/phpctl box --version)" + assert_matches "Box version 4\." "$(./bin/phpctl box --version)" } function test_couscous() { - assert_contains "Couscous 1.10" "$(./bin/phpctl couscous --version)" + assert_matches "Couscous 1\." "$(./bin/phpctl couscous --version)" } function test_exakat() { if [ -n "$WITH_EXAKAT" ]; then - assert_contains "Version : 2.6" "$(./bin/phpctl exakat version)" + assert_matches "Version : 2\." "$(./bin/phpctl exakat version)" fi } function test_infection() { - assert_contains "Infection - PHP Mutation Testing Framework version 0.27" "$(./bin/phpctl infection --version)" + assert_matches "Infection - PHP Mutation Testing Framework version 0\.27\." "$(./bin/phpctl infection --version)" } function test_php_cs_fixer() { - assert_contains "PHP CS Fixer 3.46" "$(./bin/phpctl php-cs-fixer --version)" + assert_matches "PHP CS Fixer 3\." "$(./bin/phpctl php-cs-fixer --version)" } function test_phpmd() { - assert_contains "PHPMD 2.15" "$(./bin/phpctl phpmd --version)" + assert_matches "PHPMD 2\." "$(./bin/phpctl phpmd --version)" } function test_phpstan() { - assert_contains "PHPStan - PHP Static Analysis Tool 1.10" "$(./bin/phpctl phpstan --version)" + assert_matches "PHPStan - PHP Static Analysis Tool 1\." "$(./bin/phpctl phpstan --version)" } function test_phpunit() { - assert_contains "PHPUnit 10.5" "$(./bin/phpctl phpunit --version)" + assert_matches "PHPUnit 11\." "$(./bin/phpctl phpunit --version)" } function test_pint() { - assert_contains "Pint 1.13" "$(./bin/phpctl pint --version)" + assert_matches "Pint 1\." "$(./bin/phpctl pint --version)" } function test_watchr() { if [ -z "$WITHOUT_WATCHR" ]; then - assert_contains "watchr command-line utility v0.4.1@b1b8dd5" "$(./bin/phpctl watchr --version)" + assert_matches "watchr command-line utility v0\.5\." "$(./bin/phpctl watchr --version)" fi } From 7ab9f1b7b7547bcfbd6552fdf3e2b1c5d4b374dd Mon Sep 17 00:00:00 2001 From: leocavalcante Date: Sun, 3 Mar 2024 21:32:38 -0300 Subject: [PATCH 048/130] fix(tools): PHP version match --- Dockerfile | 2 + rootfs/usr/local/bin/install-tools | 63 +++++++++++++++++++----------- src/docker.sh | 4 +- tests/tools_test.sh | 8 +++- 4 files changed, 50 insertions(+), 27 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9b475ec..00e3987 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,8 @@ ARG ALPINE=3.19 FROM alpine:${ALPINE} + ARG PHP +ENV PHP_VERSION=$PHP ARG WITH_EXAKAT ENV WITH_EXAKAT=$WITH_EXAKAT diff --git a/rootfs/usr/local/bin/install-tools b/rootfs/usr/local/bin/install-tools index 69502ea..1afcd6f 100755 --- a/rootfs/usr/local/bin/install-tools +++ b/rootfs/usr/local/bin/install-tools @@ -1,63 +1,79 @@ -#!/usr/bin/env sh +#!/usr/bin/env ash box() { - echo "Installing Box" - wget -q https://github.com/box-project/box/releases/download/4.6.1/box.phar -O /usr/local/bin/box + local version="4.6.1" + if [ "$PHP_VERSION" = "81" ]; then + version="4.5.1" + fi + echo "Installing Box $version" + wget -q "https://github.com/box-project/box/releases/download/$version/box.phar" -O /usr/local/bin/box chmod a+x /usr/local/bin/box } composer() { - echo "Installing Composer" - wget https://raw.githubusercontent.com/composer/getcomposer.org/2034a5455a11de09418e4c944e6eb0518e4b0d5d/web/installer -O - -q | php -- --quiet + local version="2034a5455a11de09418e4c944e6eb0518e4b0d5d" + echo "Installing Composer $version" + wget "https://raw.githubusercontent.com/composer/getcomposer.org/$version/web/installer" -O - -q | php -- --quiet mv composer.phar /usr/local/bin/composer chmod a+x /usr/local/bin/composer } couscous() { - echo "Installing Couscous" - wget -q https://github.com/CouscousPHP/Couscous/releases/download/1.10.0/couscous.phar -O /usr/local/bin/couscous + local version="1.10.0" + echo "Installing Couscous $version" + wget -q "https://github.com/CouscousPHP/Couscous/releases/download/$version/couscous.phar" -O /usr/local/bin/couscous chmod a+x /usr/local/bin/couscous } exakat() { - echo "Installing Exakat" - wget -q https://www.exakat.io/versions/index.php?file=exakat-2.6.2.phar -O /usr/local/bin/exakat + local version="2.6.2" + echo "Installing Exakat $version" + wget -q "https://www.exakat.io/versions/index.php?file=exakat-$version.phar" -O /usr/local/bin/exakat chmod a+x /usr/local/bin/exakat } infection() { - echo "Installing Infection" - wget -q https://github.com/infection/infection/releases/download/0.27.10/infection.phar -O /usr/local/bin/infection + local version="0.27.10" + echo "Installing Infection $version" + wget -q "https://github.com/infection/infection/releases/download/$version/infection.phar" -O /usr/local/bin/infection chmod a+x /usr/local/bin/infection } php_cs_fixer() { - echo "Installing PHP CS Fixer" - wget -q https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/releases/download/v3.51.0/php-cs-fixer.phar -O /usr/local/bin/php-cs-fixer + local version="3.51.0" + echo "Installing PHP CS Fixer $version" + wget -q "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/releases/download/v$version/php-cs-fixer.phar" -O /usr/local/bin/php-cs-fixer chmod a+x /usr/local/bin/php-cs-fixer } phpmd() { - echo "Installing PHP Mess Detector" - wget -q https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar -O /usr/local/bin/phpmd + local version="2.15.0" + echo "Installing PHP Mess Detector $version" + wget -q "https://github.com/phpmd/phpmd/releases/download/$version/phpmd.phar" -O /usr/local/bin/phpmd chmod a+x /usr/local/bin/phpmd } phpstan() { - echo "Installing PHPStan" - wget -q https://github.com/phpstan/phpstan/releases/download/1.10.59/phpstan.phar -O /usr/local/bin/phpstan + local version="1.10.59" + echo "Installing PHPStan $version" + wget -q "https://github.com/phpstan/phpstan/releases/download/$version/phpstan.phar" -O /usr/local/bin/phpstan chmod a+x /usr/local/bin/phpstan } phpunit() { - echo "Installing PHPUnit" - wget -q https://phar.phpunit.de/phpunit-11.phar -O /usr/local/bin/phpunit + local version="11" + if [ "$PHP_VERSION" = "81" ]; then + version="10" + fi + echo "Installing PHPUnit $version" + wget -q "https://phar.phpunit.de/phpunit-$version.phar" -O /usr/local/bin/phpunit chmod a+x /usr/local/bin/phpunit } pint() { - echo "Installing Pint" - wget -q https://github.com/laravel/pint/releases/download/v1.14.0/pint.phar -O /usr/local/bin/pint + local version="1.14.0" + echo "Installing Pint $version" + wget -q "https://github.com/laravel/pint/releases/download/v$version/pint.phar" -O /usr/local/bin/pint chmod a+x /usr/local/bin/pint } @@ -68,8 +84,9 @@ psysh() { } watchr() { - echo "Installing watchr" - wget -q https://github.com/flavioheleno/watchr/releases/download/v0.5.2/watchr.phar -O /usr/local/bin/watchr + local version="0.5.2" + echo "Installing watchr $version" + wget -q "https://github.com/flavioheleno/watchr/releases/download/v$version/watchr.phar" -O /usr/local/bin/watchr chmod a+x /usr/local/bin/watchr } diff --git a/src/docker.sh b/src/docker.sh index fa4302c..02ababc 100644 --- a/src/docker.sh +++ b/src/docker.sh @@ -5,14 +5,14 @@ build() { fi local without_watchr="" - if [[ "$*" == *--without-watchr* ]]; then + if [[ "$*" == *--without-watchr* ]] || [ "$PHP_VERSION" = "81" ]; then without_watchr="--build-arg WITHOUT_WATCHR=1" fi echo -e "Building 033円[0;32m$PHPCTL_IMAGE033円[0m" # shellcheck disable=SC2068 # shellcheck disable=SC2154 - $PHPCTL_RUNTIME build \ + $PHPCTL_RUNTIME buildx build --no-cache \ --build-arg PHP="$PHP_VERSION" \ --build-arg COMPOSER_AUTH="$COMPOSER_AUTH" \ --build-arg HOST_USER="$(whoami)" \ diff --git a/tests/tools_test.sh b/tests/tools_test.sh index 7789067..d334bbb 100644 --- a/tests/tools_test.sh +++ b/tests/tools_test.sh @@ -29,7 +29,11 @@ function test_phpstan() { } function test_phpunit() { - assert_matches "PHPUnit 11\." "$(./bin/phpctl phpunit --version)" + if [ "$PHP_VERSION" = "81" ]; then + assert_matches "PHPUnit 10\." "$(./bin/phpctl phpunit --version)" + else + assert_matches "PHPUnit 11\." "$(./bin/phpctl phpunit --version)" + fi } function test_pint() { @@ -37,7 +41,7 @@ function test_pint() { } function test_watchr() { - if [ -z "$WITHOUT_WATCHR" ]; then + if [ -z "$WITHOUT_WATCHR" ] && ! [ "$PHP_VERSION" = "81" ]; then assert_matches "watchr command-line utility v0\.5\." "$(./bin/phpctl watchr --version)" fi } From 94c4deaaf8f6cafd100e0842d324bbccde94faee Mon Sep 17 00:00:00 2001 From: leocavalcante Date: Sun, 3 Mar 2024 22:09:13 -0300 Subject: [PATCH 049/130] feat(tool): PHP_CodeSniffer --- Makefile | 8 ++++++-- README.md | 30 ++++++++++++++++-------------- bin/phpcbf | 2 ++ bin/phpcs | 2 ++ rootfs/usr/local/bin/install-tools | 16 ++++++++++++++++ src/help.sh | 14 ++++++++------ src/tools.sh | 16 ++++++++++++++++ tests/tools_test.sh | 8 ++++++++ 8 files changed, 74 insertions(+), 22 deletions(-) create mode 100644 bin/phpcbf create mode 100644 bin/phpcs diff --git a/Makefile b/Makefile index d2eddbb..1b1a29e 100644 --- a/Makefile +++ b/Makefile @@ -3,11 +3,15 @@ default: build .PHONY: build build: - phpctl build + @PHP_VERSION=81 phpctl build + @PHP_VERSION=82 phpctl build + @PHP_VERSION=83 phpctl build .PHONY: test test: - @COMPOSER_AUTH= TERM= notty ./lib/bashunit ./tests/ + @PHP_VERSION=81 COMPOSER_AUTH= TERM= notty ./lib/bashunit ./tests/ + @PHP_VERSION=82 COMPOSER_AUTH= TERM= notty ./lib/bashunit ./tests/ + @PHP_VERSION=83 COMPOSER_AUTH= TERM= notty ./lib/bashunit ./tests/ .PHONY: install install: diff --git a/README.md b/README.md index 182f8e8..afc7002 100644 --- a/README.md +++ b/README.md @@ -86,20 +86,22 @@ phpctl sh echo 'Hello, World!' # To run arbitrary sh commands inside the contain | `bundle` | Bundles a project into an image and ships it as a single binary file. | ### Tools -| Command | Description | -|----------------|-------------------------------------------------------------------------------------------------------------------------------| -| `phpunit` | [PHPUnit](https://phpunit.de) is a programmer-oriented testing framework for PHP. | -| `php-cs-fixer` | [PHP Coding Standards Fixer (PHP CS Fixer)](https://cs.symfony.com/) fixes your code to follow standards. | -| `phpmd` | [PHP Mess Detector](https://phpmd.org/) looks for several potential problems within your source code. | -| `phpstan` | [PHPStan](https://phpstan.org/) finds bugs in your code without writing tests. It's open-source and free. | -| `infection` | [Infection](https://infection.github.io) is a Mutation Testing Framework. | -| `pest` | [Pest](https://pestphp.com) is a testing framework with a focus on simplicity. | -| `pint` | [Pint](https://github.com/laravel/pint) is an opinionated PHP code style fixer for minimalists. | -| `box` | [Box](https://github.com/box-project/box): fast, zero config application bundler with PHARs. | -| `exakat` | [Exakat](https://www.exakat.io) is a real time customizable static analyzer engine that analyse and fix code. | -| `frankenphp` | [FrankenPHP](https://frankenphp.dev): the Modern PHP App Server, written in Go. | -| `rector` | [Rector](https://getrector.com) is a tool that you can run on any project to get an instant upgrade or automated refactoring. | -| `watchr` | [watchr](https://github.com/flavioheleno/watchr): command-line utility to explore and validate domain names and certificates. | +| Command | Description | +|----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------| +| `box` | [Box](https://github.com/box-project/box): fast, zero config application bundler with PHARs. | +| `exakat` | [Exakat](https://www.exakat.io) is a real time customizable static analyzer engine that analyse and fix code. | +| `frankenphp` | [FrankenPHP](https://frankenphp.dev): the Modern PHP App Server, written in Go. | +| `infection` | [Infection](https://infection.github.io) is a Mutation Testing Framework. | +| `pest` | [Pest](https://pestphp.com) is a testing framework with a focus on simplicity. | +| `php-cs-fixer` | [PHP Coding Standards Fixer (PHP CS Fixer)](https://cs.symfony.com/) fixes your code to follow standards. | +| `phpcbf` | [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) is an essential development tool that ensures your code remains clean and consistent. | +| `phpcs` | [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) is an essential development tool that ensures your code remains clean and consistent. | +| `phpmd` | [PHP Mess Detector](https://phpmd.org/) looks for several potential problems within your source code. | +| `phpstan` | [PHPStan](https://phpstan.org/) finds bugs in your code without writing tests. It's open-source and free. | +| `phpunit` | [PHPUnit](https://phpunit.de) is a programmer-oriented testing framework for PHP. | +| `pint` | [Pint](https://github.com/laravel/pint) is an opinionated PHP code style fixer for minimalists. | +| `rector` | [Rector](https://getrector.com) is a tool that you can run on any project to get an instant upgrade or automated refactoring. | +| `watchr` | [watchr](https://github.com/flavioheleno/watchr): command-line utility to explore and validate domain names and certificates. | ### Scaffolders | Command | Description | diff --git a/bin/phpcbf b/bin/phpcbf new file mode 100644 index 0000000..a41a85a --- /dev/null +++ b/bin/phpcbf @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +phpctl phpcbf $@ diff --git a/bin/phpcs b/bin/phpcs new file mode 100644 index 0000000..9882622 --- /dev/null +++ b/bin/phpcs @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +phpctl phpcs $@ diff --git a/rootfs/usr/local/bin/install-tools b/rootfs/usr/local/bin/install-tools index 1afcd6f..ec1ba91 100755 --- a/rootfs/usr/local/bin/install-tools +++ b/rootfs/usr/local/bin/install-tools @@ -46,6 +46,20 @@ php_cs_fixer() { chmod a+x /usr/local/bin/php-cs-fixer } +phpcbf() { + local version="3.7.2" + echo "Installing PHP CodeSniffer $version (phpcbf)" + wget -q "https://github.com/squizlabs/PHP_CodeSniffer/releases/download/$version/phpcbf.phar" -O /usr/local/bin/phpcbf + chmod a+x /usr/local/bin/phpcbf +} + +phpcs() { + local version="3.7.2" + echo "Installing PHP CodeSniffer $version (phpcs)" + wget -q "https://github.com/squizlabs/PHP_CodeSniffer/releases/download/$version/phpcs.phar" -O /usr/local/bin/phpcs + chmod a+x /usr/local/bin/phpcs +} + phpmd() { local version="2.15.0" echo "Installing PHP Mess Detector $version" @@ -97,6 +111,8 @@ install() { [ -n "$WITH_EXAKAT" ] && exakat infection php_cs_fixer + phpcbf + phpcs phpmd phpstan phpunit diff --git a/src/help.sh b/src/help.sh index aea22b9..498245b 100644 --- a/src/help.sh +++ b/src/help.sh @@ -33,16 +33,18 @@ help() { echo -e "033円[0;32m images 033円[0m Shows local phpctl images" echo -e "" echo -e "033円[0;33mTools:033円[0m" - echo -e "033円[0;32m phpunit 033円[0m Runs PHPUnit" + echo -e "033円[0;32m box 033円[0m Runs Box (PHAR builder)" + echo -e "033円[0;32m exakat 033円[0m Runs Exakat" + echo -e "033円[0;32m frankenphp 033円[0m Runs FrankenPHP" + echo -e "033円[0;32m infection 033円[0m Runs Infection, a PHP Mutation Testing Framework" + echo -e "033円[0;32m pest 033円[0m Runs Pest" echo -e "033円[0;32m php-cs-fixer 033円[0m Runs PHP-CS-Fixer" + echo -e "033円[0;32m phpcbf 033円[0m Runs PHP_CodeSniffer (phpcbf)" + echo -e "033円[0;32m phpcs 033円[0m Runs PHP_CodeSniffer (phpcs)" echo -e "033円[0;32m phpmd 033円[0m Runs PHP Mess Detector" echo -e "033円[0;32m phpstan 033円[0m Runs PHPStan" - echo -e "033円[0;32m infection 033円[0m Runs Infection, a PHP Mutation Testing Framework" - echo -e "033円[0;32m pest 033円[0m Runs Pest" + echo -e "033円[0;32m phpunit 033円[0m Runs PHPUnit" echo -e "033円[0;32m pint 033円[0m Runs Pint" - echo -e "033円[0;32m box 033円[0m Runs Box (PHAR builder)" - echo -e "033円[0;32m exakat 033円[0m Runs Exakat" - echo -e "033円[0;32m frankenphp 033円[0m Runs FrankenPHP" echo -e "033円[0;32m rector 033円[0m Runs Rector" echo -e "033円[0;32m watchr 033円[0m Runs watchr" echo -e "" diff --git a/src/tools.sh b/src/tools.sh index a50fec5..84e9b02 100644 --- a/src/tools.sh +++ b/src/tools.sh @@ -42,6 +42,22 @@ php-cs-fixer() { fi; } +phpcbf() { + if [ -f vendor/bin/phpcbf ]; then + run -- vendor/bin/phpcbf ${@} + else + run -- phpcbf ${@} + fi; +} + +phpcs() { + if [ -f vendor/bin/phpcs ]; then + run -- vendor/bin/phpcs ${@} + else + run -- phpcs ${@} + fi; +} + phpmd() { if [ -f vendor/bin/phpmd ]; then run -- vendor/bin/phpmd ${@} diff --git a/tests/tools_test.sh b/tests/tools_test.sh index d334bbb..c1e725a 100644 --- a/tests/tools_test.sh +++ b/tests/tools_test.sh @@ -20,6 +20,14 @@ function test_php_cs_fixer() { assert_matches "PHP CS Fixer 3\." "$(./bin/phpctl php-cs-fixer --version)" } +function test_phpcbf() { + assert_matches "PHP_CodeSniffer version 3\." "$(./bin/phpctl phpcbf --version)" +} + +function test_phpcs() { + assert_matches "PHP_CodeSniffer version 3\." "$(./bin/phpctl phpcs --version)" +} + function test_phpmd() { assert_matches "PHPMD 2\." "$(./bin/phpctl phpmd --version)" } From 01dda87603ab26b6141b37cc1e3a832554c9daec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20Heleno?= Date: Thu, 7 Mar 2024 21:15:20 -0300 Subject: [PATCH 050/130] Bump watchr to v0.5.3 (#28) --- rootfs/usr/local/bin/install-tools | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rootfs/usr/local/bin/install-tools b/rootfs/usr/local/bin/install-tools index ec1ba91..896fa54 100755 --- a/rootfs/usr/local/bin/install-tools +++ b/rootfs/usr/local/bin/install-tools @@ -98,7 +98,7 @@ psysh() { } watchr() { - local version="0.5.2" + local version="0.5.3" echo "Installing watchr $version" wget -q "https://github.com/flavioheleno/watchr/releases/download/v$version/watchr.phar" -O /usr/local/bin/watchr chmod a+x /usr/local/bin/watchr From f807ecee00a31732dd6019bf1625b66eda73a60c Mon Sep 17 00:00:00 2001 From: leocavalcante Date: 2024年3月11日 19:16:02 -0300 Subject: [PATCH 051/130] chore(deps): Bump Composer --- rootfs/usr/local/bin/install-tools | 2 +- tests/php_test.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rootfs/usr/local/bin/install-tools b/rootfs/usr/local/bin/install-tools index 896fa54..3d12dc7 100755 --- a/rootfs/usr/local/bin/install-tools +++ b/rootfs/usr/local/bin/install-tools @@ -11,7 +11,7 @@ box() { } composer() { - local version="2034a5455a11de09418e4c944e6eb0518e4b0d5d" + local version="993f9fec74930f32f7015e71543243bf6d9b9e93" echo "Installing Composer $version" wget "https://raw.githubusercontent.com/composer/getcomposer.org/$version/web/installer" -O - -q | php -- --quiet mv composer.phar /usr/local/bin/composer diff --git a/tests/php_test.sh b/tests/php_test.sh index c52d10a..f2a275b 100644 --- a/tests/php_test.sh +++ b/tests/php_test.sh @@ -8,7 +8,7 @@ function test_php_accepts_arguments() { } function test_composer() { - assert_contains "version" "$(./bin/phpctl composer --version)" + assert_contains "Composer version 2" "$(./bin/phpctl composer)" } function test_phpctl_ini() { From fab6372c3ca7741f50ba6256ce3d4c25266bcc06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20Heleno?= Date: 2024年3月11日 19:21:09 -0300 Subject: [PATCH 052/130] chore(docs): Couscous (#30) --- README.md | 1 + bin/couscous | 2 ++ src/help.sh | 1 + 3 files changed, 4 insertions(+) create mode 100644 bin/couscous diff --git a/README.md b/README.md index afc7002..c2d4caa 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,7 @@ phpctl sh echo 'Hello, World!' # To run arbitrary sh commands inside the contain | Command | Description | |----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------| | `box` | [Box](https://github.com/box-project/box): fast, zero config application bundler with PHARs. | +| `couscous` | [Couscous](https://github.com/CouscousPHP/Couscous): Couscous generates a GitHub pages website from your markdown documentation. | | `exakat` | [Exakat](https://www.exakat.io) is a real time customizable static analyzer engine that analyse and fix code. | | `frankenphp` | [FrankenPHP](https://frankenphp.dev): the Modern PHP App Server, written in Go. | | `infection` | [Infection](https://infection.github.io) is a Mutation Testing Framework. | diff --git a/bin/couscous b/bin/couscous new file mode 100644 index 0000000..b1a31e7 --- /dev/null +++ b/bin/couscous @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +phpctl couscous $@ diff --git a/src/help.sh b/src/help.sh index 498245b..80160c0 100644 --- a/src/help.sh +++ b/src/help.sh @@ -34,6 +34,7 @@ help() { echo -e "" echo -e "033円[0;33mTools:033円[0m" echo -e "033円[0;32m box 033円[0m Runs Box (PHAR builder)" + echo -e "033円[0;32m couscous 033円[0m Runs Couscous" echo -e "033円[0;32m exakat 033円[0m Runs Exakat" echo -e "033円[0;32m frankenphp 033円[0m Runs FrankenPHP" echo -e "033円[0;32m infection 033円[0m Runs Infection, a PHP Mutation Testing Framework" From 24f9bfb42acfbf2bc75a276508c3eb6408d78a26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20Heleno?= Date: 2024年3月11日 19:32:41 -0300 Subject: [PATCH 053/130] feat(tool): ComposerRequireChecker (#29) * Add ComposerRequireChecker to the tool list * fix(ComposerRequireChecker): PHP 8.1 support --------- Co-authored-by: leocavalcante --- README.md | 35 +++++++++++++++--------------- bin/composer-require-checker | 2 ++ rootfs/usr/local/bin/install-tools | 11 ++++++++++ src/help.sh | 1 + src/tools.sh | 4 ++++ tests/tools_test.sh | 4 ++++ 6 files changed, 40 insertions(+), 17 deletions(-) create mode 100755 bin/composer-require-checker diff --git a/README.md b/README.md index c2d4caa..20645b8 100644 --- a/README.md +++ b/README.md @@ -86,23 +86,24 @@ phpctl sh echo 'Hello, World!' # To run arbitrary sh commands inside the contain | `bundle` | Bundles a project into an image and ships it as a single binary file. | ### Tools -| Command | Description | -|----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------| -| `box` | [Box](https://github.com/box-project/box): fast, zero config application bundler with PHARs. | -| `couscous` | [Couscous](https://github.com/CouscousPHP/Couscous): Couscous generates a GitHub pages website from your markdown documentation. | -| `exakat` | [Exakat](https://www.exakat.io) is a real time customizable static analyzer engine that analyse and fix code. | -| `frankenphp` | [FrankenPHP](https://frankenphp.dev): the Modern PHP App Server, written in Go. | -| `infection` | [Infection](https://infection.github.io) is a Mutation Testing Framework. | -| `pest` | [Pest](https://pestphp.com) is a testing framework with a focus on simplicity. | -| `php-cs-fixer` | [PHP Coding Standards Fixer (PHP CS Fixer)](https://cs.symfony.com/) fixes your code to follow standards. | -| `phpcbf` | [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) is an essential development tool that ensures your code remains clean and consistent. | -| `phpcs` | [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) is an essential development tool that ensures your code remains clean and consistent. | -| `phpmd` | [PHP Mess Detector](https://phpmd.org/) looks for several potential problems within your source code. | -| `phpstan` | [PHPStan](https://phpstan.org/) finds bugs in your code without writing tests. It's open-source and free. | -| `phpunit` | [PHPUnit](https://phpunit.de) is a programmer-oriented testing framework for PHP. | -| `pint` | [Pint](https://github.com/laravel/pint) is an opinionated PHP code style fixer for minimalists. | -| `rector` | [Rector](https://getrector.com) is a tool that you can run on any project to get an instant upgrade or automated refactoring. | -| `watchr` | [watchr](https://github.com/flavioheleno/watchr): command-line utility to explore and validate domain names and certificates. | +| Command | Description | +|----------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `box` | [Box](https://github.com/box-project/box): fast, zero config application bundler with PHARs. | +| `composer-require-checker` | [ComposerRequireChecker](https://github.com/maglnet/ComposerRequireChecker): A CLI tool to analyze composer dependencies and verify that no unknown symbols are used in the sources of a package. | +| `couscous` | [Couscous](https://github.com/CouscousPHP/Couscous): Couscous generates a GitHub pages website from your markdown documentation. | +| `exakat` | [Exakat](https://www.exakat.io) is a real time customizable static analyzer engine that analyse and fix code. | +| `frankenphp` | [FrankenPHP](https://frankenphp.dev): the Modern PHP App Server, written in Go. | +| `infection` | [Infection](https://infection.github.io) is a Mutation Testing Framework. | +| `pest` | [Pest](https://pestphp.com) is a testing framework with a focus on simplicity. | +| `php-cs-fixer` | [PHP Coding Standards Fixer (PHP CS Fixer)](https://cs.symfony.com/) fixes your code to follow standards. | +| `phpcbf` | [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) is an essential development tool that ensures your code remains clean and consistent. | +| `phpcs` | [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) is an essential development tool that ensures your code remains clean and consistent. | +| `phpmd` | [PHP Mess Detector](https://phpmd.org/) looks for several potential problems within your source code. | +| `phpstan` | [PHPStan](https://phpstan.org/) finds bugs in your code without writing tests. It's open-source and free. | +| `phpunit` | [PHPUnit](https://phpunit.de) is a programmer-oriented testing framework for PHP. | +| `pint` | [Pint](https://github.com/laravel/pint) is an opinionated PHP code style fixer for minimalists. | +| `rector` | [Rector](https://getrector.com) is a tool that you can run on any project to get an instant upgrade or automated refactoring. | +| `watchr` | [watchr](https://github.com/flavioheleno/watchr): command-line utility to explore and validate domain names and certificates. | ### Scaffolders | Command | Description | diff --git a/bin/composer-require-checker b/bin/composer-require-checker new file mode 100755 index 0000000..c825e4b --- /dev/null +++ b/bin/composer-require-checker @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +phpctl composer-require-checker $@ diff --git a/rootfs/usr/local/bin/install-tools b/rootfs/usr/local/bin/install-tools index 3d12dc7..1532a8c 100755 --- a/rootfs/usr/local/bin/install-tools +++ b/rootfs/usr/local/bin/install-tools @@ -18,6 +18,16 @@ composer() { chmod a+x /usr/local/bin/composer } +composer_require_checker() { + local version="4.10.0" + if [ "$PHP_VERSION" = "81" ]; then + version="4.7.1" + fi + echo "Installing ComposerRequireChecker $version" + wget -q "https://github.com/maglnet/ComposerRequireChecker/releases/download/$version/composer-require-checker.phar" -O /usr/local/bin/composer-require-checker + chmod a+x /usr/local/bin/composer-require-checker +} + couscous() { local version="1.10.0" echo "Installing Couscous $version" @@ -107,6 +117,7 @@ watchr() { install() { box composer + composer_require_checker couscous [ -n "$WITH_EXAKAT" ] && exakat infection diff --git a/src/help.sh b/src/help.sh index 80160c0..6201709 100644 --- a/src/help.sh +++ b/src/help.sh @@ -34,6 +34,7 @@ help() { echo -e "" echo -e "033円[0;33mTools:033円[0m" echo -e "033円[0;32m box 033円[0m Runs Box (PHAR builder)" + echo -e "033円[0;32m composer-require-checker 033円[0m Runs ComposerRequireChecker" echo -e "033円[0;32m couscous 033円[0m Runs Couscous" echo -e "033円[0;32m exakat 033円[0m Runs Exakat" echo -e "033円[0;32m frankenphp 033円[0m Runs FrankenPHP" diff --git a/src/tools.sh b/src/tools.sh index 84e9b02..273d596 100644 --- a/src/tools.sh +++ b/src/tools.sh @@ -6,6 +6,10 @@ box() { fi; } +composer-require-checker() { + run -- composer-require-checker ${@} +} + couscous() { if [ -f vendor/bin/couscous ]; then run -- vendor/bin/couscous ${@} diff --git a/tests/tools_test.sh b/tests/tools_test.sh index c1e725a..f1dc9c2 100644 --- a/tests/tools_test.sh +++ b/tests/tools_test.sh @@ -2,6 +2,10 @@ function test_box() { assert_matches "Box version 4\." "$(./bin/phpctl box --version)" } +function test_composer_require_checker() { + assert_matches "ComposerRequireChecker 4\." "$(./bin/phpctl composer-require-checker --version)" +} + function test_couscous() { assert_matches "Couscous 1\." "$(./bin/phpctl couscous --version)" } From e79a6ec6c7f85af132e9a771b39143fe6c87fab7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20Heleno?= Date: 2024年3月12日 12:09:09 -0300 Subject: [PATCH 054/130] feat(tools): Deptrac (#31) --- README.md | 1 + bin/deptrac | 2 ++ rootfs/usr/local/bin/install-tools | 8 ++++++++ src/help.sh | 1 + src/tools.sh | 4 ++++ tests/tools_test.sh | 4 ++++ 6 files changed, 20 insertions(+) create mode 100644 bin/deptrac diff --git a/README.md b/README.md index 20645b8..4d3960c 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,7 @@ phpctl sh echo 'Hello, World!' # To run arbitrary sh commands inside the contain | `box` | [Box](https://github.com/box-project/box): fast, zero config application bundler with PHARs. | | `composer-require-checker` | [ComposerRequireChecker](https://github.com/maglnet/ComposerRequireChecker): A CLI tool to analyze composer dependencies and verify that no unknown symbols are used in the sources of a package. | | `couscous` | [Couscous](https://github.com/CouscousPHP/Couscous): Couscous generates a GitHub pages website from your markdown documentation. | +| `deptrac` | [Deptrac](https://github.com/qossmic/deptrac): Deptrac is a static code analysis tool for PHP that helps you communicate, visualize and enforce architectural decisions in your projects. | | `exakat` | [Exakat](https://www.exakat.io) is a real time customizable static analyzer engine that analyse and fix code. | | `frankenphp` | [FrankenPHP](https://frankenphp.dev): the Modern PHP App Server, written in Go. | | `infection` | [Infection](https://infection.github.io) is a Mutation Testing Framework. | diff --git a/bin/deptrac b/bin/deptrac new file mode 100644 index 0000000..0efe0f4 --- /dev/null +++ b/bin/deptrac @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +phpctl deptrac $@ diff --git a/rootfs/usr/local/bin/install-tools b/rootfs/usr/local/bin/install-tools index 1532a8c..2f24e24 100755 --- a/rootfs/usr/local/bin/install-tools +++ b/rootfs/usr/local/bin/install-tools @@ -35,6 +35,13 @@ couscous() { chmod a+x /usr/local/bin/couscous } +deptrac() { + local version="1.0.2" + echo "Installing Deptrac $version" + wget -q "https://github.com/qossmic/deptrac/releases/download/$version/deptrac.phar" -O /usr/local/bin/deptrac + chmod a+x /usr/local/bin/deptrac +} + exakat() { local version="2.6.2" echo "Installing Exakat $version" @@ -119,6 +126,7 @@ install() { composer composer_require_checker couscous + deptrac [ -n "$WITH_EXAKAT" ] && exakat infection php_cs_fixer diff --git a/src/help.sh b/src/help.sh index 6201709..e55ddc2 100644 --- a/src/help.sh +++ b/src/help.sh @@ -36,6 +36,7 @@ help() { echo -e "033円[0;32m box 033円[0m Runs Box (PHAR builder)" echo -e "033円[0;32m composer-require-checker 033円[0m Runs ComposerRequireChecker" echo -e "033円[0;32m couscous 033円[0m Runs Couscous" + echo -e "033円[0;32m deptrac 033円[0m Runs Deptrac" echo -e "033円[0;32m exakat 033円[0m Runs Exakat" echo -e "033円[0;32m frankenphp 033円[0m Runs FrankenPHP" echo -e "033円[0;32m infection 033円[0m Runs Infection, a PHP Mutation Testing Framework" diff --git a/src/tools.sh b/src/tools.sh index 273d596..b64413e 100644 --- a/src/tools.sh +++ b/src/tools.sh @@ -18,6 +18,10 @@ couscous() { fi; } +deptrac() { + run -- deptrac ${@} +} + exakat() { if [ -f vendor/bin/exakat ]; then run -- vendor/bin/exakat ${@} diff --git a/tests/tools_test.sh b/tests/tools_test.sh index f1dc9c2..adad98a 100644 --- a/tests/tools_test.sh +++ b/tests/tools_test.sh @@ -10,6 +10,10 @@ function test_couscous() { assert_matches "Couscous 1\." "$(./bin/phpctl couscous --version)" } +function test_deptrac() { + assert_matches "deptrac 1\." "$(./bin/phpctl deptrac --version)" +} + function test_exakat() { if [ -n "$WITH_EXAKAT" ]; then assert_matches "Version : 2\." "$(./bin/phpctl exakat version)" From 5e63e6e0cbf9ac19e6f6d36f71420c5605157c8d Mon Sep 17 00:00:00 2001 From: Douglas Medeiros Date: 2024年3月12日 12:19:03 -0300 Subject: [PATCH 055/130] feat(ext): DS (#33) --- Dockerfile | 1 + README.md | 1 + 2 files changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 00e3987..971c535 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,6 +36,7 @@ RUN apk add --update --no-cache \ php${PHP}-xmlwriter \ php${PHP}-zip \ php${PHP}-pecl-decimal \ + php${PHP}-pecl-ds \ php${PHP}-pecl-mongodb \ php${PHP}-pecl-pcov \ php${PHP}-pecl-rdkafka \ diff --git a/README.md b/README.md index 4d3960c..7ab50c2 100644 --- a/README.md +++ b/README.md @@ -196,6 +196,7 @@ ctype curl date decimal +ds dom fileinfo filter From ce3032a02d0a7b321c2b9043ad0c44d40336c09d Mon Sep 17 00:00:00 2001 From: leocavalcante Date: 2024年3月12日 13:30:43 -0300 Subject: [PATCH 056/130] feat(tool): co-phpunit --- README.md | 1 + bin/co-phpunit | 2 ++ rootfs/usr/local/bin/install-tools | 8 ++++++++ src/help.sh | 1 + src/tools.sh | 8 ++++++++ tests/tools_test.sh | 4 ++++ 6 files changed, 24 insertions(+) create mode 100755 bin/co-phpunit diff --git a/README.md b/README.md index 7ab50c2..3998d80 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,7 @@ phpctl sh echo 'Hello, World!' # To run arbitrary sh commands inside the contain | Command | Description | |----------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `box` | [Box](https://github.com/box-project/box): fast, zero config application bundler with PHARs. | +| `co-phpunit` | [co-phpunit](https://github.com/hyperf/testing) is a Coroutine-aware PHPUnit for testing Hyperf projects. | | `composer-require-checker` | [ComposerRequireChecker](https://github.com/maglnet/ComposerRequireChecker): A CLI tool to analyze composer dependencies and verify that no unknown symbols are used in the sources of a package. | | `couscous` | [Couscous](https://github.com/CouscousPHP/Couscous): Couscous generates a GitHub pages website from your markdown documentation. | | `deptrac` | [Deptrac](https://github.com/qossmic/deptrac): Deptrac is a static code analysis tool for PHP that helps you communicate, visualize and enforce architectural decisions in your projects. | diff --git a/bin/co-phpunit b/bin/co-phpunit new file mode 100755 index 0000000..c74f5c3 --- /dev/null +++ b/bin/co-phpunit @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +phpctl co-phpunit $@ diff --git a/rootfs/usr/local/bin/install-tools b/rootfs/usr/local/bin/install-tools index 2f24e24..324d0ba 100755 --- a/rootfs/usr/local/bin/install-tools +++ b/rootfs/usr/local/bin/install-tools @@ -10,6 +10,13 @@ box() { chmod a+x /usr/local/bin/box } +co_phpunit() { + local version="3.1.3" + echo "Installing co-phpunit $version" + wget -q "https://raw.githubusercontent.com/hyperf/testing/v$version/co-phpunit" -O /usr/local/bin/co-phpunit + chmod a+x /usr/local/bin/co-phpunit +} + composer() { local version="993f9fec74930f32f7015e71543243bf6d9b9e93" echo "Installing Composer $version" @@ -123,6 +130,7 @@ watchr() { install() { box + co_phpunit composer composer_require_checker couscous diff --git a/src/help.sh b/src/help.sh index e55ddc2..0c63e4c 100644 --- a/src/help.sh +++ b/src/help.sh @@ -34,6 +34,7 @@ help() { echo -e "" echo -e "033円[0;33mTools:033円[0m" echo -e "033円[0;32m box 033円[0m Runs Box (PHAR builder)" + echo -e "033円[0;32m co-phpunit 033円[0m Runs co-phpunit (Coroutine-aware PHPUnit for Hyperf)" echo -e "033円[0;32m composer-require-checker 033円[0m Runs ComposerRequireChecker" echo -e "033円[0;32m couscous 033円[0m Runs Couscous" echo -e "033円[0;32m deptrac 033円[0m Runs Deptrac" diff --git a/src/tools.sh b/src/tools.sh index b64413e..80dd187 100644 --- a/src/tools.sh +++ b/src/tools.sh @@ -6,6 +6,14 @@ box() { fi; } +co-phpunit() { + if [ -f vendor/bin/co-phpunit ]; then + run -- vendor/bin/co-phpunit ${@} + else + run -- co-phpunit ${@} + fi; +} + composer-require-checker() { run -- composer-require-checker ${@} } diff --git a/tests/tools_test.sh b/tests/tools_test.sh index adad98a..f3bc3db 100644 --- a/tests/tools_test.sh +++ b/tests/tools_test.sh @@ -2,6 +2,10 @@ function test_box() { assert_matches "Box version 4\." "$(./bin/phpctl box --version)" } +function test_co_phpunit() { + assert_contains "Swoole\Coroutine\run" "$(./bin/phpctl sh cat /usr/local/bin/co-phpunit)" +} + function test_composer_require_checker() { assert_matches "ComposerRequireChecker 4\." "$(./bin/phpctl composer-require-checker --version)" } From 694ba457ec324a71ac991acbd347a585ddc7a89b Mon Sep 17 00:00:00 2001 From: leocavalcante Date: 2024年3月12日 15:37:36 -0300 Subject: [PATCH 057/130] fix(bin): Permissions --- bin/couscous | 0 bin/deptrac | 0 bin/phpcbf | 0 bin/phpcs | 0 4 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 bin/couscous mode change 100644 => 100755 bin/deptrac mode change 100644 => 100755 bin/phpcbf mode change 100644 => 100755 bin/phpcs diff --git a/bin/couscous b/bin/couscous old mode 100644 new mode 100755 diff --git a/bin/deptrac b/bin/deptrac old mode 100644 new mode 100755 diff --git a/bin/phpcbf b/bin/phpcbf old mode 100644 new mode 100755 diff --git a/bin/phpcs b/bin/phpcs old mode 100644 new mode 100755 From b7d7cdac8c35083b72bb0329d7f8da62b4c93aa1 Mon Sep 17 00:00:00 2001 From: leocavalcante Date: 2024年3月12日 18:34:38 -0300 Subject: [PATCH 058/130] chore(docs): Update --- docs/_config.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/_config.yml b/docs/_config.yml index 679c14b..f6a150b 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -1,4 +1,6 @@ +title: phpctl +description: Frictionless PHP Development +remote_theme: just-the-docs/just-the-docs +url: https://phpctl.dev plugins: - jekyll-remote-theme - -remote_theme: just-the-docs/just-the-docs From a55a55af70be144607fbe623db6a44617078723b Mon Sep 17 00:00:00 2001 From: leocavalcante Date: 2024年3月12日 18:50:44 -0300 Subject: [PATCH 059/130] chore(docs): Update --- docs/README.md | 34 ++++++++++++++++++++++++++++++++++ docs/_config.yml | 25 +++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/docs/README.md b/docs/README.md index 3c2b0ec..544cf3c 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,5 +1,8 @@ # Frictionless PHP Development +[Get started now](#getting-started){: .btn .btn-primary .fs-5 .mb-4 .mb-md-0 .mr-2 } +[View it on GitHub](https://github.com/opencodeco/phpctl){: .btn .fs-5 .mb-4 .mb-md-0 } + Seamlessly run and switch between different versions of PHP, with different installed extensions, thanks to the power of containers. Take the advantage of goodies commands like `phpctl create` to start a new project, `phpctl repl` to start a REPL, `phpctl init` to initialize a new configuration file **and a lot more**. @@ -12,3 +15,34 @@ Take the advantage of goodies commands like `phpctl create` to start a new proje wget -q https://phpctl.dev/phpctl-installer.sh && \ bash phpctl-installer.sh && rm phpctl-installer.sh ``` + +**That is it!** Now you have `phpctl` available in your system. + +### Usage + +Simple as calling any other command in your terminal: + +```shell +phpctl [options] +``` + +You will also have aliases for the most common commands available without the `phpctl` prefix, like: +- `php` +- `composer` +- `phpunit` +- `php-cs-fixer` +- etc + +So you can use them as you would normally do: + +```shell +php -v # same as `phpctl php -v` +``` + +Or + +```shell +composer --version # same as `phpctl composer --version` +``` + +**Have fun!** Feel free to open any issues or PRs. \ No newline at end of file diff --git a/docs/_config.yml b/docs/_config.yml index f6a150b..08342a2 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -2,5 +2,30 @@ title: phpctl description: Frictionless PHP Development remote_theme: just-the-docs/just-the-docs url: https://phpctl.dev +repository: https://github.com/opencodeco/phpctl +permalink: pretty + +aux_links: + phpctl on GitHub: + - https://github.com/opencodeco/phpctl + +nav_external_links: + - title: phpctl on GitHub + url: https://github.com/opencodeco/phpctl + + +back_to_top: true +back_to_top_text: "Back to top" + +gh_edit_link: true +gh_edit_link_text: Edit this page on GitHub +gh_edit_repository: https://github.com/opencodeco/phpctl +gh_edit_branch: main +gh_edit_source: docs +gh_edit_view_mode: tree + plugins: - jekyll-remote-theme + - jekyll-seo-tag + - jekyll-github-metadata + - jekyll-include-cache \ No newline at end of file From 888a70605282136d1da0fc442a2489d7df5531a4 Mon Sep 17 00:00:00 2001 From: leocavalcante Date: 2024年3月12日 19:16:05 -0300 Subject: [PATCH 060/130] chore(docs): Moving to a documentation page --- README.md | 233 ++------------------------------------------- docs/README.md | 21 ++++ docs/commands.md | 55 +++++++++++ docs/extensions.md | 54 +++++++++++ docs/phpctlini.md | 10 ++ docs/phpctlrc.md | 46 +++++++++ docs/why.md | 4 + 7 files changed, 197 insertions(+), 226 deletions(-) create mode 100644 docs/commands.md create mode 100644 docs/extensions.md create mode 100644 docs/phpctlini.md create mode 100644 docs/phpctlrc.md create mode 100644 docs/why.md diff --git a/README.md b/README.md index 3998d80..07fb9e8 100644 --- a/README.md +++ b/README.md @@ -15,237 +15,18 @@ -## Introduction +## Frictionless PHP Development -**Frictionless PHP Development!** Seamlessly run and switch between different versions of PHP, with different installed extensions, thanks to the power of containers. +Seamlessly run and switch between different versions of PHP, with different installed extensions, thanks to the power of containers. Take the advantage of goodie commands like `phpctl create` to start a new project, `phpctl repl` to start a REPL, `phpctl init` to initialize a new configuration file **and a lot more**. ## Getting started -> [!TIP] -> Pro-tip: use it with [`stack`](https://github.com/opencodeco/stack) to spin up infrastructure components like MySQL, Redis, RabbitMQ etc. - -### Requirements -- Bash -- Git -- Docker - -### Install -You can install with default installer script for a system-wide (at `/usr/local/bin`), run: -```shell -wget -q https://phpctl.dev/phpctl-installer.sh && \ -bash phpctl-installer.sh && rm phpctl-installer.sh -``` - -> [!TIP] -> You can also pass an argument to install at a custom location (e.g. `~/bin`), but you have to make sure that folder is in your `$PATH` variable. -> ```shell -> bash phpctl-installer.sh ~/bin -> ``` - -#### Homebrew -```shell -brew install opencodeco/phpctl/phpctl -``` - -Or add the `oppencodeco` tap with `brew tap opencodeco/phpctl` and then `brew install phpctl` - -#### Update -You can re-run the installer or use the `self-update` command: -```shell -phpctl self-update -``` - -For those using Homebrew `brew upgrade opencodeco/phpctl/phpctl` or when run `brew update` - -## Usage -Then you can use `phpctl` or `pctl` with a subcommand: -```shell -phpctl [arguments] -``` - -For example -```shell -phpctl php -m # To show built-in modules -``` -Or -```shell -phpctl sh echo 'Hello, World!' # To run arbitrary sh commands inside the container -``` - -## Command list - -### Developing -| Command | Description | -|-----------------------------|---------------------------------------------------------------------------------------------| -| `php` | **Runs PHP commands** (`phpctl php -v` or `phpctl php -m`). | -| `composer` | Runs Composer commands (`phpctl composer install` or `pctl composer validate`). | -| `server [port] [directory]` | Runs PHP's built-in web-server (default port is `80` and default directory is current `.`). | -| `sh [commands]` | Starts an interactive Shell session or runs `sh` commands. | -| `repl` | Starts a PHP REPL session (powered by [PsySH](https://psysh.org/)). | -| `bundle` | Bundles a project into an image and ships it as a single binary file. | - -### Tools -| Command | Description | -|----------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `box` | [Box](https://github.com/box-project/box): fast, zero config application bundler with PHARs. | -| `co-phpunit` | [co-phpunit](https://github.com/hyperf/testing) is a Coroutine-aware PHPUnit for testing Hyperf projects. | -| `composer-require-checker` | [ComposerRequireChecker](https://github.com/maglnet/ComposerRequireChecker): A CLI tool to analyze composer dependencies and verify that no unknown symbols are used in the sources of a package. | -| `couscous` | [Couscous](https://github.com/CouscousPHP/Couscous): Couscous generates a GitHub pages website from your markdown documentation. | -| `deptrac` | [Deptrac](https://github.com/qossmic/deptrac): Deptrac is a static code analysis tool for PHP that helps you communicate, visualize and enforce architectural decisions in your projects. | -| `exakat` | [Exakat](https://www.exakat.io) is a real time customizable static analyzer engine that analyse and fix code. | -| `frankenphp` | [FrankenPHP](https://frankenphp.dev): the Modern PHP App Server, written in Go. | -| `infection` | [Infection](https://infection.github.io) is a Mutation Testing Framework. | -| `pest` | [Pest](https://pestphp.com) is a testing framework with a focus on simplicity. | -| `php-cs-fixer` | [PHP Coding Standards Fixer (PHP CS Fixer)](https://cs.symfony.com/) fixes your code to follow standards. | -| `phpcbf` | [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) is an essential development tool that ensures your code remains clean and consistent. | -| `phpcs` | [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) is an essential development tool that ensures your code remains clean and consistent. | -| `phpmd` | [PHP Mess Detector](https://phpmd.org/) looks for several potential problems within your source code. | -| `phpstan` | [PHPStan](https://phpstan.org/) finds bugs in your code without writing tests. It's open-source and free. | -| `phpunit` | [PHPUnit](https://phpunit.de) is a programmer-oriented testing framework for PHP. | -| `pint` | [Pint](https://github.com/laravel/pint) is an opinionated PHP code style fixer for minimalists. | -| `rector` | [Rector](https://getrector.com) is a tool that you can run on any project to get an instant upgrade or automated refactoring. | -| `watchr` | [watchr](https://github.com/flavioheleno/watchr): command-line utility to explore and validate domain names and certificates. | - -### Scaffolders -| Command | Description | -|----------------------------|---------------------------------------------------------------| -| `create [framework] [dir]` | Creates a new project using the given framework (or package). | -| `init [skeleton]` | Initializes a skeleton configuration. | - -#### Skeletons -- `phpunit` -- `php-cs-fixer` -- `phpstan` -- `infection` -- `box` - -### Helpers -| Command | Description | -|-----------------|-------------------------------------------------------------| -| `help` or `man` | Displays a help message. | -| `self-update` | Updates `phpctl` iself. | -| `doctor` | Inspects the current `PHP_VERSION` and `PHPCTL_IMAGE`. | -| `build` | Builds the current `Dockerfile` (useful for custom images). | -| `images` | Shows local `phpctl` images. | - -## The `.phpctlrc` file -You can also add a `.phpctlrc` file at project's root directory with some overrides like: - -### Environment variables -| Variable | Description | -|----------------|-----------------------------------| -| `PHP_VERSION` | Values can be `82` and `83` | -| `PHPCTL_IMAGE` | Use to name your own custom image | - -For example: -```shell -PHP_VERSION=83 -``` - -### Docker behaviour - -#### Run options - -You can also provide any additional [Docker `run` arguments](https://docs.docker.com/engine/reference/commandline/run/#options) using the `args` variable. - -For example, suppose you want to bind the `9501` port from the running `phpctl` container to your host, -you can add the following to your `.phpctlrc` file: -```shell -args=(-p 9501:9501) -``` - -#### Build options - -You can also provide [build options](https://docs.docker.com/engine/reference/commandline/build/) to the build command using the `build` variable: -```shell -build=(--build-arg APP_ENV=dev --label phprocks) -``` - -### Podman - -You can use Podman instead of Docker by setting the `PHPCTL_RUNTIME` variable to `podman` in your environment variables or at `.phpctlrc` file. -```shell -PHPCTL_RUNTIME=podman phpctl php -v -``` - -### Host user - -By default, `phpctl` creates an user considering host user. You can change from `root` to host user through `PHPCTL_USER` variable. -```shell -PHPCTL_USER=your_user phpctl sh whoami -``` - -## The `phpctl.ini` file -You can also add a `phpctl.ini` file at project's root directory to set any [`php.ini` directive](https://www.php.net/manual/en/ini.list.php). -```ini -memory_limit = 1337M -``` - -```shell -$ phpctl php -i | grep memory_limit -memory_limit => 1337M => 1337M -``` - -## Modules -
-For the default Docker image we have the following modules installed (click to expand). -
-[PHP Modules]
-Core
-ctype
-curl
-date
-decimal
-ds
-dom
-fileinfo
-filter
-hash
-iconv
-igbinary
-json
-libxml
-mbstring
-mongodb
-msgpack
-mysqlnd
-openssl
-pcntl
-pcov
-pcre
-PDO
-pdo_mysql
-Phar
-posix
-random
-rdkafka
-readline
-redis
-Reflection
-session
-SimpleXML
-sockets
-sodium
-SPL
-sqlite3
-standard
-swoole
-tokenizer
-xml
-xmlreader
-xmlwriter
-zip
-zlib
-
-
- -You can always use your custom image with the `PHPCTL_IMAGE` variable, but feel free to ask for more essential extensions in the issues. - -## Why it exists? -> [!TIP] -> After some years struggling with different PHP distributions into different operating systems, dealing with different PHP versions and sets of extensions, -> I came out with `phpctl` to use the power of containers to seamlessly run PHP :elephant: for developement environments. +- [Installation](https://phpctl.dev/#installation) +- [Usage](https://phpctl.dev/#usage) +- [Available commands](https://phpctl.dev/commands) +- [Available extensions](https://phpctl.dev/extensions) +- [Why it exists?](https://phpctl.dev/why) ## Contributing Click here to read the [contributing guidelines](CONTRIBUTING.md). diff --git a/docs/README.md b/docs/README.md index 544cf3c..6a34baf 100644 --- a/docs/README.md +++ b/docs/README.md @@ -18,6 +18,27 @@ bash phpctl-installer.sh && rm phpctl-installer.sh **That is it!** Now you have `phpctl` available in your system. +#### Custom installation +You can also pass an argument to install at a custom location (e.g. `~/bin`), but you have to make sure that folder is in your `$PATH` variable. +```shell +bash phpctl-installer.sh ~/bin +``` + +#### Homebrew +```shell +brew install opencodeco/phpctl/phpctl +``` + +Or add the `oppencodeco` tap with `brew tap opencodeco/phpctl` and then `brew install phpctl`. + +### Update +You can re-run the installer or use the `self-update` command: +```shell +phpctl self-update +``` + +For those using Homebrew `brew upgrade opencodeco/phpctl/phpctl` or when run `brew update`. + ### Usage Simple as calling any other command in your terminal: diff --git a/docs/commands.md b/docs/commands.md new file mode 100644 index 0000000..7b7a4c9 --- /dev/null +++ b/docs/commands.md @@ -0,0 +1,55 @@ +## Command list + +### Developing +| Command | Description | +|-----------------------------|---------------------------------------------------------------------------------------------| +| `php` | **Runs PHP commands** (`phpctl php -v` or `phpctl php -m`). | +| `composer` | Runs Composer commands (`phpctl composer install` or `pctl composer validate`). | +| `server [port] [directory]` | Runs PHP's built-in web-server (default port is `80` and default directory is current `.`). | +| `sh [commands]` | Starts an interactive Shell session or runs `sh` commands. | +| `repl` | Starts a PHP REPL session (powered by [PsySH](https://psysh.org/)). | +| `bundle` | Bundles a project into an image and ships it as a single binary file. | + +### Tools +| Command | Description | +|----------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `box` | [Box](https://github.com/box-project/box): fast, zero config application bundler with PHARs. | +| `co-phpunit` | [co-phpunit](https://github.com/hyperf/testing) is a Coroutine-aware PHPUnit for testing Hyperf projects. | +| `composer-require-checker` | [ComposerRequireChecker](https://github.com/maglnet/ComposerRequireChecker): A CLI tool to analyze composer dependencies and verify that no unknown symbols are used in the sources of a package. | +| `couscous` | [Couscous](https://github.com/CouscousPHP/Couscous): Couscous generates a GitHub pages website from your markdown documentation. | +| `deptrac` | [Deptrac](https://github.com/qossmic/deptrac): Deptrac is a static code analysis tool for PHP that helps you communicate, visualize and enforce architectural decisions in your projects. | +| `exakat` | [Exakat](https://www.exakat.io) is a real time customizable static analyzer engine that analyse and fix code. | +| `frankenphp` | [FrankenPHP](https://frankenphp.dev): the Modern PHP App Server, written in Go. | +| `infection` | [Infection](https://infection.github.io) is a Mutation Testing Framework. | +| `pest` | [Pest](https://pestphp.com) is a testing framework with a focus on simplicity. | +| `php-cs-fixer` | [PHP Coding Standards Fixer (PHP CS Fixer)](https://cs.symfony.com/) fixes your code to follow standards. | +| `phpcbf` | [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) is an essential development tool that ensures your code remains clean and consistent. | +| `phpcs` | [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) is an essential development tool that ensures your code remains clean and consistent. | +| `phpmd` | [PHP Mess Detector](https://phpmd.org/) looks for several potential problems within your source code. | +| `phpstan` | [PHPStan](https://phpstan.org/) finds bugs in your code without writing tests. It's open-source and free. | +| `phpunit` | [PHPUnit](https://phpunit.de) is a programmer-oriented testing framework for PHP. | +| `pint` | [Pint](https://github.com/laravel/pint) is an opinionated PHP code style fixer for minimalists. | +| `rector` | [Rector](https://getrector.com) is a tool that you can run on any project to get an instant upgrade or automated refactoring. | +| `watchr` | [watchr](https://github.com/flavioheleno/watchr): command-line utility to explore and validate domain names and certificates. | + +### Scaffolders +| Command | Description | +|----------------------------|---------------------------------------------------------------| +| `create [framework] [dir]` | Creates a new project using the given framework (or package). | +| `init [skeleton]` | Initializes a skeleton configuration. | + +#### Skeletons +- `phpunit` +- `php-cs-fixer` +- `phpstan` +- `infection` +- `box` + +### Helpers +| Command | Description | +|-----------------|-------------------------------------------------------------| +| `help` or `man` | Displays a help message. | +| `self-update` | Updates `phpctl` iself. | +| `doctor` | Inspects the current `PHP_VERSION` and `PHPCTL_IMAGE`. | +| `build` | Builds the current `Dockerfile` (useful for custom images). | +| `images` | Shows local `phpctl` images. | diff --git a/docs/extensions.md b/docs/extensions.md new file mode 100644 index 0000000..aa34f62 --- /dev/null +++ b/docs/extensions.md @@ -0,0 +1,54 @@ +## Modules +
+For the default Docker image we have the following modules installed (click to expand). +
+[PHP Modules]
+Core
+ctype
+curl
+date
+decimal
+ds
+dom
+fileinfo
+filter
+hash
+iconv
+igbinary
+json
+libxml
+mbstring
+mongodb
+msgpack
+mysqlnd
+openssl
+pcntl
+pcov
+pcre
+PDO
+pdo_mysql
+Phar
+posix
+random
+rdkafka
+readline
+redis
+Reflection
+session
+SimpleXML
+sockets
+sodium
+SPL
+sqlite3
+standard
+swoole
+tokenizer
+xml
+xmlreader
+xmlwriter
+zip
+zlib
+
+
+ +You can always use your custom image with the `PHPCTL_IMAGE` variable, but feel free to ask for more essential extensions in the issues. diff --git a/docs/phpctlini.md b/docs/phpctlini.md new file mode 100644 index 0000000..4da3edb --- /dev/null +++ b/docs/phpctlini.md @@ -0,0 +1,10 @@ +## The `phpctl.ini` file +You can also add a `phpctl.ini` file at project's root directory to set any [`php.ini` directive](https://www.php.net/manual/en/ini.list.php). +```ini +memory_limit = 1337M +``` + +```shell +$ phpctl php -i | grep memory_limit +memory_limit => 1337M => 1337M +``` diff --git a/docs/phpctlrc.md b/docs/phpctlrc.md new file mode 100644 index 0000000..636e143 --- /dev/null +++ b/docs/phpctlrc.md @@ -0,0 +1,46 @@ +## The `.phpctlrc` file +You can also add a `.phpctlrc` file at project's root directory with some overrides like: + +### Environment variables +| Variable | Description | +|----------------|-----------------------------------| +| `PHP_VERSION` | Values can be `82` and `83` | +| `PHPCTL_IMAGE` | Use to name your own custom image | + +For example: +```shell +PHP_VERSION=83 +``` + +### Docker behaviour + +#### Run options + +You can also provide any additional [Docker `run` arguments](https://docs.docker.com/engine/reference/commandline/run/#options) using the `args` variable. + +For example, suppose you want to bind the `9501` port from the running `phpctl` container to your host, +you can add the following to your `.phpctlrc` file: +```shell +args=(-p 9501:9501) +``` + +#### Build options + +You can also provide [build options](https://docs.docker.com/engine/reference/commandline/build/) to the build command using the `build` variable: +```shell +build=(--build-arg APP_ENV=dev --label phprocks) +``` + +### Podman + +You can use Podman instead of Docker by setting the `PHPCTL_RUNTIME` variable to `podman` in your environment variables or at `.phpctlrc` file. +```shell +PHPCTL_RUNTIME=podman phpctl php -v +``` + +### Host user + +By default, `phpctl` creates an user considering host user. You can change from `root` to host user through `PHPCTL_USER` variable. +```shell +PHPCTL_USER=your_user phpctl sh whoami +``` diff --git a/docs/why.md b/docs/why.md new file mode 100644 index 0000000..16c70f7 --- /dev/null +++ b/docs/why.md @@ -0,0 +1,4 @@ +## Why it exists? +> [!TIP] +> After some years struggling with different PHP distributions into different operating systems, dealing with different PHP versions and sets of extensions, +> I came out with `phpctl` to use the power of containers to seamlessly run PHP :elephant: for developement environments. From 20b142fd24a16acb82a24186fabdfc9230f4d378 Mon Sep 17 00:00:00 2001 From: leocavalcante Date: 2024年3月12日 19:24:49 -0300 Subject: [PATCH 061/130] chore(docs): Nav order --- docs/README.md | 4 ++++ docs/commands.md | 16 ++++++++++------ docs/extensions.md | 9 ++++++--- docs/phpctlini.md | 6 +++++- docs/phpctlrc.md | 18 +++++++++++------- docs/why.md | 13 +++++++++---- 6 files changed, 45 insertions(+), 21 deletions(-) diff --git a/docs/README.md b/docs/README.md index 6a34baf..d0cd49b 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,3 +1,7 @@ +--- +nav_order: 1 +--- + # Frictionless PHP Development [Get started now](#getting-started){: .btn .btn-primary .fs-5 .mb-4 .mb-md-0 .mr-2 } diff --git a/docs/commands.md b/docs/commands.md index 7b7a4c9..8465d99 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -1,6 +1,10 @@ -## Command list +--- +nav_order: 2 +--- -### Developing +# Available commands + +## Developing | Command | Description | |-----------------------------|---------------------------------------------------------------------------------------------| | `php` | **Runs PHP commands** (`phpctl php -v` or `phpctl php -m`). | @@ -10,7 +14,7 @@ | `repl` | Starts a PHP REPL session (powered by [PsySH](https://psysh.org/)). | | `bundle` | Bundles a project into an image and ships it as a single binary file. | -### Tools +## Tools | Command | Description | |----------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `box` | [Box](https://github.com/box-project/box): fast, zero config application bundler with PHARs. | @@ -32,20 +36,20 @@ | `rector` | [Rector](https://getrector.com) is a tool that you can run on any project to get an instant upgrade or automated refactoring. | | `watchr` | [watchr](https://github.com/flavioheleno/watchr): command-line utility to explore and validate domain names and certificates. | -### Scaffolders +## Scaffolders | Command | Description | |----------------------------|---------------------------------------------------------------| | `create [framework] [dir]` | Creates a new project using the given framework (or package). | | `init [skeleton]` | Initializes a skeleton configuration. | -#### Skeletons +### Skeletons - `phpunit` - `php-cs-fixer` - `phpstan` - `infection` - `box` -### Helpers +## Helpers | Command | Description | |-----------------|-------------------------------------------------------------| | `help` or `man` | Displays a help message. | diff --git a/docs/extensions.md b/docs/extensions.md index aa34f62..fb73ba5 100644 --- a/docs/extensions.md +++ b/docs/extensions.md @@ -1,15 +1,18 @@ -## Modules +--- +nav_order: 5 +--- + +# Available extensions
For the default Docker image we have the following modules installed (click to expand).
-[PHP Modules]
 Core
 ctype
 curl
 date
 decimal
-ds
 dom
+ds
 fileinfo
 filter
 hash
diff --git a/docs/phpctlini.md b/docs/phpctlini.md
index 4da3edb..39d7711 100644
--- a/docs/phpctlini.md
+++ b/docs/phpctlini.md
@@ -1,4 +1,8 @@
-## The `phpctl.ini` file
+---
+nav_order: 4
+---
+
+# The `phpctl.ini` file
 You can also add a `phpctl.ini` file at project's root directory to set any [`php.ini` directive](https://www.php.net/manual/en/ini.list.php).
 ```ini
 memory_limit = 1337M
diff --git a/docs/phpctlrc.md b/docs/phpctlrc.md
index 636e143..5433d0e 100644
--- a/docs/phpctlrc.md
+++ b/docs/phpctlrc.md
@@ -1,7 +1,11 @@
-## The `.phpctlrc` file
+---
+nav_order: 3
+---
+
+# The `.phpctlrc` file
 You can also add a `.phpctlrc` file at project's root directory with some overrides like:
 
-### Environment variables
+## Environment variables
 | Variable | Description |
 |----------------|-----------------------------------|
 | `PHP_VERSION` | Values can be `82` and `83` |
@@ -12,9 +16,9 @@ For example:
 PHP_VERSION=83
 ```
 
-### Docker behaviour
+## Docker behaviour
 
-#### Run options
+### Run options
 
 You can also provide any additional [Docker `run` arguments](https://docs.docker.com/engine/reference/commandline/run/#options) using the `args` variable.
 
@@ -24,21 +28,21 @@ you can add the following to your `.phpctlrc` file:
 args=(-p 9501:9501)
 ```
 
-#### Build options
+### Build options
 
 You can also provide [build options](https://docs.docker.com/engine/reference/commandline/build/) to the build command using the `build` variable:
 ```shell
 build=(--build-arg APP_ENV=dev --label phprocks)
 ```
 
-### Podman
+## Podman
 
 You can use Podman instead of Docker by setting the `PHPCTL_RUNTIME` variable to `podman` in your environment variables or at `.phpctlrc` file.
 ```shell
 PHPCTL_RUNTIME=podman phpctl php -v
 ```
 
-### Host user
+## Host user
 
 By default, `phpctl` creates an user considering host user. You can change from `root` to host user through `PHPCTL_USER` variable.
 ```shell
diff --git a/docs/why.md b/docs/why.md
index 16c70f7..cded6e2 100644
--- a/docs/why.md
+++ b/docs/why.md
@@ -1,4 +1,9 @@
-## Why it exists?
-> [!TIP]
-> After some years struggling with different PHP distributions into different operating systems, dealing with different PHP versions and sets of extensions,
-> I came out with `phpctl` to use the power of containers to seamlessly run PHP :elephant: for developement environments.
+---
+nav_order: 6
+---
+
+# Why it exists?
+
+After some years struggling with different PHP distributions into different operating systems, dealing with different PHP versions and sets of extensions,
+
+I came out with `phpctl` to use the power of containers to seamlessly run PHP :elephant: for developement environments.
From 3ce09ebcb0c5ee570538f5ef0a625978150a9901 Mon Sep 17 00:00:00 2001
From: leocavalcante 
Date: 2024年3月12日 19:30:10 -0300
Subject: [PATCH 062/130] fix(docs): Index and tables
---
 docs/README.md | 1 +
 docs/commands.md | 4 ++++
 docs/phpctlrc.md | 1 +
 3 files changed, 6 insertions(+)
diff --git a/docs/README.md b/docs/README.md
index d0cd49b..90a8085 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -1,5 +1,6 @@
 --- 
 nav_order: 1
+permalink: /
 ---
 
 # Frictionless PHP Development
diff --git a/docs/commands.md b/docs/commands.md
index 8465d99..1f46560 100644
--- a/docs/commands.md
+++ b/docs/commands.md
@@ -5,6 +5,7 @@ nav_order: 2
 # Available commands
 
 ## Developing
+
 | Command | Description |
 |-----------------------------|---------------------------------------------------------------------------------------------|
 | `php` | **Runs PHP commands** (`phpctl php -v` or `phpctl php -m`). |
@@ -15,6 +16,7 @@ nav_order: 2
 | `bundle` | Bundles a project into an image and ships it as a single binary file. |
 
 ## Tools
+
 | Command | Description |
 |----------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
 | `box` | [Box](https://github.com/box-project/box): fast, zero config application bundler with PHARs. |
@@ -37,6 +39,7 @@ nav_order: 2
 | `watchr` | [watchr](https://github.com/flavioheleno/watchr): command-line utility to explore and validate domain names and certificates. |
 
 ## Scaffolders
+
 | Command | Description |
 |----------------------------|---------------------------------------------------------------|
 | `create [framework] [dir]` | Creates a new project using the given framework (or package). |
@@ -50,6 +53,7 @@ nav_order: 2
 - `box`
 
 ## Helpers
+
 | Command | Description |
 |-----------------|-------------------------------------------------------------|
 | `help` or `man` | Displays a help message. |
diff --git a/docs/phpctlrc.md b/docs/phpctlrc.md
index 5433d0e..eeb0d98 100644
--- a/docs/phpctlrc.md
+++ b/docs/phpctlrc.md
@@ -6,6 +6,7 @@ nav_order: 3
 You can also add a `.phpctlrc` file at project's root directory with some overrides like:
 
 ## Environment variables
+
 | Variable | Description |
 |----------------|-----------------------------------|
 | `PHP_VERSION` | Values can be `82` and `83` |
From 9c4d0a7aca32295f697668c4a4293e3a4ffbfef7 Mon Sep 17 00:00:00 2001
From: leocavalcante 
Date: 2024年3月12日 19:36:22 -0300
Subject: [PATCH 063/130] fix(docs): Index, tables and typo
---
 docs/commands.md | 78 ++++++++++++++++++------------------
 docs/{README.md => index.md} | 1 +
 docs/phpctlrc.md | 8 ++--
 docs/why.md | 4 +-
 4 files changed, 45 insertions(+), 46 deletions(-)
 rename docs/{README.md => index.md} (98%)
diff --git a/docs/commands.md b/docs/commands.md
index 1f46560..f95efa1 100644
--- a/docs/commands.md
+++ b/docs/commands.md
@@ -6,44 +6,44 @@ nav_order: 2
 
 ## Developing
 
-| Command | Description |
-|-----------------------------|---------------------------------------------------------------------------------------------|
-| `php` | **Runs PHP commands** (`phpctl php -v` or `phpctl php -m`). |
-| `composer` | Runs Composer commands (`phpctl composer install` or `pctl composer validate`). |
-| `server [port] [directory]` | Runs PHP's built-in web-server (default port is `80` and default directory is current `.`). |
-| `sh [commands]` | Starts an interactive Shell session or runs `sh` commands. |
-| `repl` | Starts a PHP REPL session (powered by [PsySH](https://psysh.org/)). |
-| `bundle` | Bundles a project into an image and ships it as a single binary file. |
+| Command | Description |
+|:-----------------------------|:---------------------------------------------------------------------------------------------|
+| `php` | **Runs PHP commands** (`phpctl php -v` or `phpctl php -m`). |
+| `composer` | Runs Composer commands (`phpctl composer install` or `pctl composer validate`). |
+| `server [port] [directory]` | Runs PHP's built-in web-server (default port is `80` and default directory is current `.`). |
+| `sh [commands]` | Starts an interactive Shell session or runs `sh` commands. |
+| `repl` | Starts a PHP REPL session (powered by [PsySH](https://psysh.org/)). |
+| `bundle` | Bundles a project into an image and ships it as a single binary file. |
 
 ## Tools
 
-| Command | Description |
-|----------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| `box` | [Box](https://github.com/box-project/box): fast, zero config application bundler with PHARs. |
-| `co-phpunit` | [co-phpunit](https://github.com/hyperf/testing) is a Coroutine-aware PHPUnit for testing Hyperf projects. |
-| `composer-require-checker` | [ComposerRequireChecker](https://github.com/maglnet/ComposerRequireChecker): A CLI tool to analyze composer dependencies and verify that no unknown symbols are used in the sources of a package. |
-| `couscous` | [Couscous](https://github.com/CouscousPHP/Couscous): Couscous generates a GitHub pages website from your markdown documentation. |
-| `deptrac` | [Deptrac](https://github.com/qossmic/deptrac): Deptrac is a static code analysis tool for PHP that helps you communicate, visualize and enforce architectural decisions in your projects. |
-| `exakat` | [Exakat](https://www.exakat.io) is a real time customizable static analyzer engine that analyse and fix code. |
-| `frankenphp` | [FrankenPHP](https://frankenphp.dev): the Modern PHP App Server, written in Go. |
-| `infection` | [Infection](https://infection.github.io) is a Mutation Testing Framework. |
-| `pest` | [Pest](https://pestphp.com) is a testing framework with a focus on simplicity. |
-| `php-cs-fixer` | [PHP Coding Standards Fixer (PHP CS Fixer)](https://cs.symfony.com/) fixes your code to follow standards. |
-| `phpcbf` | [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) is an essential development tool that ensures your code remains clean and consistent. |
-| `phpcs` | [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) is an essential development tool that ensures your code remains clean and consistent. |
-| `phpmd` | [PHP Mess Detector](https://phpmd.org/) looks for several potential problems within your source code. |
-| `phpstan` | [PHPStan](https://phpstan.org/) finds bugs in your code without writing tests. It's open-source and free. |
-| `phpunit` | [PHPUnit](https://phpunit.de) is a programmer-oriented testing framework for PHP. |
-| `pint` | [Pint](https://github.com/laravel/pint) is an opinionated PHP code style fixer for minimalists. |
-| `rector` | [Rector](https://getrector.com) is a tool that you can run on any project to get an instant upgrade or automated refactoring. |
-| `watchr` | [watchr](https://github.com/flavioheleno/watchr): command-line utility to explore and validate domain names and certificates. |
+| Command | Description |
+|:----------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| `box` | [Box](https://github.com/box-project/box): fast, zero config application bundler with PHARs. |
+| `co-phpunit` | [co-phpunit](https://github.com/hyperf/testing) is a Coroutine-aware PHPUnit for testing Hyperf projects. |
+| `composer-require-checker` | [ComposerRequireChecker](https://github.com/maglnet/ComposerRequireChecker): A CLI tool to analyze composer dependencies and verify that no unknown symbols are used in the sources of a package. |
+| `couscous` | [Couscous](https://github.com/CouscousPHP/Couscous): Couscous generates a GitHub pages website from your markdown documentation. |
+| `deptrac` | [Deptrac](https://github.com/qossmic/deptrac): Deptrac is a static code analysis tool for PHP that helps you communicate, visualize and enforce architectural decisions in your projects. |
+| `exakat` | [Exakat](https://www.exakat.io) is a real time customizable static analyzer engine that analyse and fix code. |
+| `frankenphp` | [FrankenPHP](https://frankenphp.dev): the Modern PHP App Server, written in Go. |
+| `infection` | [Infection](https://infection.github.io) is a Mutation Testing Framework. |
+| `pest` | [Pest](https://pestphp.com) is a testing framework with a focus on simplicity. |
+| `php-cs-fixer` | [PHP Coding Standards Fixer (PHP CS Fixer)](https://cs.symfony.com/) fixes your code to follow standards. |
+| `phpcbf` | [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) is an essential development tool that ensures your code remains clean and consistent. |
+| `phpcs` | [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) is an essential development tool that ensures your code remains clean and consistent. |
+| `phpmd` | [PHP Mess Detector](https://phpmd.org/) looks for several potential problems within your source code. |
+| `phpstan` | [PHPStan](https://phpstan.org/) finds bugs in your code without writing tests. It's open-source and free. |
+| `phpunit` | [PHPUnit](https://phpunit.de) is a programmer-oriented testing framework for PHP. |
+| `pint` | [Pint](https://github.com/laravel/pint) is an opinionated PHP code style fixer for minimalists. |
+| `rector` | [Rector](https://getrector.com) is a tool that you can run on any project to get an instant upgrade or automated refactoring. |
+| `watchr` | [watchr](https://github.com/flavioheleno/watchr): command-line utility to explore and validate domain names and certificates. |
 
 ## Scaffolders
 
-| Command | Description |
-|----------------------------|---------------------------------------------------------------|
-| `create [framework] [dir]` | Creates a new project using the given framework (or package). |
-| `init [skeleton]` | Initializes a skeleton configuration. |
+| Command | Description |
+|:----------------------------|:---------------------------------------------------------------|
+| `create [framework] [dir]` | Creates a new project using the given framework (or package). |
+| `init [skeleton]` | Initializes a skeleton configuration. |
 
 ### Skeletons
 - `phpunit`
@@ -54,10 +54,10 @@ nav_order: 2
 
 ## Helpers
 
-| Command | Description |
-|-----------------|-------------------------------------------------------------|
-| `help` or `man` | Displays a help message. |
-| `self-update` | Updates `phpctl` iself. |
-| `doctor` | Inspects the current `PHP_VERSION` and `PHPCTL_IMAGE`. |
-| `build` | Builds the current `Dockerfile` (useful for custom images). |
-| `images` | Shows local `phpctl` images. |
+| Command | Description |
+|:-----------------|:-------------------------------------------------------------|
+| `help` or `man` | Displays a help message. |
+| `self-update` | Updates `phpctl` iself. |
+| `doctor` | Inspects the current `PHP_VERSION` and `PHPCTL_IMAGE`. |
+| `build` | Builds the current `Dockerfile` (useful for custom images). |
+| `images` | Shows local `phpctl` images. |
diff --git a/docs/README.md b/docs/index.md
similarity index 98%
rename from docs/README.md
rename to docs/index.md
index 90a8085..6862f09 100644
--- a/docs/README.md
+++ b/docs/index.md
@@ -1,4 +1,5 @@
 --- 
+title: Frictionless PHP Development
 nav_order: 1
 permalink: /
 ---
diff --git a/docs/phpctlrc.md b/docs/phpctlrc.md
index eeb0d98..2f0d9ae 100644
--- a/docs/phpctlrc.md
+++ b/docs/phpctlrc.md
@@ -7,10 +7,10 @@ You can also add a `.phpctlrc` file at project's root directory with some overri
 
 ## Environment variables
 
-| Variable | Description |
-|----------------|-----------------------------------|
-| `PHP_VERSION` | Values can be `82` and `83` |
-| `PHPCTL_IMAGE` | Use to name your own custom image |
+| Variable | Description |
+|:----------------|:-----------------------------------|
+| `PHP_VERSION` | Values can be `82` and `83` |
+| `PHPCTL_IMAGE` | Use to name your own custom image |
 
 For example:
 ```shell
diff --git a/docs/why.md b/docs/why.md
index cded6e2..aa23db3 100644
--- a/docs/why.md
+++ b/docs/why.md
@@ -4,6 +4,4 @@ nav_order: 6
 
 # Why it exists?
 
-After some years struggling with different PHP distributions into different operating systems, dealing with different PHP versions and sets of extensions,
-
-I came out with `phpctl` to use the power of containers to seamlessly run PHP :elephant: for developement environments.
+After some years struggling with different PHP distributions into different operating systems, dealing with different PHP versions and sets of extensions, I came out with `phpctl` to use the power of containers to seamlessly run PHP for development environments.
From 01b9ce7ee97414988fb786ecb588ec2f95f8ad5d Mon Sep 17 00:00:00 2001
From: leocavalcante 
Date: 2024年3月12日 21:12:26 -0300
Subject: [PATCH 064/130] chore(dev): Using GNU/Parallel to speed up
 development
---
 Makefile | 8 ++------
 tests/php_test.sh | 4 +++-
 2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/Makefile b/Makefile
index 1b1a29e..ae485fb 100644
--- a/Makefile
+++ b/Makefile
@@ -3,15 +3,11 @@ default: build
 
 .PHONY: build
 build:
-	@PHP_VERSION=81 phpctl build
-	@PHP_VERSION=82 phpctl build
-	@PHP_VERSION=83 phpctl build
+	@parallel --line-buffer PHP_VERSION={} phpctl build ::: 81 82 83
 
 .PHONY: test
 test:
-	@PHP_VERSION=81 COMPOSER_AUTH= TERM= notty ./lib/bashunit ./tests/
-	@PHP_VERSION=82 COMPOSER_AUTH= TERM= notty ./lib/bashunit ./tests/
-	@PHP_VERSION=83 COMPOSER_AUTH= TERM= notty ./lib/bashunit ./tests/
+	@parallel --line-buffer PHP_VERSION={} COMPOSER_AUTH= TERM= notty ./lib/bashunit ./tests/ ::: 81 82 83
 
 .PHONY: install
 install:
diff --git a/tests/php_test.sh b/tests/php_test.sh
index f2a275b..325f32b 100644
--- a/tests/php_test.sh
+++ b/tests/php_test.sh
@@ -14,5 +14,7 @@ function test_composer() {
 function test_phpctl_ini() {
 echo "memory_limit=1337M"> phpctl.ini
 assert_contains "memory_limit => 1337M => 1337M" "$(./bin/phpctl php -i | grep memory_limit)"
- rm phpctl.ini
+ if [ -f phpctl.ini ]; then
+ rm phpctl.ini
+ fi
 }
From fac5346e6f0d67d33a08ab80b0d3033108535a69 Mon Sep 17 00:00:00 2001
From: leocavalcante 
Date: 2024年3月12日 21:33:59 -0300
Subject: [PATCH 065/130] refactor: Rename install script
---
 docs/install.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100755 docs/install.sh
diff --git a/docs/install.sh b/docs/install.sh
new file mode 100755
index 0000000..1b14c74
--- /dev/null
+++ b/docs/install.sh
@@ -0,0 +1,46 @@
+#!/usr/bin/env bash
+
+INSTALL_DIR=~/.phpctl
+if [ -z "1ドル" ]; then
+ SUDO=sudo
+ SYMLINK_DIR=/usr/local/bin
+else
+ SUDO=""
+ SYMLINK_DIR=1ドル
+fi
+
+echo -e "033円[0;33mInstalling phpctl at 033円[0m$INSTALL_DIR"
+if [ -d "$INSTALL_DIR" ]; then
+ echo "The install directory is not empty. Attempting to remove it..."
+ rm -rI $INSTALL_DIR
+fi
+
+echo -n ""
+git clone --quiet https://github.com/opencodeco/phpctl.git $INSTALL_DIR &
+PID=$!
+while kill -0 $PID 2> /dev/null; do
+ for CHAR in '-' '/' '|' '\'; do
+ printf "\b$CHAR"
+ sleep 0.1
+ done
+done
+printf "\r"
+
+
+if [ -z "1ドル" ]; then
+ echo -n "Sudo will be prompted to symlink the phpctl files."
+else
+ echo -n "Files will be symlinked to ${SYMLINK_DIR}."
+fi
+echo -e -n " 033円[0;32mDo you want to continue? (y/n)033円[0m "
+read -r answer
+if [ "$answer" != "${answer#[Yy]}" ]; then
+ $SUDO ${INSTALL_DIR}/scripts/symlink-bins.sh ${INSTALL_DIR}
+else
+ echo -e "033円[0;31mTo use phpctl globally, link the cloned script to your bin directory, like:033円[0m"
+ echo ""
+ for file in "${INSTALL_DIR}"/bin/*; do
+ bin=$(basename "$file")
+ echo " ${SUDO} ln -sf ${INSTALL_DIR}/bin/$bin ${SYMLINK_DIR}/$bin"
+ done
+fi
From 2881959e5155274fa251aea02341b32edea4bb52 Mon Sep 17 00:00:00 2001
From: leocavalcante 
Date: 2024年3月12日 22:15:55 -0300
Subject: [PATCH 066/130] wip: Not seeing the new install file
---
 docs/_config.yml | 2 --
 1 file changed, 2 deletions(-)
diff --git a/docs/_config.yml b/docs/_config.yml
index 08342a2..1245489 100644
--- a/docs/_config.yml
+++ b/docs/_config.yml
@@ -13,7 +13,6 @@ nav_external_links:
 - title: phpctl on GitHub
 url: https://github.com/opencodeco/phpctl
 
-
 back_to_top: true
 back_to_top_text: "Back to top"
 
@@ -28,4 +27,3 @@ plugins:
 - jekyll-remote-theme
 - jekyll-seo-tag
 - jekyll-github-metadata
- - jekyll-include-cache
\ No newline at end of file
From 6a0c1a535f39b65e6f413714e82b471f3b6f0aa5 Mon Sep 17 00:00:00 2001
From: leocavalcante 
Date: 2024年3月13日 09:04:27 -0300
Subject: [PATCH 067/130] refactor(install): Symlink as default
---
 docs/install.sh | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/docs/install.sh b/docs/install.sh
index 1b14c74..0a536e3 100755
--- a/docs/install.sh
+++ b/docs/install.sh
@@ -12,7 +12,7 @@ fi
 echo -e "033円[0;33mInstalling phpctl at 033円[0m$INSTALL_DIR"
 if [ -d "$INSTALL_DIR" ]; then
 echo "The install directory is not empty. Attempting to remove it..."
- rm -rI $INSTALL_DIR
+ rm -rf $INSTALL_DIR
 fi
 
 echo -n ""
@@ -32,15 +32,15 @@ if [ -z "1ドル" ]; then
 else
 echo -n "Files will be symlinked to ${SYMLINK_DIR}."
 fi
-echo -e -n " 033円[0;32mDo you want to continue? (y/n)033円[0m "
+echo -e -n " 033円[0;32mDo you want to continue? (Y/n)033円[0m "
 read -r answer
-if [ "$answer" != "${answer#[Yy]}" ]; then
- $SUDO ${INSTALL_DIR}/scripts/symlink-bins.sh ${INSTALL_DIR}
-else
+if [ "$answer" != "${answer#[Nn]}" ]; then
 echo -e "033円[0;31mTo use phpctl globally, link the cloned script to your bin directory, like:033円[0m"
 echo ""
 for file in "${INSTALL_DIR}"/bin/*; do
 bin=$(basename "$file")
 echo " ${SUDO} ln -sf ${INSTALL_DIR}/bin/$bin ${SYMLINK_DIR}/$bin"
 done
+else
+ $SUDO ${INSTALL_DIR}/scripts/symlink-bins.sh ${INSTALL_DIR}
 fi
From 7549a513da96347195676cf472087bb6924bf854 Mon Sep 17 00:00:00 2001
From: leocavalcante 
Date: 2024年3月13日 09:37:30 -0300
Subject: [PATCH 068/130] refactor(tests): Installation
---
 tests/install/Makefile | 19 ++-----------------
 tests/install/alpine.Dockerfile | 6 +++---
 tests/install/archlinux.Dockerfile | 6 +++---
 tests/install/build | 4 ++++
 tests/install/docker-entrypoint.sh | 7 +++++++
 tests/install/test | 3 +++
 tests/install/ubuntu.Dockerfile | 6 +++---
 7 files changed, 25 insertions(+), 26 deletions(-)
 create mode 100755 tests/install/build
 create mode 100755 tests/install/docker-entrypoint.sh
 create mode 100755 tests/install/test
diff --git a/tests/install/Makefile b/tests/install/Makefile
index dfaa543..b642b85 100644
--- a/tests/install/Makefile
+++ b/tests/install/Makefile
@@ -1,22 +1,7 @@
-.PHONY: default
-default: build run
-
 .PHONY: build
 build:
-	docker build -t phpctl-${OS}-test -f ${OS}.Dockerfile .
-
-.PHONY: run
-run:
-	docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock phpctl-${OS}-test bash
-
-.PHONY: install
-install:
-	wget -q https://phpctl.dev/phpctl-installer.sh && \
-	bash phpctl-installer.sh && rm phpctl-installer.sh
+	@parallel --line-buffer ./build {} ::: alpine archlinux ubuntu
 
 .PHONY: test
 test:
-	ls -lha /usr/local/bin
-	phpctl doctor
-	php --version
-	composer --version
+	@parallel --line-buffer ./test {} ::: alpine archlinux ubuntu
diff --git a/tests/install/alpine.Dockerfile b/tests/install/alpine.Dockerfile
index 0b45e0b..a5b7144 100644
--- a/tests/install/alpine.Dockerfile
+++ b/tests/install/alpine.Dockerfile
@@ -1,4 +1,4 @@
 FROM alpine
-RUN apk add bash docker git make openssl sudo
-WORKDIR /usr/local/src
-COPY Makefile .
+RUN apk add bash curl docker git make neofetch openssl sudo
+COPY docker-entrypoint.sh /
+ENTRYPOINT ["/docker-entrypoint.sh"]
diff --git a/tests/install/archlinux.Dockerfile b/tests/install/archlinux.Dockerfile
index 61380d5..fbe2c61 100644
--- a/tests/install/archlinux.Dockerfile
+++ b/tests/install/archlinux.Dockerfile
@@ -1,4 +1,4 @@
 FROM archlinux
-RUN pacman -Syu --noconfirm docker make wget sudo git
-WORKDIR /usr/local/src
-COPY Makefile .
+RUN pacman -Syu --noconfirm curl docker git make neofetch sudo
+COPY docker-entrypoint.sh /
+ENTRYPOINT ["/docker-entrypoint.sh"]
diff --git a/tests/install/build b/tests/install/build
new file mode 100755
index 0000000..b403ef9
--- /dev/null
+++ b/tests/install/build
@@ -0,0 +1,4 @@
+#!/usr/bin/env bash
+echo -e "[1ドル] 033円[0;32mBuilding...033円[0m"
+docker build -t "phpctl-1ドル-test" -f "1ドル.Dockerfile" . &> /dev/null
+echo -e "[1ドル] 033円[0;32mDone!033円[0m"
diff --git a/tests/install/docker-entrypoint.sh b/tests/install/docker-entrypoint.sh
new file mode 100755
index 0000000..87af11d
--- /dev/null
+++ b/tests/install/docker-entrypoint.sh
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+neofetch
+/bin/bash -c "$(curl -fsSL https://phpctl.dev/install.sh)"
+echo ""
+notty phpctl doctor
+notty php --version
+notty composer --version
diff --git a/tests/install/test b/tests/install/test
new file mode 100755
index 0000000..127dd2a
--- /dev/null
+++ b/tests/install/test
@@ -0,0 +1,3 @@
+#!/usr/bin/env bash
+echo -e "[1ドル] 033円[0;32mTesting...033円[0m"
+echo -e "$(docker run --rm -v /var/run/docker.sock:/var/run/docker.sock "phpctl-1ドル-test")"
diff --git a/tests/install/ubuntu.Dockerfile b/tests/install/ubuntu.Dockerfile
index a6cb345..2962b97 100644
--- a/tests/install/ubuntu.Dockerfile
+++ b/tests/install/ubuntu.Dockerfile
@@ -1,4 +1,4 @@
 FROM ubuntu
-RUN apt update && apt install -y bash docker.io git make openssl sudo wget
-WORKDIR /usr/local/src
-COPY Makefile .
+RUN apt update && apt install -y bash curl docker.io git make neofetch openssl sudo
+COPY docker-entrypoint.sh /
+ENTRYPOINT ["/docker-entrypoint.sh"]
From 98e3f5ae28d401d06290d8f7e4a2bb38ed982d81 Mon Sep 17 00:00:00 2001
From: leocavalcante 
Date: 2024年3月13日 09:37:42 -0300
Subject: [PATCH 069/130] chore(docs): Installation
---
 README.md | 18 ++++++++++++++--
 docs/index.md | 5 ++---
 docs/phpctl-installer.sh | 46 ----------------------------------------
 3 files changed, 18 insertions(+), 51 deletions(-)
 delete mode 100755 docs/phpctl-installer.sh
diff --git a/README.md b/README.md
index 07fb9e8..117cdf2 100644
--- a/README.md
+++ b/README.md
@@ -20,11 +20,25 @@
 Seamlessly run and switch between different versions of PHP, with different installed extensions, thanks to the power of containers.
 Take the advantage of goodie commands like `phpctl create` to start a new project, `phpctl repl` to start a REPL, `phpctl init` to initialize a new configuration file **and a lot more**.
 
+### Just install
+```shell
+/bin/bash -c "$(curl -fsSL https://phpctl.dev/install.sh)"
+```
+### And that is it!
+Try it out:
+```shell
+phpctl doctor
+php --version
+composer --version
+```
+
 ## Getting started
 
-- [Installation](https://phpctl.dev/#installation)
-- [Usage](https://phpctl.dev/#usage)
+- [Installation guide](https://phpctl.dev/#installation)
+- [How to use](https://phpctl.dev/#usage)
 - [Available commands](https://phpctl.dev/commands)
+- [The `.phpctlrc` file](https://phpctl.dev/phpctlrc)
+- [The `phpctl.ini` file](https://phpctl.dev/phpctlini)
 - [Available extensions](https://phpctl.dev/extensions)
 - [Why it exists?](https://phpctl.dev/why)
 
diff --git a/docs/index.md b/docs/index.md
index 6862f09..aa0c9e8 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -18,8 +18,7 @@ Take the advantage of goodies commands like `phpctl create` to start a new proje
 ### Installation
 
 ```shell
-wget -q https://phpctl.dev/phpctl-installer.sh && \
-bash phpctl-installer.sh && rm phpctl-installer.sh
+/bin/bash -c "$(curl -fsSL https://phpctl.dev/install.sh)"
 ```
 
 **That is it!** Now you have `phpctl` available in your system.
@@ -27,7 +26,7 @@ bash phpctl-installer.sh && rm phpctl-installer.sh
 #### Custom installation
 You can also pass an argument to install at a custom location (e.g. `~/bin`), but you have to make sure that folder is in your `$PATH` variable.
 ```shell
-bash phpctl-installer.sh ~/bin
+/bin/bash -c "$(curl -fsSL https://phpctl.dev/install.sh)" ~/bin
 ```
 
 #### Homebrew
diff --git a/docs/phpctl-installer.sh b/docs/phpctl-installer.sh
deleted file mode 100755
index 1b14c74..0000000
--- a/docs/phpctl-installer.sh
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/usr/bin/env bash
-
-INSTALL_DIR=~/.phpctl
-if [ -z "1ドル" ]; then
- SUDO=sudo
- SYMLINK_DIR=/usr/local/bin
-else
- SUDO=""
- SYMLINK_DIR=1ドル
-fi
-
-echo -e "033円[0;33mInstalling phpctl at 033円[0m$INSTALL_DIR"
-if [ -d "$INSTALL_DIR" ]; then
- echo "The install directory is not empty. Attempting to remove it..."
- rm -rI $INSTALL_DIR
-fi
-
-echo -n ""
-git clone --quiet https://github.com/opencodeco/phpctl.git $INSTALL_DIR &
-PID=$!
-while kill -0 $PID 2> /dev/null; do
- for CHAR in '-' '/' '|' '\'; do
- printf "\b$CHAR"
- sleep 0.1
- done
-done
-printf "\r"
-
-
-if [ -z "1ドル" ]; then
- echo -n "Sudo will be prompted to symlink the phpctl files."
-else
- echo -n "Files will be symlinked to ${SYMLINK_DIR}."
-fi
-echo -e -n " 033円[0;32mDo you want to continue? (y/n)033円[0m "
-read -r answer
-if [ "$answer" != "${answer#[Yy]}" ]; then
- $SUDO ${INSTALL_DIR}/scripts/symlink-bins.sh ${INSTALL_DIR}
-else
- echo -e "033円[0;31mTo use phpctl globally, link the cloned script to your bin directory, like:033円[0m"
- echo ""
- for file in "${INSTALL_DIR}"/bin/*; do
- bin=$(basename "$file")
- echo " ${SUDO} ln -sf ${INSTALL_DIR}/bin/$bin ${SYMLINK_DIR}/$bin"
- done
-fi
From 92ca980ae3b41a0cb84d1965b2e066f2429cc33e Mon Sep 17 00:00:00 2001
From: Leo Cavalcante 
Date: 2024年3月13日 09:47:02 -0300
Subject: [PATCH 070/130] chore(ci): Downgrading Docker login to fix
---
 .github/workflows/docker.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
index 76d963d..77b7f5a 100644
--- a/.github/workflows/docker.yml
+++ b/.github/workflows/docker.yml
@@ -30,7 +30,7 @@ jobs:
 uses: docker/setup-buildx-action@v3
 -
 name: Login to Docker Hub
- uses: docker/login-action@v3
+ uses: docker/login-action@v2
 with:
 username: ${{ secrets.DOCKERHUB_USERNAME }}
 password: ${{ secrets.DOCKERHUB_TOKEN }}
From 38165c5568b29d95e9e778bfe23ed72928f3e9d4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fl=C3=A1vio=20Heleno?= 
Date: 2024年3月15日 09:56:15 -0300
Subject: [PATCH 071/130] feat: Container runtime detection (#38)
---
 bin/phpctl | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/bin/phpctl b/bin/phpctl
index 2c58b6b..a15142e 100755
--- a/bin/phpctl
+++ b/bin/phpctl
@@ -9,9 +9,21 @@ fi
 PHP_VERSION=${PHP_VERSION:-82}
 PHPCTL_IMAGE=${PHPCTL_IMAGE:-opencodeco/phpctl:php$PHP_VERSION}
 PHPCTL_TTY=${PHPCTL_TTY:--it}
-PHPCTL_RUNTIME=${PHPCTL_RUNTIME:-docker}
+PHPCTL_RUNTIME=${PHPCTL_RUNTIME:-detect}
 PHPCTL_USER=${PHPCTL_USER:-root}
 
+if [ "${PHPCTL_RUNTIME}" == "detect" ]; then
+ PHPCTL_RUNTIME=
+ if command -v docker> /dev/null 2>&1; then
+ PHPCTL_RUNTIME=docker
+ elif command -v podman> /dev/null 2>&1; then
+ PHPCTL_RUNTIME=podman
+ else
+ echo "Could not find neither \"docker\" nor \"podman\", aborting"
+ exit 1
+ fi
+fi
+
 for file in "$PHPCTL_DIR"/src/*.sh; do
 # shellcheck source=src/php.sh
 . "$file"
From 000f393d896d0ff67154fcfaf214f73aa19d4b04 Mon Sep 17 00:00:00 2001
From: leocavalcante 
Date: 2024年3月15日 10:05:59 -0300
Subject: [PATCH 072/130] chore(docs): GNU/Parallel note, closes #37
---
 CONTRIBUTING.md | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 4ce75d7..2145d8a 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -6,6 +6,9 @@ Feel free to contribute to this project by submitting a pull request to the `mai
 
 You can use `make` to simplify the development process.
 
+> [!NOTE]
+> Make sure you have [GNU/Parallel](https://www.gnu.org/software/parallel/) installed to speed up processes for each PHP version.
+
 ### Building
 You can build the default image using `make build` or just `make`, the `build` target is the default:
 ```shell
From 20270c5d8b7022dad99134374603f9a6d116326c Mon Sep 17 00:00:00 2001
From: leocavalcante 
Date: 2024年3月15日 17:59:58 -0300
Subject: [PATCH 073/130] feat: Bash
---
 Dockerfile | 1 +
 1 file changed, 1 insertion(+)
diff --git a/Dockerfile b/Dockerfile
index 971c535..a1a2ef6 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -12,6 +12,7 @@ ENV WITHOUT_WATCHR=$WITHOUT_WATCHR
 
 COPY rootfs /
 RUN apk add --update --no-cache \
+ bash \
 git \
 docker-cli \
 php${PHP}-cli \
From 2b4e62d265ba3b05f550b7f21724150e13b705da Mon Sep 17 00:00:00 2001
From: leocavalcante 
Date: 2024年3月15日 18:46:42 -0300
Subject: [PATCH 074/130] feat: Debian version for Dev Containers
---
 Dockerfile | 1 -
 debian.Dockerfile | 19 +++++++++++++++++++
 rootfs/usr/local/bin/install-tools | 2 +-
 3 files changed, 20 insertions(+), 2 deletions(-)
 create mode 100644 debian.Dockerfile
diff --git a/Dockerfile b/Dockerfile
index a1a2ef6..971c535 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -12,7 +12,6 @@ ENV WITHOUT_WATCHR=$WITHOUT_WATCHR
 
 COPY rootfs /
 RUN apk add --update --no-cache \
- bash \
 git \
 docker-cli \
 php${PHP}-cli \
diff --git a/debian.Dockerfile b/debian.Dockerfile
new file mode 100644
index 0000000..0fc1c24
--- /dev/null
+++ b/debian.Dockerfile
@@ -0,0 +1,19 @@
+FROM debian
+
+ARG PHP
+ENV PHP_VERSION=$PHP
+
+ARG WITH_EXAKAT
+ENV WITH_EXAKAT=$WITH_EXAKAT
+
+ARG WITHOUT_WATCHR
+ENV WITHOUT_WATCHR=$WITHOUT_WATCHR
+
+COPY rootfs /
+
+RUN apt update && apt install -y \
+ wget php-cli \
+ && /usr/local/bin/install-tools
+
+ENTRYPOINT [ "/usr/bin/php" ]
+CMD [ "-v" ]
diff --git a/rootfs/usr/local/bin/install-tools b/rootfs/usr/local/bin/install-tools
index 324d0ba..be4ea25 100755
--- a/rootfs/usr/local/bin/install-tools
+++ b/rootfs/usr/local/bin/install-tools
@@ -1,4 +1,4 @@
-#!/usr/bin/env ash
+#!/usr/bin/env sh
 
 box() {
 local version="4.6.1"
From e82776cf927efc5f8002495c49a7ba5ef9ce20bb Mon Sep 17 00:00:00 2001
From: Leo Cavalcante 
Date: 2024年3月15日 22:13:41 +0000
Subject: [PATCH 075/130] chore(dev): Make debian
---
 Makefile | 5 +++++
 1 file changed, 5 insertions(+)
diff --git a/Makefile b/Makefile
index ae485fb..5fed9f6 100644
--- a/Makefile
+++ b/Makefile
@@ -12,3 +12,8 @@ test:
 .PHONY: install
 install:
 	@sudo ./scripts/symlink-bins.sh
+
+.PHONY: debian
+debian:
+	@docker buildx build -t opencodeco/phpctl:php-debian -f debian.Dockerfile .
+	@docker push opencodeco/phpctl:php-debian
From 0e9c68135e4a4f35a4eef66c5cbcb34d21295236 Mon Sep 17 00:00:00 2001
From: Leo Cavalcante 
Date: 2024年3月15日 22:14:14 +0000
Subject: [PATCH 076/130] feat(ext/debian): Unzip and DOM
---
 debian.Dockerfile | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/debian.Dockerfile b/debian.Dockerfile
index 0fc1c24..988822a 100644
--- a/debian.Dockerfile
+++ b/debian.Dockerfile
@@ -10,9 +10,8 @@ ARG WITHOUT_WATCHR
 ENV WITHOUT_WATCHR=$WITHOUT_WATCHR
 
 COPY rootfs /
-
 RUN apt update && apt install -y \
- wget php-cli \
+ unzip wget php-cli php-dom \
 && /usr/local/bin/install-tools
 
 ENTRYPOINT [ "/usr/bin/php" ]
From 127dc2ca8ebf29494f3465b5977499f2ccfdc739 Mon Sep 17 00:00:00 2001
From: Leo Cavalcante 
Date: 2024年3月15日 22:22:10 +0000
Subject: [PATCH 077/130] feat(ext/debian): Multibyte string and MySQL
---
 debian.Dockerfile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/debian.Dockerfile b/debian.Dockerfile
index 988822a..6f94bec 100644
--- a/debian.Dockerfile
+++ b/debian.Dockerfile
@@ -11,7 +11,7 @@ ENV WITHOUT_WATCHR=$WITHOUT_WATCHR
 
 COPY rootfs /
 RUN apt update && apt install -y \
- unzip wget php-cli php-dom \
+ unzip wget php-cli php-dom php-mbstring php-mysql \
 && /usr/local/bin/install-tools
 
 ENTRYPOINT [ "/usr/bin/php" ]
From fc9c10793c87067c6f600c07a0343412b11ce999 Mon Sep 17 00:00:00 2001
From: leocavalcante 
Date: 2024年3月15日 21:30:53 -0300
Subject: [PATCH 078/130] refactor(devcontainers): Using Microsoft's PHP dev
 containers base image
---
 .github/workflows/devcontainers.yml | 35 +++++++++++++++++++++++++++++
 Makefile | 8 +++----
 debian.Dockerfile | 18 ---------------
 devcontainers.Dockerfile | 6 +++++
 4 files changed, 45 insertions(+), 22 deletions(-)
 create mode 100644 .github/workflows/devcontainers.yml
 delete mode 100644 debian.Dockerfile
 create mode 100644 devcontainers.Dockerfile
diff --git a/.github/workflows/devcontainers.yml b/.github/workflows/devcontainers.yml
new file mode 100644
index 0000000..af4223f
--- /dev/null
+++ b/.github/workflows/devcontainers.yml
@@ -0,0 +1,35 @@
+name: Dev containers
+
+on:
+ pull_request:
+ push:
+ branches:
+ - main
+
+jobs:
+ frankenphp:
+ runs-on: ubuntu-latest
+ steps:
+ -
+ name: Checkout
+ uses: actions/checkout@v3
+ -
+ name: Set up QEMU
+ uses: docker/setup-qemu-action@v3
+ -
+ name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+ -
+ name: Login to Docker Hub
+ uses: docker/login-action@v3
+ with:
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+ -
+ name: Build and push
+ uses: docker/build-push-action@v5
+ with:
+ context: .
+ file: devcontainers.Dockerfile
+ push: true
+ tags: opencodeco/phpctl:php83-devcontainers
diff --git a/Makefile b/Makefile
index 5fed9f6..b019973 100644
--- a/Makefile
+++ b/Makefile
@@ -13,7 +13,7 @@ test:
 install:
 	@sudo ./scripts/symlink-bins.sh
 
-.PHONY: debian
-debian:
-	@docker buildx build -t opencodeco/phpctl:php-debian -f debian.Dockerfile .
-	@docker push opencodeco/phpctl:php-debian
+.PHONY: devcontainers
+devcontainers:
+	@docker buildx build -t opencodeco/phpctl:php83-devcontainers -f devcontainers.Dockerfile .
+	@docker push opencodeco/phpctl:php83-devcontainers
diff --git a/debian.Dockerfile b/debian.Dockerfile
deleted file mode 100644
index 6f94bec..0000000
--- a/debian.Dockerfile
+++ /dev/null
@@ -1,18 +0,0 @@
-FROM debian
-
-ARG PHP
-ENV PHP_VERSION=$PHP
-
-ARG WITH_EXAKAT
-ENV WITH_EXAKAT=$WITH_EXAKAT
-
-ARG WITHOUT_WATCHR
-ENV WITHOUT_WATCHR=$WITHOUT_WATCHR
-
-COPY rootfs /
-RUN apt update && apt install -y \
- unzip wget php-cli php-dom php-mbstring php-mysql \
- && /usr/local/bin/install-tools
-
-ENTRYPOINT [ "/usr/bin/php" ]
-CMD [ "-v" ]
diff --git a/devcontainers.Dockerfile b/devcontainers.Dockerfile
new file mode 100644
index 0000000..17a4706
--- /dev/null
+++ b/devcontainers.Dockerfile
@@ -0,0 +1,6 @@
+FROM mcr.microsoft.com/devcontainers/php:8.3
+RUN curl -sSLf \
+ -o /usr/local/bin/install-php-extensions \
+ https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \
+ chmod +x /usr/local/bin/install-php-extensions && \
+ install-php-extensions pdo_mysql swoole
From cdd2f6c942bb5671ede99a91a7352892421e5b90 Mon Sep 17 00:00:00 2001
From: leocavalcante 
Date: 2024年3月15日 21:34:03 -0300
Subject: [PATCH 079/130] fix(devcontainers): Job name
---
 .github/workflows/devcontainers.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/devcontainers.yml b/.github/workflows/devcontainers.yml
index af4223f..527a8c1 100644
--- a/.github/workflows/devcontainers.yml
+++ b/.github/workflows/devcontainers.yml
@@ -7,7 +7,7 @@ on:
 - main
 
 jobs:
- frankenphp:
+ devcontainers:
 runs-on: ubuntu-latest
 steps:
 -
From 1f7bc240905fb91ce8e83f3c01b204d9b064a2ac Mon Sep 17 00:00:00 2001
From: leocavalcante 
Date: 2024年3月15日 22:24:27 -0300
Subject: [PATCH 080/130] chore(devcontainer): Proper naming
---
 .github/workflows/{devcontainers.yml => devcontainer.yml} | 8 ++++----
 Makefile | 8 ++++----
 devcontainers.Dockerfile => devcontainer.Dockerfile | 0
 3 files changed, 8 insertions(+), 8 deletions(-)
 rename .github/workflows/{devcontainers.yml => devcontainer.yml} (83%)
 rename devcontainers.Dockerfile => devcontainer.Dockerfile (100%)
diff --git a/.github/workflows/devcontainers.yml b/.github/workflows/devcontainer.yml
similarity index 83%
rename from .github/workflows/devcontainers.yml
rename to .github/workflows/devcontainer.yml
index 527a8c1..0a8281f 100644
--- a/.github/workflows/devcontainers.yml
+++ b/.github/workflows/devcontainer.yml
@@ -1,4 +1,4 @@
-name: Dev containers
+name: Dev Container
 
 on:
 pull_request:
@@ -7,7 +7,7 @@ on:
 - main
 
 jobs:
- devcontainers:
+ devcontainer:
 runs-on: ubuntu-latest
 steps:
 -
@@ -30,6 +30,6 @@ jobs:
 uses: docker/build-push-action@v5
 with:
 context: .
- file: devcontainers.Dockerfile
+ file: devcontainer.Dockerfile
 push: true
- tags: opencodeco/phpctl:php83-devcontainers
+ tags: opencodeco/phpctl:php83-devcontainer
diff --git a/Makefile b/Makefile
index b019973..409a520 100644
--- a/Makefile
+++ b/Makefile
@@ -13,7 +13,7 @@ test:
 install:
 	@sudo ./scripts/symlink-bins.sh
 
-.PHONY: devcontainers
-devcontainers:
-	@docker buildx build -t opencodeco/phpctl:php83-devcontainers -f devcontainers.Dockerfile .
-	@docker push opencodeco/phpctl:php83-devcontainers
+.PHONY: devcontainer
+devcontainer:
+	@docker buildx build -t opencodeco/phpctl:php83-devcontainer -f devcontainer.Dockerfile .
+	@docker push opencodeco/phpctl:php83-devcontainer
diff --git a/devcontainers.Dockerfile b/devcontainer.Dockerfile
similarity index 100%
rename from devcontainers.Dockerfile
rename to devcontainer.Dockerfile
From b4e494cba50d101e0bd134ba231d2de5010871d8 Mon Sep 17 00:00:00 2001
From: Leo Cavalcante 
Date: 2024年3月19日 10:45:24 -0300
Subject: [PATCH 081/130] chore(ci): Restore login action to the latest version
---
 .github/workflows/docker.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
index 77b7f5a..76d963d 100644
--- a/.github/workflows/docker.yml
+++ b/.github/workflows/docker.yml
@@ -30,7 +30,7 @@ jobs:
 uses: docker/setup-buildx-action@v3
 -
 name: Login to Docker Hub
- uses: docker/login-action@v2
+ uses: docker/login-action@v3
 with:
 username: ${{ secrets.DOCKERHUB_USERNAME }}
 password: ${{ secrets.DOCKERHUB_TOKEN }}
From 7a24ee2ca86d105ce0f1a91f1abb2192d8b488af Mon Sep 17 00:00:00 2001
From: Bruno Gastadi 
Date: 2024年3月19日 10:48:12 -0300
Subject: [PATCH 082/130] feat(ext): pdo_pgsql (#36)
Add the `pdo_pgsql` extension to use PostgreSQL.
Co-authored-by: Leo Cavalcante 
---
 Dockerfile | 1 +
 1 file changed, 1 insertion(+)
diff --git a/Dockerfile b/Dockerfile
index 971c535..c844df8 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -25,6 +25,7 @@ RUN apk add --update --no-cache \
 php${PHP}-pcntl \
 php${PHP}-pdo \
 php${PHP}-pdo_mysql \
+ php${PHP}-pdo_pgsql \
 php${PHP}-phar \
 php${PHP}-posix \
 php${PHP}-simplexml \
From 2912b40419af76071af221c56026f9a48a38a2e8 Mon Sep 17 00:00:00 2001
From: schons <82298137+sschonss@users.noreply.github.com>
Date: 2024年3月19日 10:48:36 -0300
Subject: [PATCH 083/130] feat(ext): GD (#40)
---
 Dockerfile | 1 +
 1 file changed, 1 insertion(+)
diff --git a/Dockerfile b/Dockerfile
index c844df8..2e07cf9 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -18,6 +18,7 @@ RUN apk add --update --no-cache \
 php${PHP}-ctype \
 php${PHP}-dom \
 php${PHP}-fileinfo \
+ php${PHP}-gd \
 php${PHP}-iconv \
 php${PHP}-mbstring \
 php${PHP}-mysqlnd \
From ee2ff476502738042b450d0a25b71e036f78adda Mon Sep 17 00:00:00 2001
From: Leo Cavalcante 
Date: 2024年3月19日 16:36:39 -0300
Subject: [PATCH 084/130] feat(ext/devcontainer): Sockets
---
 devcontainer.Dockerfile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/devcontainer.Dockerfile b/devcontainer.Dockerfile
index 17a4706..6954e77 100644
--- a/devcontainer.Dockerfile
+++ b/devcontainer.Dockerfile
@@ -3,4 +3,4 @@ RUN curl -sSLf \
 -o /usr/local/bin/install-php-extensions \
 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \
 chmod +x /usr/local/bin/install-php-extensions && \
- install-php-extensions pdo_mysql swoole
+ install-php-extensions pdo_mysql sockets swoole
From 6afe09ea7a272dcf9c42c5efc2fad3257804462b Mon Sep 17 00:00:00 2001
From: Leo Cavalcante 
Date: 2024年3月19日 16:36:39 -0300
Subject: [PATCH 085/130] feat(ext/devcontainer): Pcntl
---
 devcontainer.Dockerfile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/devcontainer.Dockerfile b/devcontainer.Dockerfile
index 6954e77..b316756 100644
--- a/devcontainer.Dockerfile
+++ b/devcontainer.Dockerfile
@@ -3,4 +3,4 @@ RUN curl -sSLf \
 -o /usr/local/bin/install-php-extensions \
 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \
 chmod +x /usr/local/bin/install-php-extensions && \
- install-php-extensions pdo_mysql sockets swoole
+ install-php-extensions pcntl pdo_mysql sockets swoole
From 049313a180f9ec38d4815d9d4f700d43ba169cb5 Mon Sep 17 00:00:00 2001
From: leocavalcante 
Date: 2024年3月21日 02:12:07 +0000
Subject: [PATCH 086/130] feat(devcontainer): Using itself to develop itself
---
 .devcontainer/devcontainer.json | 9 +++++++++
 Makefile | 4 ++--
 devcontainer.Dockerfile | 3 ++-
 3 files changed, 13 insertions(+), 3 deletions(-)
 create mode 100644 .devcontainer/devcontainer.json
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
new file mode 100644
index 0000000..418bec2
--- /dev/null
+++ b/.devcontainer/devcontainer.json
@@ -0,0 +1,9 @@
+{
+ "build": {
+ "context": "..",
+ "dockerfile": "../devcontainer.Dockerfile"
+ },
+ "features": {
+ "ghcr.io/devcontainers/features/docker-in-docker:2": {}
+ }
+}
diff --git a/Makefile b/Makefile
index 409a520..7e93a41 100644
--- a/Makefile
+++ b/Makefile
@@ -3,11 +3,11 @@ default: build
 
 .PHONY: build
 build:
-	@parallel --line-buffer PHP_VERSION={} phpctl build ::: 81 82 83
+	@parallel --line-buffer PHP_VERSION={} ./bin/phpctl build ::: 81 82 83
 
 .PHONY: test
 test:
-	@parallel --line-buffer PHP_VERSION={} COMPOSER_AUTH= TERM= notty ./lib/bashunit ./tests/ ::: 81 82 83
+	@parallel --line-buffer PHP_VERSION={} COMPOSER_AUTH= TERM= ./bin/notty ./lib/bashunit ./tests/ ::: 81 82 83
 
 .PHONY: install
 install:
diff --git a/devcontainer.Dockerfile b/devcontainer.Dockerfile
index b316756..6baca1d 100644
--- a/devcontainer.Dockerfile
+++ b/devcontainer.Dockerfile
@@ -1,5 +1,6 @@
 FROM mcr.microsoft.com/devcontainers/php:8.3
-RUN curl -sSLf \
+RUN apt-get update && apt-get install -y parallel && \
+ curl -sSLf \
 -o /usr/local/bin/install-php-extensions \
 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \
 chmod +x /usr/local/bin/install-php-extensions && \
From 0ce2ee2e54b046e3fd6c370e2a4ab2e976a47009 Mon Sep 17 00:00:00 2001
From: leocavalcante 
Date: 2024年3月21日 02:32:45 +0000
Subject: [PATCH 087/130] fix(devcontainer): Share SSH settings
---
 .devcontainer/devcontainer.json | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
index 418bec2..547c8e4 100644
--- a/.devcontainer/devcontainer.json
+++ b/.devcontainer/devcontainer.json
@@ -5,5 +5,9 @@
 },
 "features": {
 "ghcr.io/devcontainers/features/docker-in-docker:2": {}
- }
+ },
+ "mounts": [
+ "source=${localEnv:HOME}/.ssh,target=/home/vscode/.ssh,type=bind,consistency=cached"
+ ],
+ "containerUser": "vscode"
 }
From a74443130aca0877cefd97f54a438437f752a64b Mon Sep 17 00:00:00 2001
From: Leo Cavalcante 
Date: 2024年3月21日 23:25:49 +0000
Subject: [PATCH 088/130] refactor(devcontainer): More extensions
---
 .devcontainer/devcontainer.json | 21 +++++++++++++++------
 devcontainer.Dockerfile | 10 ++++------
 2 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
index 547c8e4..87c5c5d 100644
--- a/.devcontainer/devcontainer.json
+++ b/.devcontainer/devcontainer.json
@@ -1,13 +1,22 @@
 {
- "build": {
- "context": "..",
- "dockerfile": "../devcontainer.Dockerfile"
- },
+ "image": "opencodeco/phpctl:php83-devcontainer",
 "features": {
- "ghcr.io/devcontainers/features/docker-in-docker:2": {}
+ "ghcr.io/devcontainers/features/sshd:1": {},
+ "ghcr.io/devcontainers/features/docker-in-docker:2": {}, 
+ "ghcr.io/devcontainers/features/github-cli:1": {}
+ 
 },
 "mounts": [
 "source=${localEnv:HOME}/.ssh,target=/home/vscode/.ssh,type=bind,consistency=cached"
 ],
- "containerUser": "vscode"
+ "containerUser": "vscode",
+ "customizations": {
+ "vscode": {
+ "extensions": [
+ "ms-vscode.makefile-tools",
+ "timonwong.shellcheck",
+ "ms-azuretools.vscode-docker"
+ ]
+ }
+ }
 }
diff --git a/devcontainer.Dockerfile b/devcontainer.Dockerfile
index 6baca1d..0f11094 100644
--- a/devcontainer.Dockerfile
+++ b/devcontainer.Dockerfile
@@ -1,7 +1,5 @@
 FROM mcr.microsoft.com/devcontainers/php:8.3
-RUN apt-get update && apt-get install -y parallel && \
- curl -sSLf \
- -o /usr/local/bin/install-php-extensions \
- https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions && \
- chmod +x /usr/local/bin/install-php-extensions && \
- install-php-extensions pcntl pdo_mysql sockets swoole
+ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
+RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
+ && apt-get -y install --no-install-recommends parallel \
+ && install-php-extensions decimal gd intl mongodb pcntl pdo_mysql pdo_pgsql pdo_sqlite rdkafka redis sockets swoole
From f68d7cec3cac0a3fa86f44395174cf1b979673d7 Mon Sep 17 00:00:00 2001
From: Leo Cavalcante 
Date: 2024年3月22日 00:02:36 +0000
Subject: [PATCH 089/130] feat(devcontainer): Using official PHP base image and
 installing tools
---
 devcontainer.Dockerfile | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/devcontainer.Dockerfile b/devcontainer.Dockerfile
index 0f11094..4495e12 100644
--- a/devcontainer.Dockerfile
+++ b/devcontainer.Dockerfile
@@ -1,5 +1,7 @@
-FROM mcr.microsoft.com/devcontainers/php:8.3
+FROM php:8.3-cli-bookworm
+COPY rootfs /
 ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
 RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
 && apt-get -y install --no-install-recommends parallel \
- && install-php-extensions decimal gd intl mongodb pcntl pdo_mysql pdo_pgsql pdo_sqlite rdkafka redis sockets swoole
+ && install-php-extensions decimal gd intl mongodb pcntl pdo_mysql pdo_pgsql pdo_sqlite rdkafka redis sockets swoole \
+ && install-tools
From 7dd131d757705fb131b028c09c51a5a6021e845e Mon Sep 17 00:00:00 2001
From: leocavalcante 
Date: 2024年3月22日 02:20:52 +0000
Subject: [PATCH 090/130] refactor(devcontainer): Pre-build phpctl image
---
 .devcontainer/devcontainer.json | 15 +++++----------
 .github/workflows/devcontainer.yml | 11 +++++------
 Makefile | 3 +--
 devcontainer/.devcontainer.json | 16 ++++++++++++++++
 .../Dockerfile | 6 +++---
 5 files changed, 30 insertions(+), 21 deletions(-)
 create mode 100644 devcontainer/.devcontainer.json
 rename devcontainer.Dockerfile => devcontainer/Dockerfile (67%)
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
index 87c5c5d..88aba63 100644
--- a/.devcontainer/devcontainer.json
+++ b/.devcontainer/devcontainer.json
@@ -1,21 +1,16 @@
 {
 "image": "opencodeco/phpctl:php83-devcontainer",
 "features": {
- "ghcr.io/devcontainers/features/sshd:1": {},
- "ghcr.io/devcontainers/features/docker-in-docker:2": {}, 
- "ghcr.io/devcontainers/features/github-cli:1": {}
- 
+ "ghcr.io/devcontainers/features/docker-in-docker:2": {},
+ "ghcr.io/devcontainers-contrib/features/devcontainers-cli:1": {},
+ "ghcr.io/devcontainers/features/sshd:1": {}
 },
- "mounts": [
- "source=${localEnv:HOME}/.ssh,target=/home/vscode/.ssh,type=bind,consistency=cached"
- ],
- "containerUser": "vscode",
 "customizations": {
 "vscode": {
 "extensions": [
 "ms-vscode.makefile-tools",
- "timonwong.shellcheck",
- "ms-azuretools.vscode-docker"
+ "ms-azuretools.vscode-docker",
+ "timonwong.shellcheck"
 ]
 }
 }
diff --git a/.github/workflows/devcontainer.yml b/.github/workflows/devcontainer.yml
index 0a8281f..0fdfde0 100644
--- a/.github/workflows/devcontainer.yml
+++ b/.github/workflows/devcontainer.yml
@@ -26,10 +26,9 @@ jobs:
 username: ${{ secrets.DOCKERHUB_USERNAME }}
 password: ${{ secrets.DOCKERHUB_TOKEN }}
 -
- name: Build and push
- uses: docker/build-push-action@v5
+ name: Build and run dev container task
+ uses: devcontainers/ci@v0.3
 with:
- context: .
- file: devcontainer.Dockerfile
- push: true
- tags: opencodeco/phpctl:php83-devcontainer
+ subFolder: devcontainer
+ imageName: opencodeco/phpctl:php83-devcontainer
+ push: always
diff --git a/Makefile b/Makefile
index 7e93a41..08d8486 100644
--- a/Makefile
+++ b/Makefile
@@ -15,5 +15,4 @@ install:
 
 .PHONY: devcontainer
 devcontainer:
-	@docker buildx build -t opencodeco/phpctl:php83-devcontainer -f devcontainer.Dockerfile .
-	@docker push opencodeco/phpctl:php83-devcontainer
+	@devcontainer build --no-cache --workspace-folder devcontainer --push true --image-name opencodeco/phpctl:php83-devcontainer
diff --git a/devcontainer/.devcontainer.json b/devcontainer/.devcontainer.json
new file mode 100644
index 0000000..22472bd
--- /dev/null
+++ b/devcontainer/.devcontainer.json
@@ -0,0 +1,16 @@
+{
+ "build": {
+ "dockerfile": "./Dockerfile",
+ "context": ".."
+ },
+ "features": {
+ "ghcr.io/devcontainers/features/common-utils:2": {
+ "installZsh": "true",
+ "username": "phpctl",
+ "userUid": "1000",
+ "userGid": "1000",
+ "upgradePackages": "true"
+ }
+ },
+ "remoteUser": "phpctl"
+}
diff --git a/devcontainer.Dockerfile b/devcontainer/Dockerfile
similarity index 67%
rename from devcontainer.Dockerfile
rename to devcontainer/Dockerfile
index 4495e12..371e09c 100644
--- a/devcontainer.Dockerfile
+++ b/devcontainer/Dockerfile
@@ -1,7 +1,7 @@
 FROM php:8.3-cli-bookworm
-COPY rootfs /
 ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
+COPY rootfs .
 RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
- && apt-get -y install --no-install-recommends parallel \
- && install-php-extensions decimal gd intl mongodb pcntl pdo_mysql pdo_pgsql pdo_sqlite rdkafka redis sockets swoole \
+ && apt-get -y install --no-install-recommends parallel unzip wget \
+ && install-php-extensions decimal gd intl mongodb pcntl pdo_mysql pdo_pgsql pdo_sqlite rdkafka redis sockets swoole xdebug \
 && install-tools
From b4f112a4fbc178eef10b644f443e89b39099a7b0 Mon Sep 17 00:00:00 2001
From: leocavalcante 
Date: 2024年3月21日 23:23:43 -0300
Subject: [PATCH 091/130] fix(devcontainer): Naming conventions
---
 devcontainer/{ => .devcontainer}/.devcontainer.json | 2 +-
 devcontainer/{ => .devcontainer}/Dockerfile | 0
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename devcontainer/{ => .devcontainer}/.devcontainer.json (92%)
 rename devcontainer/{ => .devcontainer}/Dockerfile (100%)
diff --git a/devcontainer/.devcontainer.json b/devcontainer/.devcontainer/.devcontainer.json
similarity index 92%
rename from devcontainer/.devcontainer.json
rename to devcontainer/.devcontainer/.devcontainer.json
index 22472bd..ad31c17 100644
--- a/devcontainer/.devcontainer.json
+++ b/devcontainer/.devcontainer/.devcontainer.json
@@ -1,7 +1,7 @@
 {
 "build": {
 "dockerfile": "./Dockerfile",
- "context": ".."
+ "context": "../.."
 },
 "features": {
 "ghcr.io/devcontainers/features/common-utils:2": {
diff --git a/devcontainer/Dockerfile b/devcontainer/.devcontainer/Dockerfile
similarity index 100%
rename from devcontainer/Dockerfile
rename to devcontainer/.devcontainer/Dockerfile
From bd1cdd07b3155370405217f14c1192999c935a97 Mon Sep 17 00:00:00 2001
From: leocavalcante 
Date: 2024年3月21日 23:26:45 -0300
Subject: [PATCH 092/130] chore(devcontainer): Better naming
---
 .github/workflows/devcontainer.yml | 2 +-
 {devcontainer => src-devc}/.devcontainer/Dockerfile | 0
 .../.devcontainer/devcontainer.json | 0
 3 files changed, 1 insertion(+), 1 deletion(-)
 rename {devcontainer => src-devc}/.devcontainer/Dockerfile (100%)
 rename devcontainer/.devcontainer/.devcontainer.json => src-devc/.devcontainer/devcontainer.json (100%)
diff --git a/.github/workflows/devcontainer.yml b/.github/workflows/devcontainer.yml
index 0fdfde0..c57969c 100644
--- a/.github/workflows/devcontainer.yml
+++ b/.github/workflows/devcontainer.yml
@@ -29,6 +29,6 @@ jobs:
 name: Build and run dev container task
 uses: devcontainers/ci@v0.3
 with:
- subFolder: devcontainer
+ subFolder: src-devc
 imageName: opencodeco/phpctl:php83-devcontainer
 push: always
diff --git a/devcontainer/.devcontainer/Dockerfile b/src-devc/.devcontainer/Dockerfile
similarity index 100%
rename from devcontainer/.devcontainer/Dockerfile
rename to src-devc/.devcontainer/Dockerfile
diff --git a/devcontainer/.devcontainer/.devcontainer.json b/src-devc/.devcontainer/devcontainer.json
similarity index 100%
rename from devcontainer/.devcontainer/.devcontainer.json
rename to src-devc/.devcontainer/devcontainer.json
From 3e38e686c6cbeb3c5b0983805a75265675b5933d Mon Sep 17 00:00:00 2001
From: leocavalcante 
Date: 2024年3月21日 23:29:48 -0300
Subject: [PATCH 093/130] fix(ci/devcontainer): Image tag
---
 .github/workflows/devcontainer.yml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/devcontainer.yml b/.github/workflows/devcontainer.yml
index c57969c..49868e2 100644
--- a/.github/workflows/devcontainer.yml
+++ b/.github/workflows/devcontainer.yml
@@ -30,5 +30,6 @@ jobs:
 uses: devcontainers/ci@v0.3
 with:
 subFolder: src-devc
- imageName: opencodeco/phpctl:php83-devcontainer
+ imageName: opencodeco/phpctl
+	 imageTag: php83-devcontainer
 push: always
From 6135eee21077eca15da3193f1c2725f9c5d28195 Mon Sep 17 00:00:00 2001
From: leocavalcante 
Date: 2024年3月21日 23:34:07 -0300
Subject: [PATCH 094/130] fix(ci): Indent
---
 .github/workflows/devcontainer.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/devcontainer.yml b/.github/workflows/devcontainer.yml
index 49868e2..943e480 100644
--- a/.github/workflows/devcontainer.yml
+++ b/.github/workflows/devcontainer.yml
@@ -31,5 +31,5 @@ jobs:
 with:
 subFolder: src-devc
 imageName: opencodeco/phpctl
-	 imageTag: php83-devcontainer
+ imageTag: php83-devcontainer
 push: always
From 510421a94b6a0825de68fe75fd3ab52629b4ab09 Mon Sep 17 00:00:00 2001
From: Leo Cavalcante 
Date: 2024年3月22日 03:02:48 +0000
Subject: [PATCH 095/130] fix(devcontainer): PHP version env and pre-installed
---
 .devcontainer/devcontainer.json | 4 ++++
 1 file changed, 4 insertions(+)
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
index 88aba63..42b45d2 100644
--- a/.devcontainer/devcontainer.json
+++ b/.devcontainer/devcontainer.json
@@ -1,5 +1,9 @@
 {
 "image": "opencodeco/phpctl:php83-devcontainer",
+ "postCreateCommand": "make install",
+ "containerEnv": {
+ "PHP_VERSION": "83"
+ },
 "features": {
 "ghcr.io/devcontainers/features/docker-in-docker:2": {},
 "ghcr.io/devcontainers-contrib/features/devcontainers-cli:1": {},
From 8f1e1988d7b40ad3eaab65637d3ed56f0824585f Mon Sep 17 00:00:00 2001
From: Leo Cavalcante 
Date: 2024年3月22日 15:40:19 +0000
Subject: [PATCH 096/130] feat(devcontaienr): Pcov extension
---
 src-devc/.devcontainer/Dockerfile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src-devc/.devcontainer/Dockerfile b/src-devc/.devcontainer/Dockerfile
index 371e09c..f68acb1 100644
--- a/src-devc/.devcontainer/Dockerfile
+++ b/src-devc/.devcontainer/Dockerfile
@@ -3,5 +3,5 @@ ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/relea
 COPY rootfs .
 RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
 && apt-get -y install --no-install-recommends parallel unzip wget \
- && install-php-extensions decimal gd intl mongodb pcntl pdo_mysql pdo_pgsql pdo_sqlite rdkafka redis sockets swoole xdebug \
+ && install-php-extensions decimal gd intl mongodb pcntl pcov pdo_mysql pdo_pgsql pdo_sqlite rdkafka redis sockets swoole xdebug \
 && install-tools
From f2cd8b3b1c5fbaf5a1231d3d23f0e1b4750b8669 Mon Sep 17 00:00:00 2001
From: Leo Cavalcante 
Date: 2024年3月22日 15:41:26 +0000
Subject: [PATCH 097/130] fix(run): Share Git config dir only if it exists
Avoid it being created when not exists
---
 src/docker.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/docker.sh b/src/docker.sh
index 02ababc..224b4b4 100644
--- a/src/docker.sh
+++ b/src/docker.sh
@@ -51,6 +51,11 @@ run() {
 composer_home="-v $composer_home:$composer_home"
 fi
 
+ local gitconfig=""
+ if [ -f ~/.gitconfig ]; then
+ gitconfig="-v ~/.gitconfig:/root/.gitconfig:ro"
+ fi
+
 if [ -n "$GIT_EXEC_PATH" ]; then
 # In a Git hook environment, we need to disable TTY allocation
 PHPCTL_TTY="--label=no-tty"
@@ -68,7 +73,7 @@ run() {
 --user "$PHPCTL_USER" \
 $(env | awk -F= '/^[[:alpha:]]/{print 1ドル}' | sed 's/^/-e/') \
 -v /var/run/docker.sock:/var/run/docker.sock \
- -v ~/.gitconfig:/root/.gitconfig:ro \
+ $gitconfig \
 -v "$(pwd)":/usr/local/src -w /usr/local/src \
 -v "$PHPCTL_DIR/php.ini:/etc/php$PHP_VERSION/conf.d/zphp.ini" \
 $phpctl_ini \
From e0f2748ed72086c1291abccb69ce48cf279424ee Mon Sep 17 00:00:00 2001
From: Leo Cavalcante 
Date: 2024年3月22日 18:07:32 -0300
Subject: [PATCH 098/130] feat(devcontainer): GitHub CLI
---
 src-devc/.devcontainer/devcontainer.json | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src-devc/.devcontainer/devcontainer.json b/src-devc/.devcontainer/devcontainer.json
index ad31c17..3a2386e 100644
--- a/src-devc/.devcontainer/devcontainer.json
+++ b/src-devc/.devcontainer/devcontainer.json
@@ -10,7 +10,8 @@
 "userUid": "1000",
 "userGid": "1000",
 "upgradePackages": "true"
- }
+ },
+ "ghcr.io/devcontainers/features/github-cli:1": {}
 },
 "remoteUser": "phpctl"
 }
From 8e92f871e856fc2dfb14c4f8256fca3a6b3c2fb3 Mon Sep 17 00:00:00 2001
From: Leo Cavalcante 
Date: 2024年3月22日 18:53:33 -0300
Subject: [PATCH 099/130] refactor(devcontainer): Using feature to install
 extensions
---
 src-devc/.devcontainer/devcontainer.json | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)
diff --git a/src-devc/.devcontainer/devcontainer.json b/src-devc/.devcontainer/devcontainer.json
index 3a2386e..6a55192 100644
--- a/src-devc/.devcontainer/devcontainer.json
+++ b/src-devc/.devcontainer/devcontainer.json
@@ -1,17 +1,8 @@
 {
- "build": {
- "dockerfile": "./Dockerfile",
- "context": "../.."
- },
+ "image": "mcr.microsoft.com/devcontainers/php:8.3-bookworm",
 "features": {
- "ghcr.io/devcontainers/features/common-utils:2": {
- "installZsh": "true",
- "username": "phpctl",
- "userUid": "1000",
- "userGid": "1000",
- "upgradePackages": "true"
- },
- "ghcr.io/devcontainers/features/github-cli:1": {}
- },
- "remoteUser": "phpctl"
+ "ghcr.io/opencodeco/devcontainers/install-php-extensions:latest": {
+ "extensions": "swoole"
+ }
+ }
 }
From 382aac14651a4ae37d36ef91f8267ce355cc1bae Mon Sep 17 00:00:00 2001
From: Leo Cavalcante 
Date: 2024年3月22日 19:01:03 -0300
Subject: [PATCH 100/130] chore(docs): Dev Container badge
---
 README.md | 1 +
 1 file changed, 1 insertion(+)
diff --git a/README.md b/README.md
index 117cdf2..0a76511 100644
--- a/README.md
+++ b/README.md
@@ -7,6 +7,7 @@
 

phpctl phpctl docker badge + phpctl docker badge phpctl frankenphp badge

🐳 A Docker-based development environment for PHP 🐘

From bfcc7e36d677698217310c9123530b8eb5709197 Mon Sep 17 00:00:00 2001 From: Leo Cavalcante Date: 2024年3月22日 19:05:30 -0300 Subject: [PATCH 101/130] feat(devcontainer): Common extensions --- src-devc/.devcontainer/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src-devc/.devcontainer/devcontainer.json b/src-devc/.devcontainer/devcontainer.json index 6a55192..f044517 100644 --- a/src-devc/.devcontainer/devcontainer.json +++ b/src-devc/.devcontainer/devcontainer.json @@ -2,7 +2,7 @@ "image": "mcr.microsoft.com/devcontainers/php:8.3-bookworm", "features": { "ghcr.io/opencodeco/devcontainers/install-php-extensions:latest": { - "extensions": "swoole" + "extensions": "decimal gd intl mongodb pcntl pcov pdo_mysql pdo_pgsql pdo_sqlite rdkafka redis sockets swoole" } } } From 2283cab4f9d8b88a421e07fa541afee2ffd760ff Mon Sep 17 00:00:00 2001 From: Leo Cavalcante Date: 2024年3月22日 19:13:31 -0300 Subject: [PATCH 102/130] chore(devcontainer): Unused file --- src-devc/.devcontainer/Dockerfile | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 src-devc/.devcontainer/Dockerfile diff --git a/src-devc/.devcontainer/Dockerfile b/src-devc/.devcontainer/Dockerfile deleted file mode 100644 index f68acb1..0000000 --- a/src-devc/.devcontainer/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM php:8.3-cli-bookworm -ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ -COPY rootfs . -RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ - && apt-get -y install --no-install-recommends parallel unzip wget \ - && install-php-extensions decimal gd intl mongodb pcntl pcov pdo_mysql pdo_pgsql pdo_sqlite rdkafka redis sockets swoole xdebug \ - && install-tools From 7e68e5a5c9c3f769dddfead2a0a79c99ff27d7e3 Mon Sep 17 00:00:00 2001 From: Leo Cavalcante Date: 2024年3月22日 19:13:58 -0300 Subject: [PATCH 103/130] refactor(ext/devcontainer): Remove PDO SQLite --- src-devc/.devcontainer/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src-devc/.devcontainer/devcontainer.json b/src-devc/.devcontainer/devcontainer.json index f044517..614b31c 100644 --- a/src-devc/.devcontainer/devcontainer.json +++ b/src-devc/.devcontainer/devcontainer.json @@ -2,7 +2,7 @@ "image": "mcr.microsoft.com/devcontainers/php:8.3-bookworm", "features": { "ghcr.io/opencodeco/devcontainers/install-php-extensions:latest": { - "extensions": "decimal gd intl mongodb pcntl pcov pdo_mysql pdo_pgsql pdo_sqlite rdkafka redis sockets swoole" + "extensions": "decimal gd intl mongodb pcntl pcov pdo_mysql pdo_pgsql rdkafka redis sockets swoole" } } } From e5b036b8794052297b1604de87a33f8110e03a3e Mon Sep 17 00:00:00 2001 From: Leo Cavalcante Date: 2024年3月28日 22:08:35 +0000 Subject: [PATCH 104/130] refactor(devcontainer): From plain PHP --- .devcontainer/devcontainer.json | 13 +++---------- Makefile | 2 +- src-devc/.devcontainer/Dockerfile | 6 ++++++ src-devc/.devcontainer/devcontainer.json | 20 +++++++++++++++++--- 4 files changed, 27 insertions(+), 14 deletions(-) create mode 100644 src-devc/.devcontainer/Dockerfile diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 42b45d2..bf85986 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,21 +1,14 @@ { "image": "opencodeco/phpctl:php83-devcontainer", - "postCreateCommand": "make install", "containerEnv": { "PHP_VERSION": "83" }, "features": { "ghcr.io/devcontainers/features/docker-in-docker:2": {}, "ghcr.io/devcontainers-contrib/features/devcontainers-cli:1": {}, - "ghcr.io/devcontainers/features/sshd:1": {} - }, - "customizations": { - "vscode": { - "extensions": [ - "ms-vscode.makefile-tools", - "ms-azuretools.vscode-docker", - "timonwong.shellcheck" - ] + "ghcr.io/devcontainers/features/sshd:1": {}, + "ghcr.io/rocker-org/devcontainer-features/apt-packages:1": { + "packages": "parallel" } } } diff --git a/Makefile b/Makefile index 08d8486..e1946f8 100644 --- a/Makefile +++ b/Makefile @@ -15,4 +15,4 @@ install: .PHONY: devcontainer devcontainer: - @devcontainer build --no-cache --workspace-folder devcontainer --push true --image-name opencodeco/phpctl:php83-devcontainer + @devcontainer build --workspace-folder src-devc --push true --image-name opencodeco/phpctl:php83-devcontainer diff --git a/src-devc/.devcontainer/Dockerfile b/src-devc/.devcontainer/Dockerfile new file mode 100644 index 0000000..f28bce0 --- /dev/null +++ b/src-devc/.devcontainer/Dockerfile @@ -0,0 +1,6 @@ +FROM php:8.3-bookworm +COPY rootfs / +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get -y install --no-install-recommends wget \ + && mv /etc/php/php.ini /usr/local/etc/php/conf.d/zzphp.ini \ + && /usr/local/bin/install-tools diff --git a/src-devc/.devcontainer/devcontainer.json b/src-devc/.devcontainer/devcontainer.json index 614b31c..45061b8 100644 --- a/src-devc/.devcontainer/devcontainer.json +++ b/src-devc/.devcontainer/devcontainer.json @@ -1,8 +1,22 @@ { - "image": "mcr.microsoft.com/devcontainers/php:8.3-bookworm", + "build": { + "dockerfile": "./Dockerfile", + "context": "../.." + }, "features": { + "ghcr.io/devcontainers/features/common-utils:2": { + "installZsh": "true", + "username": "phpctl", + "userUid": "1000", + "userGid": "1000", + "upgradePackages": "true" + }, "ghcr.io/opencodeco/devcontainers/install-php-extensions:latest": { - "extensions": "decimal gd intl mongodb pcntl pcov pdo_mysql pdo_pgsql rdkafka redis sockets swoole" + "extensions": "decimal gd intl mongodb pcntl pcov pdo_mysql pdo_pgsql rdkafka redis sockets swoole xdebug" } - } + }, + "overrideFeatureInstallOrder": [ + "ghcr.io/devcontainers/features/common-utils" + ], + "remoteUser": "phpctl" } From 867e168aec430666d32625beaf280bc2bb5810c0 Mon Sep 17 00:00:00 2001 From: Leo Cavalcante Date: 2024年3月28日 22:08:58 +0000 Subject: [PATCH 105/130] fix(docker): Upgrade apk packages --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 2e07cf9..30b2ca0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ ARG WITHOUT_WATCHR ENV WITHOUT_WATCHR=$WITHOUT_WATCHR COPY rootfs / -RUN apk add --update --no-cache \ +RUN apk add --upgrade --update --no-cache \ git \ docker-cli \ php${PHP}-cli \ From d6135a4daab121066d1e55b3bb51e12e16e0db10 Mon Sep 17 00:00:00 2001 From: Leo Cavalcante Date: 2024年3月28日 22:09:07 +0000 Subject: [PATCH 106/130] chore(dev): Use cache --- src/docker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/docker.sh b/src/docker.sh index 224b4b4..53c3655 100644 --- a/src/docker.sh +++ b/src/docker.sh @@ -12,7 +12,7 @@ build() { echo -e "Building 033円[0;32m$PHPCTL_IMAGE033円[0m" # shellcheck disable=SC2068 # shellcheck disable=SC2154 - $PHPCTL_RUNTIME buildx build --no-cache \ + $PHPCTL_RUNTIME buildx build \ --build-arg PHP="$PHP_VERSION" \ --build-arg COMPOSER_AUTH="$COMPOSER_AUTH" \ --build-arg HOST_USER="$(whoami)" \ From 53731cbc249ef950d3b02bda8dac4c40b6667330 Mon Sep 17 00:00:00 2001 From: Leo Cavalcante Date: 2024年3月28日 19:24:32 -0300 Subject: [PATCH 107/130] chore(docs): Codespaces badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0a76511..f7dcb9b 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@

🐳 A Docker-based development environment for PHP 🐘

Heavily inspired by opencodeco/hfctl.
+

Open in GitHub Codespaces

From 9d4be622f515845c5d969e61dc436a95aae78032 Mon Sep 17 00:00:00 2001 From: Leo Cavalcante Date: 2024年3月28日 22:43:28 +0000 Subject: [PATCH 108/130] fix(dev): Remove test files after all tests --- Makefile | 1 + tests/php_test.sh | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Makefile b/Makefile index e1946f8..92ad3ca 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,7 @@ build: .PHONY: test test: @parallel --line-buffer PHP_VERSION={} COMPOSER_AUTH= TERM= ./bin/notty ./lib/bashunit ./tests/ ::: 81 82 83 + @[ -f phpctl.ini ] && rm phpctl.ini .PHONY: install install: diff --git a/tests/php_test.sh b/tests/php_test.sh index 325f32b..9ebab2d 100644 --- a/tests/php_test.sh +++ b/tests/php_test.sh @@ -14,7 +14,4 @@ function test_composer() { function test_phpctl_ini() { echo "memory_limit=1337M"> phpctl.ini assert_contains "memory_limit => 1337M => 1337M" "$(./bin/phpctl php -i | grep memory_limit)" - if [ -f phpctl.ini ]; then - rm phpctl.ini - fi } From ee792d8e66fc23b880f1bc7e7c061a5d1537ebd7 Mon Sep 17 00:00:00 2001 From: Leo Cavalcante Date: 2024年3月28日 22:51:45 +0000 Subject: [PATCH 109/130] chore(docs): Tell about dev containers --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index f7dcb9b..9fff05b 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,15 @@ php --version composer --version ``` +Using [Dev Containers](https://containers.dev/)? We have a pre-built image: +```json +{ + "image": "opencodeco/phpctl:php83-devcontainer" +} +``` +In fact, we use it ourselves to develop `phpctl` itself: [devcontainer.json](.devcontainer/devcontainer.json). + + ## Getting started - [Installation guide](https://phpctl.dev/#installation) From b8f4546e2b5def814dea67f867efb5740478e084 Mon Sep 17 00:00:00 2001 From: Silvio Ney Date: Mon, 1 Apr 2024 17:05:14 +0100 Subject: [PATCH 110/130] fix: gitconfig invalid characters issue (#41) --- src/docker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/docker.sh b/src/docker.sh index 53c3655..a023066 100644 --- a/src/docker.sh +++ b/src/docker.sh @@ -53,7 +53,7 @@ run() { local gitconfig="" if [ -f ~/.gitconfig ]; then - gitconfig="-v ~/.gitconfig:/root/.gitconfig:ro" + gitconfig="-v $HOME/.gitconfig:/root/.gitconfig:ro" fi if [ -n "$GIT_EXEC_PATH" ]; then From 726f3ac40c6a373b5222af67e612c2f539e2d047 Mon Sep 17 00:00:00 2001 From: Silvio Ney Date: Tue, 2 Apr 2024 13:25:50 +0100 Subject: [PATCH 111/130] feat: Search for .phpctlrc in the home directory for global configurations (#42) Search for .phpctlrc in the home directory for global configurations. --- bin/phpctl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bin/phpctl b/bin/phpctl index a15142e..4a42601 100755 --- a/bin/phpctl +++ b/bin/phpctl @@ -1,5 +1,12 @@ #!/usr/bin/env bash PHPCTL_DIR=$(dirname "$(realpath "0ドル")")/../ + +if [ -s "$HOME/.phpctlrc" ]; then + set -a + . "$HOME/.phpctlrc" + set +a +fi + if [ -s .phpctlrc ]; then set -a . .phpctlrc From af8c8f3561ac4f014bdc6a4c3ab59ca4bf5458e2 Mon Sep 17 00:00:00 2001 From: Leo Cavalcante Date: Wed, 3 Apr 2024 08:05:57 +0000 Subject: [PATCH 112/130] refactor(devcontainer): Using contrib's apt-get --- .devcontainer/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index bf85986..e613e3e 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -7,7 +7,7 @@ "ghcr.io/devcontainers/features/docker-in-docker:2": {}, "ghcr.io/devcontainers-contrib/features/devcontainers-cli:1": {}, "ghcr.io/devcontainers/features/sshd:1": {}, - "ghcr.io/rocker-org/devcontainer-features/apt-packages:1": { + "ghcr.io/devcontainers-contrib/features/apt-get-packages:1": { "packages": "parallel" } } From 8137697d9fcd7dc4a111a61d8e8882fe86dad5c4 Mon Sep 17 00:00:00 2001 From: Leo Cavalcante Date: Wed, 3 Apr 2024 08:07:33 +0000 Subject: [PATCH 113/130] feat(tools): Stop on install errors --- rootfs/usr/local/bin/install-tools | 1 + 1 file changed, 1 insertion(+) diff --git a/rootfs/usr/local/bin/install-tools b/rootfs/usr/local/bin/install-tools index be4ea25..1e59ff6 100755 --- a/rootfs/usr/local/bin/install-tools +++ b/rootfs/usr/local/bin/install-tools @@ -1,4 +1,5 @@ #!/usr/bin/env sh +set -e box() { local version="4.6.1" From ba47dd122a86abdf117cc3321d76c5695f3cd3a8 Mon Sep 17 00:00:00 2001 From: Leo Cavalcante Date: Wed, 3 Apr 2024 08:09:09 +0000 Subject: [PATCH 114/130] :rocket: refactor(devcontainer): Latest and greatest Swoole --- rootfs/usr/local/bin/install-swoole | 23 +++++++++++++++++++++++ src-devc/.devcontainer/Dockerfile | 6 ++++-- src-devc/.devcontainer/devcontainer.json | 2 +- 3 files changed, 28 insertions(+), 3 deletions(-) create mode 100755 rootfs/usr/local/bin/install-swoole diff --git a/rootfs/usr/local/bin/install-swoole b/rootfs/usr/local/bin/install-swoole new file mode 100755 index 0000000..23db7ac --- /dev/null +++ b/rootfs/usr/local/bin/install-swoole @@ -0,0 +1,23 @@ +#!/usr/bin/env sh +set -e + +SWOOLE_VERSION="5.1.2" +echo "Installing Swoole $SWOOLE_VERSION" + +# Download +cd /usr/local/src +wget -q "https://github.com/swoole/swoole-src/archive/refs/tags/v${SWOOLE_VERSION}.zip" +unzip -q "v${SWOOLE_VERSION}.zip" + +# Install +cd "swoole-src-${SWOOLE_VERSION}" +phpize +./configure --enable-sockets --enable-openssl --enable-brotli --enable-mysqlnd --enable-cares --enable-swoole-curl --enable-swoole-pgsql --enable-swoole-sqlite +make -j$(nproc) +make install +echo "extension=swoole.so">> /usr/local/etc/php/conf.d/docker-php-ext-swoole.ini + +# Clean up +cd .. +rm "v${SWOOLE_VERSION}.zip" +rm -r "swoole-src-${SWOOLE_VERSION}" diff --git a/src-devc/.devcontainer/Dockerfile b/src-devc/.devcontainer/Dockerfile index f28bce0..fb3b4e8 100644 --- a/src-devc/.devcontainer/Dockerfile +++ b/src-devc/.devcontainer/Dockerfile @@ -1,6 +1,8 @@ FROM php:8.3-bookworm COPY rootfs / +ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ - && apt-get -y install --no-install-recommends wget \ + && apt-get -y install --no-install-recommends libcurl4-openssl-dev libc-ares-dev libsqlite3-dev libpq-dev git unzip wget \ + && mv /usr/local/etc/php/php.ini-development /usr/local/etc/php/php.ini \ && mv /etc/php/php.ini /usr/local/etc/php/conf.d/zzphp.ini \ - && /usr/local/bin/install-tools + && install-php-extensions sockets && install-swoole && install-tools diff --git a/src-devc/.devcontainer/devcontainer.json b/src-devc/.devcontainer/devcontainer.json index 45061b8..14e4dea 100644 --- a/src-devc/.devcontainer/devcontainer.json +++ b/src-devc/.devcontainer/devcontainer.json @@ -12,7 +12,7 @@ "upgradePackages": "true" }, "ghcr.io/opencodeco/devcontainers/install-php-extensions:latest": { - "extensions": "decimal gd intl mongodb pcntl pcov pdo_mysql pdo_pgsql rdkafka redis sockets swoole xdebug" + "extensions": "decimal gd intl mongodb pcntl pcov pdo_mysql pdo_pgsql rdkafka redis xdebug" } }, "overrideFeatureInstallOrder": [ From a75daba0b9392a8197c459cf87779e8288cc79f3 Mon Sep 17 00:00:00 2001 From: leocavalcante Date: Thu, 9 May 2024 21:06:56 +0000 Subject: [PATCH 115/130] feat(devc): All supported versions --- .github/workflows/devcontainer.yml | 15 ++++++++++++++- Dockerfile | 4 +++- Makefile | 6 +++--- src-devc/.devcontainer/Dockerfile | 7 ++++++- src-devc/.devcontainer/devcontainer.json | 6 +++++- src-devc/build.sh | 3 +++ src/docker.sh | 2 +- 7 files changed, 35 insertions(+), 8 deletions(-) create mode 100755 src-devc/build.sh diff --git a/.github/workflows/devcontainer.yml b/.github/workflows/devcontainer.yml index 943e480..61d9258 100644 --- a/.github/workflows/devcontainer.yml +++ b/.github/workflows/devcontainer.yml @@ -9,6 +9,16 @@ on: jobs: devcontainer: runs-on: ubuntu-latest + strategy: + matrix: + include: + - php: 81 + php-str: 8.1 + - php: 82 + php-str: 8.2 + - php: 83 + php-str: 8.3 + steps: - name: Checkout @@ -28,8 +38,11 @@ jobs: - name: Build and run dev container task uses: devcontainers/ci@v0.3 + env: + PHP_VERSION: ${{ matrix.php }} + PHP_VERSION_STR: ${{ matrix.php-str }} with: subFolder: src-devc imageName: opencodeco/phpctl - imageTag: php83-devcontainer + imageTag: php${{ matrix.php }}-devcontainer push: always diff --git a/Dockerfile b/Dockerfile index 2e07cf9..fb30549 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,12 +11,14 @@ ARG WITHOUT_WATCHR ENV WITHOUT_WATCHR=$WITHOUT_WATCHR COPY rootfs / -RUN apk add --update --no-cache \ +RUN apk update && apk upgrade && apk add --no-cache \ git \ docker-cli \ php${PHP}-cli \ php${PHP}-ctype \ + php${PHP}-curl \ php${PHP}-dom \ + php${PHP}-ffi \ php${PHP}-fileinfo \ php${PHP}-gd \ php${PHP}-iconv \ diff --git a/Makefile b/Makefile index 08d8486..5e81ec8 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,6 @@ test: install: @sudo ./scripts/symlink-bins.sh -.PHONY: devcontainer -devcontainer: - @devcontainer build --no-cache --workspace-folder devcontainer --push true --image-name opencodeco/phpctl:php83-devcontainer +.PHONY: devcontainers +devcontainers: + @parallel --line-buffer PHP_VERSION={} ./src-devc/build.sh ::: 81 82 83 diff --git a/src-devc/.devcontainer/Dockerfile b/src-devc/.devcontainer/Dockerfile index 371e09c..c07f286 100644 --- a/src-devc/.devcontainer/Dockerfile +++ b/src-devc/.devcontainer/Dockerfile @@ -1,4 +1,9 @@ -FROM php:8.3-cli-bookworm +ARG PHP_VERSION 83 +ARG PHP_VERSION_STR 8.3 + +FROM php:${PHP_VERSION_STR}-cli-bookworm +ENV PHP_VERSION $PHP_VERSION + ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ COPY rootfs . RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ diff --git a/src-devc/.devcontainer/devcontainer.json b/src-devc/.devcontainer/devcontainer.json index ad31c17..e2e63e9 100644 --- a/src-devc/.devcontainer/devcontainer.json +++ b/src-devc/.devcontainer/devcontainer.json @@ -1,7 +1,11 @@ { "build": { "dockerfile": "./Dockerfile", - "context": "../.." + "context": "../..", + "args": { + "PHP_VERSION": "${localEnv:PHP_VERSION}", + "PHP_VERSION_STR": "${localEnv:PHP_VERSION_STR}" + } }, "features": { "ghcr.io/devcontainers/features/common-utils:2": { diff --git a/src-devc/build.sh b/src-devc/build.sh new file mode 100755 index 0000000..40ba4c4 --- /dev/null +++ b/src-devc/build.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +export PHP_VERSION_STR="${PHP_VERSION:0:1}.${PHP_VERSION:1}" +devcontainer build --workspace-folder src-devc --push true --image-name "opencodeco/phpctl:php$PHP_VERSION-devcontainer" diff --git a/src/docker.sh b/src/docker.sh index 02ababc..f0d8711 100644 --- a/src/docker.sh +++ b/src/docker.sh @@ -54,7 +54,7 @@ run() { if [ -n "$GIT_EXEC_PATH" ]; then # In a Git hook environment, we need to disable TTY allocation PHPCTL_TTY="--label=no-tty" - fi + fi # shellcheck disable=SC2046 # shellcheck disable=SC2068 From d1b20109a9ea5009804cd520465d3007316be6a6 Mon Sep 17 00:00:00 2001 From: leocavalcante Date: Thu, 9 May 2024 18:14:11 -0300 Subject: [PATCH 116/130] chore(ci): Trigger From 2c11396d3d6e2126769101da12aa5027afd03a1d Mon Sep 17 00:00:00 2001 From: leocavalcante Date: Thu, 9 May 2024 21:24:43 +0000 Subject: [PATCH 117/130] fix(devc): Root file system and parallel --- src-devc/.devcontainer/Dockerfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src-devc/.devcontainer/Dockerfile b/src-devc/.devcontainer/Dockerfile index fcc1406..c9bb6e8 100644 --- a/src-devc/.devcontainer/Dockerfile +++ b/src-devc/.devcontainer/Dockerfile @@ -1,12 +1,11 @@ ARG PHP_VERSION 83 ARG PHP_VERSION_STR 8.3 - FROM php:${PHP_VERSION_STR}-cli-bookworm ENV PHP_VERSION $PHP_VERSION - +COPY rootfs / ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ - && apt-get -y install --no-install-recommends libcurl4-openssl-dev libc-ares-dev libsqlite3-dev libpq-dev git unzip wget \ + && apt-get -y install --no-install-recommends libcurl4-openssl-dev libc-ares-dev libsqlite3-dev libpq-dev git parallel unzip wget \ && mv /usr/local/etc/php/php.ini-development /usr/local/etc/php/php.ini \ && mv /etc/php/php.ini /usr/local/etc/php/conf.d/zzphp.ini \ && install-php-extensions sockets && install-swoole && install-tools From db5ed6e74cfa74d849196f611e414686236d7bc7 Mon Sep 17 00:00:00 2001 From: "Jose M. Valera Reales" Date: 2024年7月15日 00:12:48 +0200 Subject: [PATCH 118/130] Upgrade bashunit 0.14.0 (#44) upgrade bashunit:0.14 --- lib/bashunit | 940 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 738 insertions(+), 202 deletions(-) diff --git a/lib/bashunit b/lib/bashunit index 8a20bca..4663b3c 100755 --- a/lib/bashunit +++ b/lib/bashunit @@ -1,11 +1,22 @@ #!/bin/bash +# src/assert.sh + +function fail() { + local message=1ドル + + local label + label="$(helper::normalize_test_function_name "${FUNCNAME[1]}")" + state::add_assertions_failed + console_results::print_failure_message "${label}" "$message" +} function assert_equals() { local expected="1ドル" local actual="2ドル" - local label="${3:-$(helper::normalize_test_function_name "${FUNCNAME[1]}")}" if [[ "$expected" != "$actual" ]]; then + local label + label="$(helper::normalize_test_function_name "${FUNCNAME[1]}")" state::add_assertions_failed console_results::print_failed_test "${label}" "${expected}" "but got" "${actual}" return @@ -17,19 +28,27 @@ function assert_equals() { function assert_equals_ignore_colors() { local expected="1ドル" local actual="2ドル" - local label="${3:-$(helper::normalize_test_function_name "${FUNCNAME[1]}")}" local actual_without_colors actual_without_colors=$(echo -e "$actual" | sed "s/\x1B\[[0-9;]*[JKmsu]//g") - assert_equals "$expected" "$actual_without_colors" "$label" + if [[ "$expected" != "$actual_without_colors" ]]; then + local label + label="$(helper::normalize_test_function_name "${FUNCNAME[1]}")" + state::add_assertions_failed + console_results::print_failed_test "${label}" "${expected}" "but got" "${actual_without_colors}" + return + fi + + state::add_assertions_passed } function assert_empty() { local expected="1ドル" - local label="${2:-$(helper::normalize_test_function_name "${FUNCNAME[1]}")}" if [[ "$expected" != "" ]]; then + local label + label="$(helper::normalize_test_function_name "${FUNCNAME[1]}")" state::add_assertions_failed console_results::print_failed_test "${label}" "to be empty" "but got" "${expected}" return @@ -40,9 +59,10 @@ function assert_empty() { function assert_not_empty() { local expected="1ドル" - local label="${2:-$(helper::normalize_test_function_name "${FUNCNAME[1]}")}" if [[ "$expected" == "" ]]; then + local label + label="$(helper::normalize_test_function_name "${FUNCNAME[1]}")" state::add_assertions_failed console_results::print_failed_test "${label}" "to not be empty" "but got" "${expected}" return @@ -54,9 +74,10 @@ function assert_not_empty() { function assert_not_equals() { local expected="1ドル" local actual="2ドル" - local label="${3:-$(helper::normalize_test_function_name "${FUNCNAME[1]}")}" if [[ "$expected" == "$actual" ]]; then + local label + label="$(helper::normalize_test_function_name "${FUNCNAME[1]}")" state::add_assertions_failed console_results::print_failed_test "${label}" "${expected}" "but got" "${actual}" return @@ -67,10 +88,13 @@ function assert_not_equals() { function assert_contains() { local expected="1ドル" - local actual="2ドル" - local label="${3:-$(helper::normalize_test_function_name "${FUNCNAME[1]}")}" + local actual_arr=("${@:2}") + local actual + actual=$(printf '%s\n' "${actual_arr[@]}") if ! [[ $actual == *"$expected"* ]]; then + local label + label="$(helper::normalize_test_function_name "${FUNCNAME[1]}")" state::add_assertions_failed console_results::print_failed_test "${label}" "${actual}" "to contain" "${expected}" return @@ -82,14 +106,14 @@ function assert_contains() { function assert_contains_ignore_case() { local expected="1ドル" local actual="2ドル" - local label="${3:-$(helper::normalize_test_function_name "${FUNCNAME[1]}")}" shopt -s nocasematch if ! [[ $actual =~ $expected ]]; then + local label + label="$(helper::normalize_test_function_name "${FUNCNAME[1]}")" state::add_assertions_failed console_results::print_failed_test "${label}" "${actual}" "to contain" "${expected}" - shopt -u nocasematch return fi @@ -100,10 +124,13 @@ function assert_contains_ignore_case() { function assert_not_contains() { local expected="1ドル" - local actual="2ドル" - local label="${3:-$(helper::normalize_test_function_name "${FUNCNAME[1]}")}" + local actual_arr=("${@:2}") + local actual + actual=$(printf '%s\n' "${actual_arr[@]}") if [[ $actual == *"$expected"* ]]; then + local label + label="$(helper::normalize_test_function_name "${FUNCNAME[1]}")" state::add_assertions_failed console_results::print_failed_test "${label}" "${actual}" "to not contain" "${expected}" return @@ -114,10 +141,13 @@ function assert_not_contains() { function assert_matches() { local expected="1ドル" - local actual="2ドル" - local label="${3:-$(helper::normalize_test_function_name "${FUNCNAME[1]}")}" + local actual_arr=("${@:2}") + local actual + actual=$(printf '%s\n' "${actual_arr[@]}") if ! [[ $actual =~ $expected ]]; then + local label + label="$(helper::normalize_test_function_name "${FUNCNAME[1]}")" state::add_assertions_failed console_results::print_failed_test "${label}" "${actual}" "to match" "${expected}" return @@ -128,10 +158,13 @@ function assert_matches() { function assert_not_matches() { local expected="1ドル" - local actual="2ドル" - local label="${3:-$(helper::normalize_test_function_name "${FUNCNAME[1]}")}" + local actual_arr=("${@:2}") + local actual + actual=$(printf '%s\n' "${actual_arr[@]}") if [[ $actual =~ $expected ]]; then + local label + label="$(helper::normalize_test_function_name "${FUNCNAME[1]}")" state::add_assertions_failed console_results::print_failed_test "${label}" "${actual}" "to not match" "${expected}" return @@ -143,9 +176,10 @@ function assert_not_matches() { function assert_exit_code() { local actual_exit_code=${3-"$?"} local expected_exit_code="1ドル" - local label="${2:-$(helper::normalize_test_function_name "${FUNCNAME[1]}")}" if [[ "$actual_exit_code" -ne "$expected_exit_code" ]]; then + local label + label="$(helper::normalize_test_function_name "${FUNCNAME[1]}")" state::add_assertions_failed console_results::print_failed_test "${label}" "${actual_exit_code}" "to be" "${expected_exit_code}" return @@ -157,9 +191,10 @@ function assert_exit_code() { function assert_successful_code() { local actual_exit_code=${3-"$?"} local expected_exit_code=0 - local label="${2:-$(helper::normalize_test_function_name "${FUNCNAME[1]}")}" if [[ "$actual_exit_code" -ne "$expected_exit_code" ]]; then + local label + label="$(helper::normalize_test_function_name "${FUNCNAME[1]}")" state::add_assertions_failed console_results::print_failed_test "${label}" "${actual_exit_code}" "to be exactly" "${expected_exit_code}" return @@ -171,9 +206,10 @@ function assert_successful_code() { function assert_general_error() { local actual_exit_code=${3-"$?"} local expected_exit_code=1 - local label="${2:-$(helper::normalize_test_function_name "${FUNCNAME[1]}")}" if [[ $actual_exit_code -ne "$expected_exit_code" ]]; then + local label + label="$(helper::normalize_test_function_name "${FUNCNAME[1]}")" state::add_assertions_failed console_results::print_failed_test "${label}" "${actual_exit_code}" "to be exactly" "${expected_exit_code}" return @@ -185,9 +221,10 @@ function assert_general_error() { function assert_command_not_found() { local actual_exit_code=${3-"$?"} local expected_exit_code=127 - local label="${2:-$(helper::normalize_test_function_name "${FUNCNAME[1]}")}" if [[ $actual_exit_code -ne "$expected_exit_code" ]]; then + local label + label="$(helper::normalize_test_function_name "${FUNCNAME[1]}")" state::add_assertions_failed console_results::print_failed_test "${label}" "${actual_exit_code}" "to be exactly" "${expected_exit_code}" return @@ -198,10 +235,13 @@ function assert_command_not_found() { function assert_string_starts_with() { local expected="1ドル" - local actual="2ドル" - local label="${3:-$(helper::normalize_test_function_name "${FUNCNAME[1]}")}" + local actual_arr=("${@:2}") + local actual + actual=$(printf '%s\n' "${actual_arr[@]}") if ! [[ $actual =~ ^"$expected"* ]]; then + local label + label="$(helper::normalize_test_function_name "${FUNCNAME[1]}")" state::add_assertions_failed console_results::print_failed_test "${label}" "${actual}" "to start with" "${expected}" return @@ -213,9 +253,10 @@ function assert_string_starts_with() { function assert_string_not_starts_with() { local expected="1ドル" local actual="2ドル" - local label="${3:-$(helper::normalize_test_function_name "${FUNCNAME[1]}")}" if [[ $actual =~ ^"$expected"* ]]; then + local label + label="$(helper::normalize_test_function_name "${FUNCNAME[1]}")" state::add_assertions_failed console_results::print_failed_test "${label}" "${actual}" "to not start with" "${expected}" return @@ -226,10 +267,13 @@ function assert_string_not_starts_with() { function assert_string_ends_with() { local expected="1ドル" - local actual="2ドル" - local label="${3:-$(helper::normalize_test_function_name "${FUNCNAME[1]}")}" + local actual_arr=("${@:2}") + local actual + actual=$(printf '%s\n' "${actual_arr[@]}") if ! [[ $actual =~ .*"$expected"$ ]]; then + local label + label="$(helper::normalize_test_function_name "${FUNCNAME[1]}")" state::add_assertions_failed console_results::print_failed_test "${label}" "${actual}" "to end with" "${expected}" return @@ -240,10 +284,13 @@ function assert_string_ends_with() { function assert_string_not_ends_with() { local expected="1ドル" - local actual="2ドル" - local label="${3:-$(helper::normalize_test_function_name "${FUNCNAME[1]}")}" + local actual_arr=("${@:2}") + local actual + actual=$(printf '%s\n' "${actual_arr[@]}") if [[ $actual =~ .*"$expected"$ ]]; then + local label + label="$(helper::normalize_test_function_name "${FUNCNAME[1]}")" state::add_assertions_failed console_results::print_failed_test "${label}" "${actual}" "to not end with" "${expected}" return @@ -255,9 +302,10 @@ function assert_string_not_ends_with() { function assert_less_than() { local expected="1ドル" local actual="2ドル" - local label="${3:-$(helper::normalize_test_function_name "${FUNCNAME[1]}")}" if ! [[ "$actual" -lt "$expected" ]]; then + local label + label="$(helper::normalize_test_function_name "${FUNCNAME[1]}")" state::add_assertions_failed console_results::print_failed_test "${label}" "${actual}" "to be less than" "${expected}" return @@ -269,9 +317,10 @@ function assert_less_than() { function assert_less_or_equal_than() { local expected="1ドル" local actual="2ドル" - local label="${3:-$(helper::normalize_test_function_name "${FUNCNAME[1]}")}" if ! [[ "$actual" -le "$expected" ]]; then + local label + label="$(helper::normalize_test_function_name "${FUNCNAME[1]}")" state::add_assertions_failed console_results::print_failed_test "${label}" "${actual}" "to be less or equal than" "${expected}" return @@ -283,9 +332,10 @@ function assert_less_or_equal_than() { function assert_greater_than() { local expected="1ドル" local actual="2ドル" - local label="${3:-$(helper::normalize_test_function_name "${FUNCNAME[1]}")}" if ! [[ "$actual" -gt "$expected" ]]; then + local label + label="$(helper::normalize_test_function_name "${FUNCNAME[1]}")" state::add_assertions_failed console_results::print_failed_test "${label}" "${actual}" "to be greater than" "${expected}" return @@ -297,9 +347,10 @@ function assert_greater_than() { function assert_greater_or_equal_than() { local expected="1ドル" local actual="2ドル" - local label="${3:-$(helper::normalize_test_function_name "${FUNCNAME[1]}")}" if ! [[ "$actual" -ge "$expected" ]]; then + local label + label="$(helper::normalize_test_function_name "${FUNCNAME[1]}")" state::add_assertions_failed console_results::print_failed_test "${label}" "${actual}" "to be greater or equal than" "${expected}" return @@ -307,7 +358,37 @@ function assert_greater_or_equal_than() { state::add_assertions_passed } -#!/bin/bash + +function assert_line_count() { + local expected="1ドル" + local input_arr=("${@:2}") + local input_str + input_str=$(printf '%s\n' "${input_arr[@]}") + + if [ -z "$input_str" ]; then + local actual=0 + else + local actual + actual=$(echo "$input_str" | wc -l | tr -d '[:blank:]') + additional_new_lines=$(grep -o '\\n' <<< "$input_str" | wc -l | tr -d '[:blank:]') + ((actual+=additional_new_lines)) + fi + + if [[ "$expected" != "$actual" ]]; then + local label + label="$(helper::normalize_test_function_name "${FUNCNAME[1]}")" + + state::add_assertions_failed + console_results::print_failed_test "${label}" "${input_str}"\ + "to contain number of lines equal to" "${expected}"\ + "but found" "${actual}" + return + fi + + state::add_assertions_passed +} + +# src/assert_arrays.sh function assert_array_contains() { local expected="1ドル" @@ -340,7 +421,8 @@ function assert_array_not_contains() { state::add_assertions_passed } -#!/bin/bash + +# src/assert_files.sh function assert_file_exists() { local expected="1ドル" @@ -393,7 +475,8 @@ function assert_is_file_empty() { state::add_assertions_passed } -#!/bin/bash + +# src/assert_folders.sh function assert_directory_exists() { local expected="1ドル" @@ -511,7 +594,8 @@ function assert_is_directory_not_writable() { state::add_assertions_passed } -#!/bin/bash + +# src/assert_snapshot.sh function assert_match_snapshot() { local actual @@ -549,9 +633,33 @@ function assert_match_snapshot() { state::add_assertions_passed } -#!/bin/bash -#!/bin/bash +# src/assertions.sh + + +# src/bashunit.sh + +# This file provides a facade to developers who wants +# to interact with the internals of bashunit. +# e.g. adding custom assertions + +function bashunit::assertion_failed() { + local expected=1ドル + local actual=2ドル + local failure_condition_message=${3:-"but got"} + + local label + label="$(helper::normalize_test_function_name "${FUNCNAME[1]}")" + state::add_assertions_failed + console_results::print_failed_test "${label}" "${expected}" \ + "$failure_condition_message" "${actual}" +} + +function bashunit::assertion_passed() { + state::add_assertions_passed +} + +# src/check_os.sh # shellcheck disable=SC2034 _OS="Unknown" @@ -563,23 +671,65 @@ elif [[ "$(uname)" == "Darwin" ]]; then elif [[ $(uname) == *"MINGW"* ]]; then _OS="Windows" fi -#!/bin/bash -# shellcheck disable=SC2034 -_COLOR_DEFAULT=$'\e[0m' -_COLOR_BOLD=$'\e[1m' -_COLOR_FAINT=$'\e[2m' -_COLOR_FAILED=$'\e[31m' -_COLOR_PASSED=$'\e[32m' -_COLOR_SKIPPED=$'\e[33m' -_COLOR_INCOMPLETE=$'\e[36m' -_COLOR_SNAPSHOT=$'\e[34m' -_COLOR_RETURN_ERROR=$'\e[41m' -_COLOR_RETURN_SUCCESS=$'\e[42m' -_COLOR_RETURN_SKIPPED=$'\e[43m' -_COLOR_RETURN_INCOMPLETE=$'\e[46m' -_COLOR_RETURN_SNAPSHOT=$'\e[44m' -#!/bin/bash +# src/clock.sh + +function clock::now() { + if perl --version> /dev/null 2>&1; then + perl -MTime::HiRes -e 'printf("%.0f\n",Time::HiRes::time()*1000)' + elif [[ "$_OS" != "OSX" ]]; then + date +%s%N + else + echo "" + fi +} + +_START_TIME=$(clock::now) + +function clock::runtime_in_milliseconds() { + end_time=$(clock::now) + if [[ -n $end_time ]]; then + echo $(( end_time - _START_TIME )) + else + echo "" + fi +} + +# src/colors.sh + +# Pass in any number of ANSI SGR codes. +# +# Code reference: +# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters +# Credit: +# https://superuser.com/a/1119396 +sgr() { + local codes=${1:-0} + shift + + for c in "$@"; do + codes="$codes;$c" + done + + echo $'\e'"[${codes}m" +} + +_COLOR_BOLD="$(sgr 1)" +_COLOR_FAINT="$(sgr 2)" +_COLOR_BLACK="$(sgr 30)" +_COLOR_FAILED="$(sgr 31)" +_COLOR_PASSED="$(sgr 32)" +_COLOR_SKIPPED="$(sgr 33)" +_COLOR_INCOMPLETE="$(sgr 36)" +_COLOR_SNAPSHOT="$(sgr 34)" +_COLOR_RETURN_ERROR="$(sgr 41)$_COLOR_BLACK$_COLOR_BOLD" +_COLOR_RETURN_SUCCESS="$(sgr 42)$_COLOR_BLACK$_COLOR_BOLD" +_COLOR_RETURN_SKIPPED="$(sgr 43)$_COLOR_BLACK$_COLOR_BOLD" +_COLOR_RETURN_INCOMPLETE="$(sgr 46)$_COLOR_BLACK$_COLOR_BOLD" +_COLOR_RETURN_SNAPSHOT="$(sgr 44)$_COLOR_BLACK$_COLOR_BOLD" +_COLOR_DEFAULT="$(sgr 0)" + +# src/console_header.sh function console_header::print_version() { if [[ $HEADER_ASCII_ART == true ]]; then @@ -614,30 +764,45 @@ Arguments: If you use wildcards, bashunit will run any tests it finds. Options: - -f|--filer + -a|--assert + Run a core assert function standalone without a test context. + + --debug + Print all executed shell commands to the terminal. + + -e|--env + Load a custom env file overriding the .env environment variables. + + -f|--filter Filters the tests to run based on the test name. + -l|--log-junit + Create a report JUnit XML file that contains information about the test results. + + -r|--report-html + Create a report HTML file that contains information about the test results. + -s|simple || -v|verbose Enables simplified or verbose output to the console. -S|--stop-on-failure Force to stop the runner right after encountering one failing test. - -e|--env - Load a custom env file overriding the .env environment variables. - --version Displays the current version of bashunit. + --upgrade + Upgrade to latest version of bashunit. + --help This message. See more: https://bashunit.typeddevs.com/command-line EOF } -#!/bin/bash -_START_TIME=$(date +%s%N); +# src/console_results.sh + _SUCCESSFUL_TEST_COUNT=0 function console_results::render_result() { @@ -646,24 +811,24 @@ function console_results::render_result() { printf "%s%s%s\n" "${_COLOR_RETURN_ERROR}" "Duplicate test functions found" "${_COLOR_DEFAULT}" printf "File with duplicate functions: %s\n" "$(state::get_file_with_duplicated_function_names)" printf "Duplicate functions: %s\n" "$(state::get_duplicated_function_names)" - exit 1 + return 1 fi echo "" local total_tests=0 - ((total_tests+=$(state::get_tests_passed))) - ((total_tests+=$(state::get_tests_skipped))) - ((total_tests+=$(state::get_tests_incomplete))) - ((total_tests+=$(state::get_tests_snapshot))) - ((total_tests+=$(state::get_tests_failed))) + ((total_tests += $(state::get_tests_passed))) || true + ((total_tests += $(state::get_tests_skipped))) || true + ((total_tests += $(state::get_tests_incomplete))) || true + ((total_tests += $(state::get_tests_snapshot))) || true + ((total_tests += $(state::get_tests_failed))) || true local total_assertions=0 - ((total_assertions+=$(state::get_assertions_passed))) - ((total_assertions+=$(state::get_assertions_skipped))) - ((total_assertions+=$(state::get_assertions_incomplete))) - ((total_assertions+=$(state::get_assertions_snapshot))) - ((total_assertions+=$(state::get_assertions_failed))) + ((total_assertions += $(state::get_assertions_passed))) || true + ((total_assertions += $(state::get_assertions_skipped))) || true + ((total_assertions += $(state::get_assertions_incomplete))) || true + ((total_assertions += $(state::get_assertions_snapshot))) || true + ((total_assertions += $(state::get_assertions_failed))) || true printf "%sTests: %s" "$_COLOR_FAINT" "$_COLOR_DEFAULT" if [[ "$(state::get_tests_passed)" -gt 0 ]] || [[ "$(state::get_assertions_passed)" -gt 0 ]]; then @@ -702,38 +867,38 @@ function console_results::render_result() { printf " %s total\n" "$total_assertions" if [[ "$(state::get_tests_failed)" -gt 0 ]]; then - printf "%s%s%s\n" "$_COLOR_RETURN_ERROR" "Some tests failed" "$_COLOR_DEFAULT" + printf "\n%s%s%s\n" "$_COLOR_RETURN_ERROR" " Some tests failed " "$_COLOR_DEFAULT" console_results::print_execution_time - exit 1 + return 1 fi if [[ "$(state::get_tests_incomplete)" -gt 0 ]]; then - printf "%s%s%s\n" "$_COLOR_RETURN_INCOMPLETE" "Some tests incomplete" "$_COLOR_DEFAULT" + printf "\n%s%s%s\n" "$_COLOR_RETURN_INCOMPLETE" " Some tests incomplete " "$_COLOR_DEFAULT" console_results::print_execution_time - exit 0 + return 0 fi if [[ "$(state::get_tests_skipped)" -gt 0 ]]; then - printf "%s%s%s\n" "$_COLOR_RETURN_SKIPPED" "Some tests skipped" "$_COLOR_DEFAULT" + printf "\n%s%s%s\n" "$_COLOR_RETURN_SKIPPED" " Some tests skipped " "$_COLOR_DEFAULT" console_results::print_execution_time - exit 0 + return 0 fi if [[ "$(state::get_tests_snapshot)" -gt 0 ]]; then - printf "%s%s%s\n" "$_COLOR_RETURN_SNAPSHOT" "Some snapshots created" "$_COLOR_DEFAULT" + printf "\n%s%s%s\n" "$_COLOR_RETURN_SNAPSHOT" " Some snapshots created " "$_COLOR_DEFAULT" console_results::print_execution_time - exit 0 + return 0 fi if [[ $total_tests -eq 0 ]]; then - printf "%s%s%s\n" "$_COLOR_RETURN_ERROR" "No tests found" "$_COLOR_DEFAULT" + printf "\n%s%s%s\n" "$_COLOR_RETURN_ERROR" " No tests found " "$_COLOR_DEFAULT" console_results::print_execution_time - exit 1 + return 1 fi - printf "%s%s%s\n" "$_COLOR_RETURN_SUCCESS" "All tests passed" "$_COLOR_DEFAULT" + printf "\n%s%s%s\n" "$_COLOR_RETURN_SUCCESS" " All tests passed " "$_COLOR_DEFAULT" console_results::print_execution_time - exit 0 + return 0 } function console_results::print_execution_time() { @@ -741,14 +906,12 @@ function console_results::print_execution_time() { return fi - if [[ "$_OS" != "OSX" ]]; then - _EXECUTION_TIME=$((($(date +%s%N) - "$_START_TIME") / 1000000)) - printf "${_COLOR_BOLD}%s${_COLOR_DEFAULT}\n" "Time taken: ${_EXECUTION_TIME} ms" - fi + _EXECUTION_TIME=$(clock::runtime_in_milliseconds) + printf "${_COLOR_BOLD}%s${_COLOR_DEFAULT}\n" "Time taken: ${_EXECUTION_TIME} ms" } function console_results::print_successful_test() { - ((_SUCCESSFUL_TEST_COUNT++)) + ((_SUCCESSFUL_TEST_COUNT++)) || true if [[ "$SIMPLE_OUTPUT" == true ]]; then if (( _SUCCESSFUL_TEST_COUNT % 50 != 0 )); then @@ -758,27 +921,45 @@ function console_results::print_successful_test() { fi else local test_name=1ドル - local data=2ドル + shift - if [[ -z "$data" ]]; then + if [[ -z "$*" ]]; then printf "%s✓ Passed%s: %s\n" "$_COLOR_PASSED" "$_COLOR_DEFAULT" "${test_name}" else - printf "%s✓ Passed%s: %s (%s)\n" "$_COLOR_PASSED" "$_COLOR_DEFAULT" "${test_name}" "${data}" + printf "%s✓ Passed%s: %s (%s)\n" "$_COLOR_PASSED" "$_COLOR_DEFAULT" "${test_name}" "$*" fi fi } +function console_results::print_failure_message() { + local test_name=1ドル + local failure_message=2ドル + + printf "\ +${_COLOR_FAILED}✗ Failed${_COLOR_DEFAULT}: %s + ${_COLOR_FAINT}Message:${_COLOR_DEFAULT} ${_COLOR_BOLD}'%s'${_COLOR_DEFAULT}\n"\ + "${test_name}" "${failure_message}" +} + function console_results::print_failed_test() { local test_name=1ドル local expected=2ドル local failure_condition_message=3ドル local actual=4ドル + local extra_key=${5-} + local extra_value=${6-} printf "\ ${_COLOR_FAILED}✗ Failed${_COLOR_DEFAULT}: %s ${_COLOR_FAINT}Expected${_COLOR_DEFAULT} ${_COLOR_BOLD}'%s'${_COLOR_DEFAULT} ${_COLOR_FAINT}%s${_COLOR_DEFAULT} ${_COLOR_BOLD}'%s'${_COLOR_DEFAULT}\n"\ "${test_name}" "${expected}" "${failure_condition_message}" "${actual}" + + if [ -n "$extra_key" ]; then + printf "\ + ${_COLOR_FAINT}%s${_COLOR_DEFAULT} ${_COLOR_BOLD}'%s'${_COLOR_DEFAULT}\n"\ + "${extra_key}" "${extra_value}" + fi } function console_results::print_failed_snapshot_test() { @@ -800,7 +981,7 @@ function console_results::print_failed_snapshot_test() { function console_results::print_skipped_test() { local test_name=1ドル - local reason=2ドル + local reason=${2-} printf "${_COLOR_SKIPPED}↷ Skipped${_COLOR_DEFAULT}: %s\n" "${test_name}" @@ -811,7 +992,7 @@ function console_results::print_skipped_test() { function console_results::print_incomplete_test() { local test_name=1ドル - local pending=2ドル + local pending=${2-} printf "${_COLOR_INCOMPLETE}✒ Incomplete${_COLOR_DEFAULT}: %s\n" "${test_name}" @@ -835,7 +1016,8 @@ function console_results::print_error_test() { printf "${_COLOR_FAILED}✗ Failed${_COLOR_DEFAULT}: %s ${_COLOR_FAINT}%s${_COLOR_DEFAULT}\n" "${test_name}" "${error}" } -#!/bin/bash + +# src/default_env_config.sh # shellcheck disable=SC2034 _DEFAULT_PARALLEL_RUN=false @@ -845,8 +1027,11 @@ _DEFAULT_SIMPLE_OUTPUT=false _DEFAULT_STOP_ON_FAILURE=false _DEFAULT_SHOW_EXECUTION_TIME=true _DEFAULT_DEFAULT_PATH= +_DEFAULT_LOG_JUNIT= +_DEFAULT_REPORT_HTML= CAT="$(which cat)" -#!/bin/bash + +# src/deprecated_assert.sh # Deprecated: Please use assert_equals instead. function assertEquals() { @@ -945,41 +1130,27 @@ function assertArrayContains() { function assertArrayNotContains() { assert_array_not_contains "1ドル" "${@:1}" } -#!/bin/bash + +# src/env_configuration.sh set -o allexport # shellcheck source=/dev/null [[ -f ".env" ]] && source .env set set +o allexport -if [[ -z "$PARALLEL_RUN" ]]; then - PARALLEL_RUN=$_DEFAULT_PARALLEL_RUN -fi - -if [[ -z "$SHOW_HEADER" ]]; then - SHOW_HEADER=$_DEFAULT_SHOW_HEADER -fi - -if [[ -z "$HEADER_ASCII_ART" ]]; then - HEADER_ASCII_ART=$_DEFAULT_HEADER_ASCII_ART -fi - -if [[ -z "$SIMPLE_OUTPUT" ]]; then - SIMPLE_OUTPUT=$_DEFAULT_SIMPLE_OUTPUT -fi +: "${PARALLEL_RUN:=$_DEFAULT_PARALLEL_RUN}" +: "${SHOW_HEADER:=$_DEFAULT_SHOW_HEADER}" +: "${HEADER_ASCII_ART:=$_DEFAULT_HEADER_ASCII_ART}" +: "${SIMPLE_OUTPUT:=$_DEFAULT_SIMPLE_OUTPUT}" +: "${STOP_ON_FAILURE:=$_DEFAULT_STOP_ON_FAILURE}" +: "${SHOW_EXECUTION_TIME:=$_DEFAULT_SHOW_EXECUTION_TIME}" +: "${DEFAULT_PATH:=$_DEFAULT_DEFAULT_PATH}" +: "${LOG_JUNIT:=$_DEFAULT_LOG_JUNIT}" +: "${REPORT_HTML:=$_DEFAULT_REPORT_HTML}" -if [[ -z "$STOP_ON_FAILURE" ]]; then - STOP_ON_FAILURE=$_DEFAULT_STOP_ON_FAILURE -fi - -if [[ -z "$SHOW_EXECUTION_TIME" ]]; then - SHOW_EXECUTION_TIME=$_DEFAULT_SHOW_EXECUTION_TIME -fi +# src/helpers.sh -if [[ -z "$DEFAULT_PATH" ]]; then - DEFAULT_PATH=$_DEFAULT_DEFAULT_PATH -fi -#!/bin/bash +declare -r BASHUNIT_GIT_REPO="https://github.com/TypedDevs/bashunit" # # @param 1ドル string Eg: "test_some_logic_camelCase" @@ -987,7 +1158,7 @@ fi # @return string Eg: "Some logic camelCase" # function helper::normalize_test_function_name() { - local original_function_name="1ドル" + local original_function_name="${1-}" local result # Remove "test_" prefix @@ -1034,40 +1205,26 @@ function helper::get_functions_to_run() { local filter=2ドル local function_names=3ドル - local functions_to_run=() + local filtered_functions="" - for function_name in $function_names; do - if [[ $function_name != ${prefix}* ]]; then - continue - fi - - local lower_case_function_name - lower_case_function_name=$(echo "$function_name" | tr '[:upper:]' '[:lower:]') - local lower_case_filter - lower_case_filter=$(echo "$filter" | tr '[:upper:]' '[:lower:]') - - if [[ -n $filter && $lower_case_function_name != *"$lower_case_filter"* ]]; then - continue - fi - - if [[ "${functions_to_run[*]}" =~ ${function_name} ]]; then - return 1 + for fn in $function_names; do + if [[ $fn == ${prefix}_${filter}* ]]; then + if [[ $filtered_functions == *" $fn"* ]]; then + return 1 + fi + filtered_functions+=" $fn" fi - - functions_to_run+=("$function_name") done - echo "${functions_to_run[@]}" + echo "${filtered_functions# }" } # # @param 1ドル string Eg: "do_something" # function helper::execute_function_if_exists() { - local function_name=1ドル - - if declare -F | awk '{print 3ドル}' | grep -Eq "^${function_name}$"; then - "$function_name" + if [[ "$(type -t "1ドル")" == "function" ]]; then + "1ドル" 2>/dev/null fi } @@ -1075,11 +1232,7 @@ function helper::execute_function_if_exists() { # @param 1ドル string Eg: "do_something" # function helper::unset_if_exists() { - local function_name=1ドル - - if declare -F | awk '{print 3ドル}' | grep -Eq "^${function_name}$"; then - unset "$function_name" - fi + unset "1ドル" 2>/dev/null } function helper::find_files_recursive() { @@ -1120,6 +1273,7 @@ function helper::get_provider_data() { grep -B 1 "function $function_name()" "$script" |\ grep "# data_provider " |\ sed -E -e 's/\ *# data_provider (.*)$/1円/g'\ + || true ) if [[ -n "$data_provider_function" ]]; then @@ -1127,16 +1281,287 @@ function helper::get_provider_data() { fi } +function helper::get_multi_invoker_function() { + local function_name="1ドル" + local script="2ドル" + local multi_invoker_function + + if [[ ! -f "$script" ]]; then + return + fi + + multi_invoker_function=$(\ + grep -B 1 "function $function_name()" "$script" |\ + grep "# multi_invoker " |\ + sed -E -e 's/\ *# multi_invoker (.*)$/1円/g'\ + ) + func_exists=$(declare -f "$multi_invoker_function") + if [[ -n "$func_exists" ]]; then + echo "$multi_invoker_function" + fi +} + function helper::trim() { - local input_string="1ドル" - local trimmed_string + local input_string="1ドル" + local trimmed_string - trimmed_string="${input_string#"${input_string%%[![:space:]]*}"}" - trimmed_string="${trimmed_string%"${trimmed_string##*[![:space:]]}"}" + trimmed_string="${input_string#"${input_string%%[![:space:]]*}"}" + trimmed_string="${trimmed_string%"${trimmed_string##*[![:space:]]}"}" - echo "$trimmed_string" + echo "$trimmed_string" +} + +function helpers::get_latest_tag() { + git ls-remote --tags "$BASHUNIT_GIT_REPO" | + awk '{print 2ドル}' | + sed 's|^refs/tags/||' | + sort -Vr | + head -n 1 +} + +# src/logger.sh + +TEST_NAMES=() +TEST_STATUSES=() +TEST_DURATIONS=() + +function logger::test_snapshot() { + logger::log "1ドル" "2ドル" "3ドル" "snapshot" +} + +function logger::test_incomplete() { + logger::log "1ドル" "2ドル" "3ドル" "incomplete" +} + +function logger::test_skipped() { + logger::log "1ドル" "2ドル" "3ドル" "skipped" +} + +function logger::test_passed() { + logger::log "1ドル" "2ドル" "3ドル" "passed" +} + +function logger::test_failed() { + logger::log "1ドル" "2ドル" "3ドル" "failed" +} + +function logger::log() { + local file="1ドル" + local test_name="2ドル" + local start_time="3ドル" + local status="4ドル" + + local end_time + end_time=$(clock::now) + local duration=$((end_time - start_time)) + + TEST_FILES+=("$file") + TEST_NAMES+=("$test_name") + TEST_STATUSES+=("$status") + TEST_DURATIONS+=("$duration") +} + +function logger::generate_junit_xml() { + local output_file="1ドル" + local test_passed + test_passed=$(state::get_tests_passed) + local tests_skipped + tests_skipped=$(state::get_tests_skipped) + local tests_incomplete + tests_incomplete=$(state::get_tests_incomplete) + local tests_snapshot + tests_snapshot=$(state::get_tests_snapshot) + local tests_failed + tests_failed=$(state::get_tests_failed) + local time + time=$(clock::runtime_in_milliseconds) + + { + echo "" + echo "" + echo " " + + for i in "${!TEST_NAMES[@]}"; do + local file="${TEST_FILES[$i]}" + local name="${TEST_NAMES[$i]}" + local status="${TEST_STATUSES[$i]}" + local test_time="${TEST_DURATIONS[$i]}" + + echo " " + echo " " + done + + echo " " + echo "" + }> "$output_file" +} + +function logger::generate_report_html() { + local output_file="1ドル" + local test_passed + test_passed=$(state::get_tests_passed) + local tests_skipped + tests_skipped=$(state::get_tests_skipped) + local tests_incomplete + tests_incomplete=$(state::get_tests_incomplete) + local tests_snapshot + tests_snapshot=$(state::get_tests_snapshot) + local tests_failed + tests_failed=$(state::get_tests_failed) + local time + time=$(clock::runtime_in_milliseconds) + + # Temporary file to store test cases by file + local temp_file="temp_test_cases.txt" + + # Collect test cases by file + :> "$temp_file" # Clear temp file if it exists + for i in "${!TEST_NAMES[@]}"; do + local file="${TEST_FILES[$i]}" + local name="${TEST_NAMES[$i]}" + local status="${TEST_STATUSES[$i]}" + local test_time="${TEST_DURATIONS[$i]}" + local test_case="$file|$name|$status|$test_time" + + echo "$test_case">> "$temp_file" + done + + { + echo "" + echo "" + echo " " + echo " " + echo " " + echo " Test Report" + echo " " + echo "" + echo "
" + echo "

Test Report

" + echo " " + echo " " + echo " " + echo " " + echo " " + echo " " + echo " " + echo " " + echo " " + echo " " + echo " " + echo " " + echo " " + echo " " + echo " " + echo " " + echo " " + echo " " + echo " " + echo " " + echo " " + echo " " + echo " " + echo "
Total TestsPassedFailedIncompleteSkippedSnapshotTime (ms)
${#TEST_NAMES[@]}$test_passed$tests_failed$tests_incomplete$tests_skipped$tests_snapshot${time}
" + echo "

Time: $time ms

" + + # Read the temporary file and group by file + local current_file="" + while IFS='|' read -r file name status test_time; do + if [ "$file" != "$current_file" ]; then + if [ -n "$current_file" ]; then + echo " " + echo " " + fi + echo "

File: $file

" + echo " " + echo " " + echo " " + echo " " + echo " " + echo " " + echo " " + echo " " + echo " " + current_file="$file" + fi + echo " " + echo " " + echo " " + echo " " + echo " " + done < "$temp_file" + + # Close the last table + if [ -n "$current_file" ]; then + echo " " + echo "
Test NameStatusTime (ms)
$name$status$test_time
" + fi + + echo "

AltStyle によって変換されたページ (->オリジナル) /

" + echo "" + }> "$output_file" + + # Clean up temporary file + rm -f "$temp_file" } -#!/bin/bash + +# src/main.sh + +function main::exec_tests() { + local filter=1ドル + local files=("${@:2}") + + console_header::print_version_with_env + runner::load_test_files "$filter" "${files[@]}" + console_results::render_result + exit_code=$? + + if [[ -n "$LOG_JUNIT" ]]; then + logger::generate_junit_xml "$LOG_JUNIT" + fi + + if [[ -n "$REPORT_HTML" ]]; then + logger::generate_report_html "$REPORT_HTML" + fi + + exit $exit_code +} + +function main::exec_assert() { + local original_assert_fn=1ドル + local assert_fn=$original_assert_fn + local args=("${@:2}") + + if ! type "$assert_fn"> /dev/null 2>&1; then + # try again using prefix `assert_` + assert_fn="assert_$assert_fn" + if ! type "$assert_fn"> /dev/null 2>&1; then + echo "Function $original_assert_fn does not exist." + exit 127 + fi + fi + + "$assert_fn" "${args[@]}" + + if [[ "$(state::get_tests_failed)" -gt 0 ]] || [[ "$(state::get_assertions_failed)" -gt 0 ]]; then + exit 1 + fi +} + +# src/runner.sh function runner::load_test_files() { local filter=1ドル @@ -1172,23 +1597,44 @@ function runner::load_test_files() { done } +function runner::functions_for_script() { + local script="1ドル" + local all_function_names="2ドル" + + # Filter the names down to the ones defined in the script, sort them by line number + shopt -s extdebug + for f in $all_function_names; do + declare -F "$f" | grep "$script" + done | sort -k2 -n | awk '{print 1ドル}' + shopt -u extdebug +} + +# Helper function for test authors to invoke a named test case +function run_test() { + runner::run_test "testing-fn" "$function_name" "$@" +} + function runner::call_test_functions() { local script="1ドル" local filter="2ドル" local prefix="test" # Use declare -F to list all function names - local function_names - function_names=$(declare -F | awk '{print 3ドル}') + local all_function_names + all_function_names=$(declare -F | awk '{print 3ドル}') + local filtered_functions + # shellcheck disable=SC2207 + filtered_functions=$(helper::get_functions_to_run "$prefix" "$filter" "$all_function_names") + local functions_to_run # shellcheck disable=SC2207 - functions_to_run=($(helper::get_functions_to_run "$prefix" "$filter" "$function_names")) + functions_to_run=($(runner::functions_for_script "$script" "$filtered_functions")) if [[ "${#functions_to_run[@]}" -gt 0 ]]; then if [[ "$SIMPLE_OUTPUT" == false ]]; then echo "Running $script" fi - helper::check_duplicate_functions "$script" + helper::check_duplicate_functions "$script" || true for function_name in "${functions_to_run[@]}"; do local provider_data=() @@ -1196,13 +1642,19 @@ function runner::call_test_functions() { if [[ "${#provider_data[@]}" -gt 0 ]]; then for data in "${provider_data[@]}"; do - runner::run_test "$function_name" "$data" + runner::run_test "$script" "$function_name" "$data" done else - runner::run_test "$function_name" + local multi_invoker + multi_invoker=$(helper::get_multi_invoker_function "$function_name" "$script") + if [[ -n "${multi_invoker}" ]]; then + helper::execute_function_if_exists "${multi_invoker}" + else + runner::run_test "$script" "$function_name" + fi fi - unset "$function_name" + unset function_name done fi } @@ -1245,16 +1697,21 @@ function runner::parse_execution_result() { sed -E -e 's/.*##ASSERTIONS_SNAPSHOT=([0-9]*)##.*/1円/g'\ ) - _ASSERTIONS_PASSED=$((_ASSERTIONS_PASSED + assertions_passed)) - _ASSERTIONS_FAILED=$((_ASSERTIONS_FAILED + assertions_failed)) - _ASSERTIONS_SKIPPED=$((_ASSERTIONS_SKIPPED + assertions_skipped)) - _ASSERTIONS_INCOMPLETE=$((_ASSERTIONS_INCOMPLETE + assertions_incomplete)) - _ASSERTIONS_SNAPSHOT=$((_ASSERTIONS_SNAPSHOT + assertions_snapshot)) + ((_ASSERTIONS_PASSED += assertions_passed)) || true + ((_ASSERTIONS_FAILED += assertions_failed)) || true + ((_ASSERTIONS_SKIPPED += assertions_skipped)) || true + ((_ASSERTIONS_INCOMPLETE += assertions_incomplete)) || true + ((_ASSERTIONS_SNAPSHOT += assertions_snapshot)) || true } function runner::run_test() { + local start_time + start_time=$(clock::now) + + local test_file="1ドル" + shift local function_name="1ドル" - local data="2ドル" + shift local current_assertions_failed current_assertions_failed="$(state::get_assertions_failed)" local current_assertions_snapshot @@ -1264,6 +1721,9 @@ function runner::run_test() { local current_assertions_skipped current_assertions_skipped="$(state::get_assertions_skipped)" + # (FD = File Descriptor) + # Duplicate the current std-output (FD 1) and assigns it to FD 3. + # This means that FD 3 now points to wherever the std-output was pointing. exec 3>&1 local test_execution_result @@ -1271,12 +1731,17 @@ function runner::run_test() { state::initialize_assertions_count runner::run_set_up - "$function_name" "$data" 2>&1 1>&3 + # 2>&1: Redirects the std-error (FD 2) to the std-output (FD 1). + # 1>&3: Redirects the std-output (FD 1) to FD 3, which, as set up earlier, + # points to the original std-output. + "$function_name" "$@" 2>&1 1>&3 runner::run_tear_down + runner::clear_mocks state::export_assertions_count ) + # Closes FD 3, which was used temporarily to hold the original std-output. exec 3>&- runner::parse_execution_result "$test_execution_result" @@ -1284,18 +1749,20 @@ function runner::run_test() { local runtime_error runtime_error=$(\ echo "$test_execution_result" |\ - head -n 1 |\ + tail -n 1 |\ sed -E -e 's/(.*)##ASSERTIONS_FAILED=.*/1円/g'\ ) if [[ -n $runtime_error ]]; then state::add_tests_failed console_results::print_error_test "$function_name" "$runtime_error" + logger::test_failed "$test_file" "$function_name" "$start_time" return fi if [[ "$current_assertions_failed" != "$(state::get_assertions_failed)" ]]; then state::add_tests_failed + logger::test_failed "$test_file" "$function_name" "$start_time" if [ "$STOP_ON_FAILURE" = true ]; then exit 1 @@ -1307,60 +1774,63 @@ function runner::run_test() { if [[ "$current_assertions_snapshot" != "$(state::get_assertions_snapshot)" ]]; then state::add_tests_snapshot console_results::print_snapshot_test "$function_name" + logger::test_snapshot "$test_file" "$function_name" "$start_time" return fi if [[ "$current_assertions_incomplete" != "$(state::get_assertions_incomplete)" ]]; then state::add_tests_incomplete + logger::test_incomplete "$test_file" "$function_name" "$start_time" return fi if [[ "$current_assertions_skipped" != "$(state::get_assertions_skipped)" ]]; then state::add_tests_skipped + logger::test_skipped "$test_file" "$function_name" "$start_time" return fi local label label="$(helper::normalize_test_function_name "$function_name")" - console_results::print_successful_test "${label}" "${data}" + console_results::print_successful_test "${label}" "$@" state::add_tests_passed + logger::test_passed "$test_file" "$function_name" "$start_time" } function runner::run_set_up() { - helper::execute_function_if_exists 'setUp' # Deprecated: please use set_up instead. helper::execute_function_if_exists 'set_up' } function runner::run_set_up_before_script() { - helper::execute_function_if_exists 'setUpBeforeScript' # Deprecated: please use set_up_before_script instead. helper::execute_function_if_exists 'set_up_before_script' } function runner::run_tear_down() { - helper::execute_function_if_exists 'tearDown' # Deprecated: please use tear_down instead. helper::execute_function_if_exists 'tear_down' } +function runner::clear_mocks() { + for i in "${!MOCKED_FUNCTIONS[@]}"; do + unmock "${MOCKED_FUNCTIONS[$i]}" + done +} + function runner::run_tear_down_after_script() { - helper::execute_function_if_exists 'tearDownAfterScript' # Deprecated: please use tear_down_after_script instead. helper::execute_function_if_exists 'tear_down_after_script' } function runner::clean_set_up_and_tear_down_after_script() { - helper::unset_if_exists 'setUp' # Deprecated: please use set_up instead. helper::unset_if_exists 'set_up' - helper::unset_if_exists 'tearDown' # Deprecated: please use tear_down instead. helper::unset_if_exists 'tear_down' - helper::unset_if_exists 'setUpBeforeScript' # Deprecated: please use set_up_before_script instead. helper::unset_if_exists 'set_up_before_script' - helper::unset_if_exists 'tearDownAfterScript' # Deprecated: please use tear_down_after_script instead. helper::unset_if_exists 'tear_down_after_script' } -#!/bin/bash + +# src/skip_todo.sh function skip() { - local reason=1ドル + local reason=${1-} local label label="$(helper::normalize_test_function_name "${FUNCNAME[1]}")" @@ -1370,7 +1840,7 @@ function skip() { } function todo() { - local pending=1ドル + local pending=${1-} local label label="$(helper::normalize_test_function_name "${FUNCNAME[1]}")" @@ -1378,7 +1848,8 @@ function todo() { state::add_assertions_incomplete } -#!/bin/bash + +# src/state.sh _TESTS_PASSED=0 _TESTS_FAILED=0 @@ -1521,7 +1992,22 @@ function state::export_assertions_count() { ##ASSERTIONS_SNAPSHOT=$_ASSERTIONS_SNAPSHOT\ ##" } -#!/bin/bash + +# src/test_doubles.sh + +declare -a MOCKED_FUNCTIONS=() + +function unmock() { + local command=1ドル + + for i in "${!MOCKED_FUNCTIONS[@]}"; do + if [[ "${MOCKED_FUNCTIONS[$i]}" == "$command" ]]; then + unset "MOCKED_FUNCTIONS[$i]" + unset -f "$command" + break + fi + done +} function mock() { local command=1ドル @@ -1534,6 +2020,8 @@ function mock() { fi export -f "${command?}" + + MOCKED_FUNCTIONS+=("$command") } function spy() { @@ -1547,6 +2035,8 @@ function spy() { eval "function $command() { ${variable}_params=(\"\$*\"); ((${variable}_times++)) || true; }" export -f "${command?}" + + MOCKED_FUNCTIONS+=("$command") } function assert_have_been_called() { @@ -1593,7 +2083,7 @@ function assert_have_been_called_times() { actual="${variable}_times" local label="${3:-$(helper::normalize_test_function_name "${FUNCNAME[1]}")}" - if [[ ${!actual} -ne $expected ]]; then + if [[ -z "${!actual-}" && $expected -ne 0 || ${!actual-0} -ne $expected ]]; then state::add_assertions_failed console_results::print_failed_test "${label}" "${command}" "to has been called" "${expected} times" return @@ -1601,40 +2091,70 @@ function assert_have_been_called_times() { state::add_assertions_passed } + +# src/upgrade.sh + +function upgrade::upgrade() { + local script_path + script_path="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + local latest_tag + latest_tag="$(helpers::get_latest_tag)" + + if [[ "$BASHUNIT_VERSION" == "$latest_tag" ]]; then + echo "> You are already on latest version" + return + fi + + echo "> Upgrading bashunit to latest version" + cd "$script_path" || exit + curl -L -J -o bashunit "https://github.com/TypedDevs/bashunit/releases/download/$latest_tag/bashunit" 2>/dev/null + chmod u+x "bashunit" + + echo "> bashunit upgraded successfully to latest version $latest_tag" +} + #!/bin/bash +set -euo pipefail # shellcheck disable=SC2034 -declare -r BASHUNIT_VERSION="0.10.1" +declare -r BASHUNIT_VERSION="0.14.0" -readonly BASHUNIT_ROOT_DIR="$(dirname "${BASH_SOURCE[0]}")" +# shellcheck disable=SC2155 +declare -r BASHUNIT_ROOT_DIR="$(dirname "${BASH_SOURCE[0]}")" export BASHUNIT_ROOT_DIR -############### -#### MAIN ##### -############### - +_ASSERT_FN="" _FILTER="" -_FILES=() +_ARGS=() while [[ $# -gt 0 ]]; do argument="1ドル" case $argument in + -a|--assert) + _ASSERT_FN="2ドル" + shift + shift + ;; -f|--filter) _FILTER="2ドル" shift shift ;; -s|--simple) - SIMPLE_OUTPUT=true + export SIMPLE_OUTPUT=true shift ;; -v|--verbose) - SIMPLE_OUTPUT=false + export SIMPLE_OUTPUT=false + shift + ;; + --debug) + set -x shift ;; -S|--stop-on-failure) - STOP_ON_FAILURE=true + export STOP_ON_FAILURE=true shift ;; -e|--env) @@ -1643,25 +2163,41 @@ while [[ $# -gt 0 ]]; do shift shift ;; + -l|--log-junit) + export LOG_JUNIT="2ドル"; + shift + shift + ;; + -r|--report-html) + export REPORT_HTML="2ドル"; + shift + shift + ;; --version) console_header::print_version trap '' EXIT && exit 0 ;; + --upgrade) + upgrade::upgrade + trap '' EXIT && exit 0 + ;; --help) console_header::print_help trap '' EXIT && exit 0 ;; *) while IFS='' read -r line; do - _FILES+=("$line"); + _ARGS+=("$line"); done < <(helper::find_files_recursive "$argument") shift ;; esac done -console_header::print_version_with_env -runner::load_test_files "$_FILTER" "${_FILES[@]}" -console_results::render_result +set +eu -exit 0 +if [[ -n "$_ASSERT_FN" ]]; then + main::exec_assert "$_ASSERT_FN" "${_ARGS[@]}" +else + main::exec_tests "$_FILTER" "${_ARGS[@]}" +fi From 80128cc7ae813cf40ad11c982535f30933ea4202 Mon Sep 17 00:00:00 2001 From: "Brayann W. F. Barbosa" Date: 2024年8月26日 11:55:41 -0300 Subject: [PATCH 119/130] feat: include script to uninstall phpctl (#45) --- docs/uninstall.sh | 51 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 docs/uninstall.sh diff --git a/docs/uninstall.sh b/docs/uninstall.sh new file mode 100644 index 0000000..ba40433 --- /dev/null +++ b/docs/uninstall.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +INSTALL_DIR=~/.phpctl +SYMLINK_DIR=/usr/local/bin + +LINKS=( + composer + composer-require-checker + co-phpunit + couscous + deptrac + exakat + frankenphp + infection + notty + pest + php + phpcbf + phpcs + php-cs-fixer + phpctl + phpmd + phpstan + phpunit + pint + rector + watchr +) + +# Removing symlink +echo "Removing symbolic links..." +for link in "${LINKS[@]}"; do + if [ -L "${SYMLINK_DIR}/${link}" ]; then + sudo rm "${SYMLINK_DIR}/${link}" + echo "Removed ${SYMLINK_DIR}/${link}" + else + echo "Link ${SYMLINK_DIR}/${link} does not exist, skipping." + fi +done + +# Opcional: removing directory +echo -e "\nDo you want to remove the installation directory (${INSTALL_DIR})? (Y/n) " +read -r answer +if [ "$answer" != "${answer#[Yy]}" ]; then + rm -rf "$INSTALL_DIR" + echo "Removed installation directory: ${INSTALL_DIR}" +else + echo "Skipping removal of installation directory." +fi + +echo "Uninstallation complete." \ No newline at end of file From 5cb16b3a2af6c9f0a2b82a4769431ddd87a74d82 Mon Sep 17 00:00:00 2001 From: leocavalcante Date: 2024年9月16日 12:57:34 -0300 Subject: [PATCH 120/130] chore(deps): Bump Swoole --- rootfs/usr/local/bin/install-swoole | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rootfs/usr/local/bin/install-swoole b/rootfs/usr/local/bin/install-swoole index 23db7ac..3017b47 100755 --- a/rootfs/usr/local/bin/install-swoole +++ b/rootfs/usr/local/bin/install-swoole @@ -1,7 +1,7 @@ #!/usr/bin/env sh set -e -SWOOLE_VERSION="5.1.2" +SWOOLE_VERSION="5.1.4" echo "Installing Swoole $SWOOLE_VERSION" # Download From 8be29179a74ac62138c6c28084e082624abe2ec9 Mon Sep 17 00:00:00 2001 From: leocavalcante Date: 2024年9月16日 13:15:16 -0300 Subject: [PATCH 121/130] fix(ci): Proper Alpine version --- .github/workflows/docker.yml | 10 +++++++--- Dockerfile | 5 +++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 76d963d..fc8a0e9 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -12,11 +12,14 @@ jobs: strategy: matrix: include: - - php: 81 + - alpine: 3.19 + php: 81 without-watchr: 1 - - php: 82 + - alpine: 3.20 + php: 82 without-watchr: '' - - php: 83 + - alpine: 3.20 + php: 83 without-watchr: '' steps: - @@ -41,6 +44,7 @@ jobs: context: . load: true build-args: | + ALPINE=${{ matrix.alpine }} PHP=${{ matrix.php }} WITHOUT_WATCHR=${{ matrix.without-watchr }} tags: opencodeco/phpctl:php${{ matrix.php }} diff --git a/Dockerfile b/Dockerfile index fb30549..f45489d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG ALPINE=3.19 +ARG ALPINE=3.20 FROM alpine:${ALPINE} ARG PHP @@ -11,7 +11,8 @@ ARG WITHOUT_WATCHR ENV WITHOUT_WATCHR=$WITHOUT_WATCHR COPY rootfs / -RUN apk update && apk upgrade && apk add --no-cache \ +RUN sed -i 's/latest-stable/${ALPINE}/g' /etc/apk/repositories && \ + apk update && apk upgrade && apk add --no-cache \ git \ docker-cli \ php${PHP}-cli \ From eec790067e3928d0c2f6a27111e25593f75b0b53 Mon Sep 17 00:00:00 2001 From: leocavalcante Date: 2024年9月16日 13:19:21 -0300 Subject: [PATCH 122/130] fix(ci): Alpine version as parameter --- .github/workflows/docker.yml | 7 +++---- Dockerfile | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index fc8a0e9..fca121f 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,5 +1,4 @@ name: Docker - on: pull_request: push: @@ -12,13 +11,13 @@ jobs: strategy: matrix: include: - - alpine: 3.19 + - alpine: '3.19' php: 81 without-watchr: 1 - - alpine: 3.20 + - alpine: '3.20' php: 82 without-watchr: '' - - alpine: 3.20 + - alpine: '3.20' php: 83 without-watchr: '' steps: diff --git a/Dockerfile b/Dockerfile index f45489d..1eca7ec 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ ARG WITHOUT_WATCHR ENV WITHOUT_WATCHR=$WITHOUT_WATCHR COPY rootfs / -RUN sed -i 's/latest-stable/${ALPINE}/g' /etc/apk/repositories && \ +RUN sed -i "s/latest-stable/v${ALPINE}/g" /etc/apk/repositories && \ apk update && apk upgrade && apk add --no-cache \ git \ docker-cli \ From f471be642192fd6405cdcad850b81f36cb0ef1e7 Mon Sep 17 00:00:00 2001 From: leocavalcante Date: 2024年9月16日 13:30:16 -0300 Subject: [PATCH 123/130] fix(docker): Build arg --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 1eca7ec..a6e2c63 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ ARG WITHOUT_WATCHR ENV WITHOUT_WATCHR=$WITHOUT_WATCHR COPY rootfs / -RUN sed -i "s/latest-stable/v${ALPINE}/g" /etc/apk/repositories && \ +RUN sed -i 's/latest-stable/v$ALPINE/g' /etc/apk/repositories && \ apk update && apk upgrade && apk add --no-cache \ git \ docker-cli \ From 1a2f7e93c1d2c90a4f1b5bdd839c435920ee648d Mon Sep 17 00:00:00 2001 From: leocavalcante Date: 2024年9月16日 13:32:59 -0300 Subject: [PATCH 124/130] fix(ci): Build arg usage --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index a6e2c63..bafa14a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ ARG ALPINE=3.20 +ENV ALPINE=$ALPINE FROM alpine:${ALPINE} ARG PHP @@ -11,7 +12,7 @@ ARG WITHOUT_WATCHR ENV WITHOUT_WATCHR=$WITHOUT_WATCHR COPY rootfs / -RUN sed -i 's/latest-stable/v$ALPINE/g' /etc/apk/repositories && \ +RUN sed -i "s/latest-stable/v${ALPINE}/g" /etc/apk/repositories && \ apk update && apk upgrade && apk add --no-cache \ git \ docker-cli \ From fe4ddd8a5651a2549ff2210bcdbac38422ea599f Mon Sep 17 00:00:00 2001 From: leocavalcante Date: 2024年9月16日 13:34:16 -0300 Subject: [PATCH 125/130] fix(docker): Instructions order --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index bafa14a..bd1e5e6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ ARG ALPINE=3.20 -ENV ALPINE=$ALPINE FROM alpine:${ALPINE} +ENV ALPINE=$ALPINE ARG PHP ENV PHP_VERSION=$PHP From 54a5525dc57e99ea8ab675ad97be28fe8618d6f8 Mon Sep 17 00:00:00 2001 From: leocavalcante Date: 2024年9月16日 13:42:33 -0300 Subject: [PATCH 126/130] fix(docker): Alpine repositories --- Dockerfile | 4 +--- rootfs/etc/apk/repositories | 4 ---- 2 files changed, 1 insertion(+), 7 deletions(-) delete mode 100644 rootfs/etc/apk/repositories diff --git a/Dockerfile b/Dockerfile index bd1e5e6..cf3654f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,5 @@ ARG ALPINE=3.20 FROM alpine:${ALPINE} -ENV ALPINE=$ALPINE ARG PHP ENV PHP_VERSION=$PHP @@ -12,8 +11,7 @@ ARG WITHOUT_WATCHR ENV WITHOUT_WATCHR=$WITHOUT_WATCHR COPY rootfs / -RUN sed -i "s/latest-stable/v${ALPINE}/g" /etc/apk/repositories && \ - apk update && apk upgrade && apk add --no-cache \ +RUN apk update && apk upgrade && apk add --no-cache \ git \ docker-cli \ php${PHP}-cli \ diff --git a/rootfs/etc/apk/repositories b/rootfs/etc/apk/repositories deleted file mode 100644 index f1fb265..0000000 --- a/rootfs/etc/apk/repositories +++ /dev/null @@ -1,4 +0,0 @@ -https://dl-cdn.alpinelinux.org/alpine/latest-stable/main -https://dl-cdn.alpinelinux.org/alpine/latest-stable/community -https://dl-cdn.alpinelinux.org/alpine/edge/main -https://dl-cdn.alpinelinux.org/alpine/edge/community From 56a0ab02e919bbce92ebdfa085e5c2fc7f28caaa Mon Sep 17 00:00:00 2001 From: leocavalcante Date: 2024年9月16日 13:57:23 -0300 Subject: [PATCH 127/130] fix(docker): Build arg --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index cf3654f..9c98734 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ ARG ALPINE=3.20 -FROM alpine:${ALPINE} +FROM alpine:$ALPINE ARG PHP ENV PHP_VERSION=$PHP From c02c35451eb8c743763a18c22fcb658a8c1aa460 Mon Sep 17 00:00:00 2001 From: leocavalcante Date: 2024年9月16日 14:00:33 -0300 Subject: [PATCH 128/130] fix(ci): Missing Alpine in step --- .github/workflows/docker.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index fca121f..ebbf8c7 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -61,5 +61,7 @@ jobs: with: context: . push: true - build-args: PHP=${{ matrix.php }} + build-args: | + ALPINE=${{ matrix.alpine }} + PHP=${{ matrix.php }} tags: opencodeco/phpctl:php${{ matrix.php }} From bcbd8b530be82cc8f3b8f1f93bd41fbd39934614 Mon Sep 17 00:00:00 2001 From: Luiz Carlos Manhani Junior <139877977+luizmanhani@users.noreply.github.com> Date: 2024年9月18日 13:48:43 -0300 Subject: [PATCH 129/130] test lib brotli (#47) --- src-devc/.devcontainer/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src-devc/.devcontainer/Dockerfile b/src-devc/.devcontainer/Dockerfile index c9bb6e8..2b3012f 100644 --- a/src-devc/.devcontainer/Dockerfile +++ b/src-devc/.devcontainer/Dockerfile @@ -5,7 +5,7 @@ ENV PHP_VERSION $PHP_VERSION COPY rootfs / ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ - && apt-get -y install --no-install-recommends libcurl4-openssl-dev libc-ares-dev libsqlite3-dev libpq-dev git parallel unzip wget \ + && apt-get -y install --no-install-recommends libcurl4-openssl-dev libc-ares-dev libsqlite3-dev libpq-dev git parallel unzip wget libbrotli-dev \ && mv /usr/local/etc/php/php.ini-development /usr/local/etc/php/php.ini \ && mv /etc/php/php.ini /usr/local/etc/php/conf.d/zzphp.ini \ && install-php-extensions sockets && install-swoole && install-tools From 34ccdc10d92ccc555100ace02ea3191d47d8d633 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+copilot@users.noreply.github.com> Date: 2025年11月21日 16:17:27 -0300 Subject: [PATCH 130/130] Update install instructions to use GitHub raw URL (#52) * Initial plan * Update install instructions URL to use GitHub raw URL Co-authored-by: leocavalcante <183722+leocavalcante@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+copilot@users.noreply.github.com> Co-authored-by: leocavalcante <183722+leocavalcante@users.noreply.github.com> --- README.md | 2 +- docs/index.md | 4 ++-- tests/install/docker-entrypoint.sh | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9fff05b..8884908 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Take the advantage of goodie commands like `phpctl create` to start a new projec ### Just install ```shell -/bin/bash -c "$(curl -fsSL https://phpctl.dev/install.sh)" +/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/opencodeco/phpctl/refs/heads/main/docs/install.sh)" ``` ### And that is it! Try it out: diff --git a/docs/index.md b/docs/index.md index aa0c9e8..38b21f8 100644 --- a/docs/index.md +++ b/docs/index.md @@ -18,7 +18,7 @@ Take the advantage of goodies commands like `phpctl create` to start a new proje ### Installation ```shell -/bin/bash -c "$(curl -fsSL https://phpctl.dev/install.sh)" +/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/opencodeco/phpctl/refs/heads/main/docs/install.sh)" ``` **That is it!** Now you have `phpctl` available in your system. @@ -26,7 +26,7 @@ Take the advantage of goodies commands like `phpctl create` to start a new proje #### Custom installation You can also pass an argument to install at a custom location (e.g. `~/bin`), but you have to make sure that folder is in your `$PATH` variable. ```shell -/bin/bash -c "$(curl -fsSL https://phpctl.dev/install.sh)" ~/bin +/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/opencodeco/phpctl/refs/heads/main/docs/install.sh)" ~/bin ``` #### Homebrew diff --git a/tests/install/docker-entrypoint.sh b/tests/install/docker-entrypoint.sh index 87af11d..e62e540 100755 --- a/tests/install/docker-entrypoint.sh +++ b/tests/install/docker-entrypoint.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash neofetch -/bin/bash -c "$(curl -fsSL https://phpctl.dev/install.sh)" +/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/opencodeco/phpctl/refs/heads/main/docs/install.sh)" echo "" notty phpctl doctor notty php --version