Last active
April 4, 2022 15:53
-
-
Save Tom-Millard/67f6bd4629739a603fc40762e4f6a581 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Autodetect text files | |
* text=auto | |
# Force the following filetypes to have unix eols, so Windows does not break them | |
*.* text eol=lf | |
# Encrypt the repository | |
# Remove/modify this line if the repository is meant to be open-source | |
*.* filter=git-crypt diff=git-crypt | |
.gitattributes !filter !diff | |
# These files are text and should be normalized (Convert crlf => lf) | |
*.php text | |
*.css text | |
*.js text | |
*.htm text | |
*.html text | |
*.xml text | |
*.txt text | |
*.ini text | |
*.inc text | |
*.sql text | |
*.md text | |
*.csv text | |
.htaccess text | |
# These files are binary and should be left untouched | |
# (binary is a macro for -text -diff) | |
*.png binary | |
*.jpg binary | |
*.jpeg binary | |
*.gif binary | |
*.ico binary | |
*.mov binary | |
*.mp4 binary | |
*.mp3 binary | |
*.flv binary | |
*.fla binary | |
*.swf binary | |
*.gz binary | |
*.zip binary | |
*.7z binary | |
*.ttf binary | |
*.pdf binary | |
*.phar binary | |
*.class binary | |
# Documents | |
*.doc diff=astextplain | |
*.DOC diff=astextplain | |
*.docx diff=astextplain | |
*.DOCX diff=astextplain | |
*.dot diff=astextplain | |
*.DOT diff=astextplain | |
*.pdf diff=astextplain | |
*.PDF diff=astextplain | |
*.rtf diff=astextplain | |
*.RTF diff=astextplain | |
*.xlsx diff=astextplain | |
# Set line endings to always be lf for SVG font files | |
*.eot binary | |
*.ttf binary | |
*.woff binary | |
*.woff2 binary | |
*.otf binary | |
*.large.csv filter=lfs diff=lfs merge=lfs -text | |
*.large.csv.zip filter=lfs diff=lfs merge=lfs -text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.env | |
vendor | |
node_modules | |
.phpcs-cache | |
.phpunit.result.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
mkdir -p docker/php/conf.d | |
curl https://gist.githubusercontent.com/Tom-Millard/67f6bd4629739a603fc40762e4f6a581/raw/22221da7afd64aee308ad1bf587aed378823d716/Dockerfile > docker/php/conf.d/Dockerfile | |
curl https://gist.githubusercontent.com/Tom-Millard/67f6bd4629739a603fc40762e4f6a581/raw/22221da7afd64aee308ad1bf587aed378823d716/docker-compose.yml > docker-compose.yml | |
docker compose build | |
docker compose run php bash boot-php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir ./src | |
mkdir -p ./tests/{Unit, Feature} | |
composer require --dev phpunit/phpunit | |
composer require --dev squizlabs/php_codesniffer | |
composer require --dev slevomat/coding-standard | |
composer require --dev doctrine/coding-standard | |
composer require --dev behat/behat | |
composer require --dev vimeo/psalm | |
composer require --dev phpstan/phpstan | |
composer require --dev captainhook/captainhook | |
php -r "copy('https://gist.githubusercontent.com/Tom-Millard/67f6bd4629739a603fc40762e4f6a581/raw/95de56e7a1f21323188d82764b185239130f6abc/.gitattributes', '.gitattributes');" | |
php -r "copy('https://gist.githubusercontent.com/Tom-Millard/67f6bd4629739a603fc40762e4f6a581/raw/95de56e7a1f21323188d82764b185239130f6abc/.gitignore', '.gitignore');" | |
php -r "copy('https://gist.githubusercontent.com/Tom-Millard/67f6bd4629739a603fc40762e4f6a581/raw/b0dba02aa0897b7a4879ac891736fa170645767d/phpcs.xml.dist', 'phpcs.xml');" | |
php -r "copy('https://gist.githubusercontent.com/Tom-Millard/67f6bd4629739a603fc40762e4f6a581/raw/a1e29e73a1deda0af35ca93b7d5ea6c481182a87/phpunit.xml', 'phpunit.xml');" | |
php -r "copy('https://gist.githubusercontent.com/Tom-Millard/67f6bd4629739a603fc40762e4f6a581/raw/b37fbb10a0b0a943ac5c369fde3845d4e7955459/psalm.xml', 'psalm.xml');" | |
php -r "copy('https://gist.githubusercontent.com/Tom-Millard/67f6bd4629739a603fc40762e4f6a581/raw/1936a3a74f73a7a67f231298770f0a11db6439be/captainhook.json', 'captainhook.json');" | |
php -r "copy('https://gist.githubusercontent.com/Tom-Millard/67f6bd4629739a603fc40762e4f6a581/raw/1936a3a74f73a7a67f231298770f0a11db6439be/phpstan.neon', 'phpstan.neon');" | |
php vendor/bin/captainhook install --force |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"config": { | |
"run-mode": "docker", | |
"run-exec": "docker exec php8.1", | |
"verbosity": "verbose" | |
}, | |
"commit-msg": { | |
"enabled": true, | |
"actions": [ | |
{ | |
"action": "\\CaptainHook\\App\\Hook\\Message\\Action\\Beams", | |
"options": { | |
"subjectLength": 50, | |
"bodyLineLength": 72 | |
}, | |
"conditions": [] | |
} | |
] | |
}, | |
"pre-push": { | |
"enabled": false, | |
"actions": [] | |
}, | |
"pre-commit": { | |
"enabled": true, | |
"actions": [ | |
{ | |
"action": "\\CaptainHook\\App\\Hook\\PHP\\Action\\Linting", | |
"options": [], | |
"conditions": [] | |
}, | |
{ | |
"action": "php ./vendor/bin/phpstan analyse --memory-limit=2G {$STAGED_FILES|of-type:php}", | |
"options": [], | |
"conditions": [ | |
{ | |
"exec": "\\CaptainHook\\App\\Hook\\Condition\\FileStaged\\OfType", | |
"args": ["php"] | |
} | |
] | |
}, | |
{ | |
"action": "php ./vendor/bin/psalm {$STAGED_FILES|of-type:php}", | |
"options": [], | |
"conditions": [ | |
{ | |
"exec": "\\CaptainHook\\App\\Hook\\Condition\\FileStaged\\OfType", | |
"args": ["php"] | |
} | |
] | |
}, | |
{ | |
"action": "php ./vendor/bin/phpcbf {$STAGED_FILES|of-type:php}", | |
"options": [], | |
"conditions": [ | |
{ | |
"exec": "\\CaptainHook\\App\\Hook\\Condition\\FileStaged\\OfType", | |
"args": ["php"] | |
} | |
] | |
} | |
] | |
}, | |
"prepare-commit-msg": { | |
"enabled": false, | |
"actions": [] | |
}, | |
"post-commit": { | |
"enabled": false, | |
"actions": [] | |
}, | |
"post-merge": { | |
"enabled": false, | |
"actions": [] | |
}, | |
"post-checkout": { | |
"enabled": false, | |
"actions": [] | |
}, | |
"post-rewrite": { | |
"enabled": false, | |
"actions": [] | |
}, | |
"post-change": { | |
"enabled": true, | |
"actions": [ | |
{ | |
"action": "composer install", | |
"options": {}, | |
"conditions": [ | |
{ | |
"exec": "\\CaptainHook\\App\\Hook\\Condition\\FileChanged\\Any", | |
"args": [ | |
["composer.json", "composer.lock", "captainhook.json"] | |
] | |
} | |
] | |
} | |
] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
php: | |
container_name: php8.1 | |
build: ./docker/php/ | |
platform: linux/x86_64 | |
expose: | |
- 9000 | |
volumes: | |
- ./:/code | |
- ./docker/php/conf.d/xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini | |
- ./docker/php/conf.d/error_reporting.ini:/usr/local/etc/php/conf.d/error_reporting.ini | |
working_dir: /code | |
networks: | |
- application | |
networks: | |
application: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM php:8.1.0-fpm | |
RUN apt-get update | |
RUN apt-get install -y git zip unzip curl | |
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer | |
RUN pecl install xdebug && docker-php-ext-enable xdebug | |
RUN apt-get clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<ruleset> | |
<arg name="basepath" value="."/> | |
<arg name="extensions" value="php"/> | |
<arg name="parallel" value="80"/> | |
<arg name="cache" value=".phpcs-cache"/> | |
<arg name="colors"/> | |
<!-- Ignore warnings, show progress of the run and show sniff names --> | |
<arg value="nps"/> | |
<!-- Directories to be checked --> | |
<file>lib</file> | |
<file>tests</file> | |
<!-- Include full Doctrine Coding Standard --> | |
<rule ref="Doctrine"/> | |
</ruleset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parameters: | |
paths: | |
- app | |
- tests/Unit | |
level: 9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<phpunit | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.3/phpunit.xsd" | |
colors="true" | |
convertErrorsToExceptions="true" | |
convertNoticesToExceptions="true" | |
convertWarningsToExceptions="true" | |
> | |
<testsuites> | |
<testsuite name='Unit'> | |
<directory suffix='.php'>./tests/Unit</directory> | |
</testsuite> | |
</testsuites> | |
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<psalm | |
errorLevel="1" | |
resolveFromConfigFile="true" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns="https://getpsalm.org/schema/config" | |
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" | |
> | |
<projectFiles> | |
<directory name="src" /> | |
<ignoreFiles> | |
<directory name="vendor" /> | |
</ignoreFiles> | |
</projectFiles> | |
</psalm> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
php -r "copy('https://gist.githubusercontent.com/Tom-Millard/67f6bd4629739a603fc40762e4f6a581/raw/b0dba02aa0897b7a4879ac891736fa170645767d/phpcs.xml.dist', 'phpcs.xml.dist');"