diff --git a/.github/workflows/code-standart.yml b/.github/workflows/code-standart.yml new file mode 100644 index 0000000..e0eea57 --- /dev/null +++ b/.github/workflows/code-standart.yml @@ -0,0 +1,38 @@ +name: DEPLOY AND BUILD + +on: ['push', 'pull_request'] + +jobs: + coding-standard: + name: Coding Standard + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.4' + coverage: none + + - name: Get composer cache directory + id: composer-cache + run: | + echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Cache composer dependencies + uses: actions/cache@v4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer- + + - name: Install dependencies + run: composer install --no-progress --no-suggest --prefer-dist --no-interaction + + - name: Check coding style + run: composer cs-check + + - name: Run tests + run: composer tests \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..0b52848 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/composer.lock +/phpunit.xml +/vendor/ +/.idea/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100755 index 0000000..10bb7b7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM php:8.4-cli-alpine + +WORKDIR /app + +COPY . /app + +COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer \ No newline at end of file diff --git a/README.md b/README.md new file mode 100755 index 0000000..3e8cfc0 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# Skeleton PHP Docker \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100755 index 0000000..d0b0cec --- /dev/null +++ b/composer.json @@ -0,0 +1,48 @@ +{ + "name": "deniskorbakov/skeleton-php-docker", + "description": "A skeleton php libs with docker", + "keywords": ["php", "skeleton", "package", "docker"], + "type": "libarary", + "license": "MIT", + "authors": [ + { + "name": "Denis Korbakov", + "email": "korbakovd@gmail.com" + } + ], + "autoload": { + "psr-4": { + "DenisKorbakov\\SkeletonPhpDocker\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Tests\\": "tests/" + } + }, + "minimum-stability": "stable", + "scripts": { + "tests": "php ./vendor/bin/pest", + "cs-check": [ + "@phpstan", + "@cs", + "@rector" + ], + "phpstan": "phpstan analyse --memory-limit=2G", + "rector": "rector", + "cs": "phpcs" + }, + "require-dev": { + "pestphp/pest": "^3.8", + "phpstan/phpstan": "^2.1", + "rector/rector": "*", + "squizlabs/php_codesniffer": "^3.13", + "slevomat/coding-standard": "^8.20" + }, + "config": { + "allow-plugins": { + "pestphp/pest-plugin": true, + "dealerdirect/phpcodesniffer-composer-installer": true + } + } +} diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100755 index 0000000..cf8392c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +version: '3.7' +services: + app: + container_name: scribe-plugin + build: + context: ./ + volumes: + - ./:/app + tty: true + stdin_open: true \ No newline at end of file diff --git a/makefile b/makefile new file mode 100755 index 0000000..afc4073 --- /dev/null +++ b/makefile @@ -0,0 +1,26 @@ +# command for init project +init: build install + +# command for start app +up: + docker compose up -d + +# command for build app +build: + docker compose up -d --build + +# command for exec in container +exec: + docker exec -it scribe-plugin /bin/sh + +# command for install pkg +install: + docker exec -i scribe-plugin composer install --dev + +# command for run verify code +code-check: + docker exec -i scribe-plugin composer cs-check + +# command for run tests +test: + docker exec -i scribe-plugin composer tests \ No newline at end of file diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100755 index 0000000..c518941 --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,76 @@ + + + Coding standard + + + + + + + + src + tests + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100755 index 0000000..4f2a3b2 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,6 @@ +parameters: + level: max + paths: + - src + + reportUnmatchedIgnoredErrors: true \ No newline at end of file diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..e6198e0 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,18 @@ + + + + + ./tests + + + + + app + src + + + diff --git a/rector.php b/rector.php new file mode 100755 index 0000000..9ee8aa5 --- /dev/null +++ b/rector.php @@ -0,0 +1,77 @@ +paths([ + __DIR__ . '/src', + __DIR__ . '/tests', + ]); + + $rectorConfig->rules([ + AddVoidReturnTypeWhereNoReturnRector::class, + DeclareStrictTypesRector::class, + ClosureReturnTypeRector::class, + ReturnTypeFromStrictTypedCallRector::class, + ReturnTypeFromStrictNewArrayRector::class, + ReturnTypeFromReturnDirectArrayRector::class, + TypedPropertyFromStrictConstructorRector::class, + CompleteDynamicPropertiesRector::class, + InlineArrayReturnAssignRector::class, + ExplicitBoolCompareRector::class, + SwitchNegatedTernaryRector::class, + NewlineBeforeNewAssignSetRector::class, + EncapsedStringsToSprintfRector::class, + PostIncDecToPreIncDecRector::class, + SymplifyQuoteEscapeRector::class, + RemoveUnusedPromotedPropertyRector::class, + RemoveUnusedPrivateMethodRector::class, + RemoveUnusedPrivatePropertyRector::class, + ClassPropertyAssignToConstructorPromotionRector::class, + ReadOnlyPropertyRector::class, + PrivatizeFinalClassMethodRector::class, + PrivatizeFinalClassPropertyRector::class, + ]); + + $rectorConfig->skip([ + CompactToVariablesRector::class, + RemoveEmptyClassMethodRector::class, + ]); + + $rectorConfig->sets([ + SetList::CODE_QUALITY, + SetList::TYPE_DECLARATION, + SetList::DEAD_CODE, + SetList::PRIVATIZATION, + ]); + + $rectorConfig->phpVersion(PhpVersion::PHP_84); +}; diff --git a/src/Example.php b/src/Example.php new file mode 100755 index 0000000..d1fd314 --- /dev/null +++ b/src/Example.php @@ -0,0 +1,13 @@ +foo(); + + expect($result)->toBe('bar'); +});