Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
andysnell committed Mar 23, 2024
0 parents commit d425685
Show file tree
Hide file tree
Showing 21 changed files with 3,429 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# EditorConfig http://EditorConfig.org

# top-most EditorConfig file
root = true

# This applies to all files
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8
indent_style = space
indent_size = 4

[*.{yml,yaml}]
indent_size = 2
36 changes: 36 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/.allowed-licenses export-ignore
/.editorconfig export-ignore
/.env export-ignore
/.env.example export-ignore
/.gitattributes export-ignore
/.github/ export-ignore
/.gitignore export-ignore
/.idea export-ignore
/CHANGELOG.md export-ignore
/CODE_OF_CONDUCT.md export-ignore
/CONTRIBUTING.md export-ignore
/Dockerfile export-ignore
/Makefile export-ignore
/SECURITY.md export-ignore
/benchmarks/ export-ignore
/bin/ export-ignore
/build/ export-ignore
/captainhook.json export-ignore
/codecov.yml export-ignore
/composer.lock export-ignore
/conventional-commits.json export-ignore
/docker-compose.yml export-ignore
/docs/ export-ignore
/phpbench.json export-ignore
/phpcs.xml export-ignore
/phpcs.xml.dist export-ignore
/phpstan.neon export-ignore
/phpstan.dist.neon export-ignore
/phpunit.xml export-ignore
/phpunit.dist.xml export-ignore
/psalm-baseline.xml export-ignore
/psalm.xml export-ignore
/rector.php export-ignore
/resources/ export-ignore
/settings.ini export-ignore
/tests/ export-ignore
92 changes: 92 additions & 0 deletions .github/workflows/code_quality.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Code Quality
on: [push, pull_request]

jobs:
phpcs:
name: PHP ${{ matrix.php }} - PHP_CodeSniffer
runs-on: ubuntu-latest
strategy:
matrix:
php: ['8.3']
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Install PHP and Extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2

- name: Install Composer Dependencies
uses: ramsey/composer-install@v2

- name: Run PHP_CodeSniffer
run: vendor/bin/phpcs --no-cache

phpstan:
name: PHP ${{ matrix.php }} - PHPStan
runs-on: ubuntu-latest
strategy:
matrix:
php: ['8.3']
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Install PHP and Extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2

- name: Install Composer Dependencies
uses: ramsey/composer-install@v2

- name: Run PHPStan
run: vendor/bin/phpstan --no-progress --no-ansi

rector:
name: PHP ${{ matrix.php }} - Rector
runs-on: ubuntu-latest
strategy:
matrix:
php: ['8.3']
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Install PHP and Extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2

- name: Install Composer Dependencies
uses: ramsey/composer-install@v2

- name: Run Rector
run: vendor/bin/rector process --dry-run --no-progress-bar

phpunit:
name: PHP ${{ matrix.php }} - PHPUnit
runs-on: ubuntu-latest
strategy:
matrix:
php: ['8.3']
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Install PHP and Extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: pcov
tools: composer:v2

- name: Install Composer Dependencies
uses: ramsey/composer-install@v2

- name: Run PHPUnit
run: vendor/bin/phpunit --no-progress --coverage-text
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.idea/
.env
.phpunit.result.cache
docker-compose.override.yml
phpstan.neon
phpunit.xml
vendor/
build/
14 changes: 14 additions & 0 deletions .psysh.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

return [
'commands' => [],
'defaultIncludes' => [],
'eraseDuplicates' => true,
'errorLoggingLevel' => \E_ALL,
'forceArrayIndexes' => false,
'pager' => 'less',
'useBracketedPaste' => true,
'verbosity' => \Psy\Configuration::VERBOSITY_NORMAL,
];
42 changes: 42 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# syntax=docker/dockerfile:1.4
FROM php:8.3-cli as php
WORKDIR /app
ENV PATH "/app/bin:/app/vendor/bin:/app/build/composer/vendor/bin:$PATH"
ENV COMPOSER_HOME "/app/build/composer"

RUN <<-EOF
groupadd --gid 1000 dev;
useradd --system --create-home --uid 1000 --gid 1000 --shell /bin/bash dev;
EOF

RUN <<-EOF
apt-get update;
apt-get install -y \
apt-transport-https \
autoconf \
build-essential \
curl \
git \
less \
libgmp-dev \
libicu-dev \
libzip-dev \
libsodium-dev \
pkg-config \
unzip \
vim-tiny \
zip \
zlib1g-dev;
apt-get clean;
EOF

RUN <<-EOF
docker-php-ext-install -j$(nproc) bcmath gmp intl opcache zip;
pecl install xdebug;
docker-php-ext-enable xdebug;
EOF

COPY --link --from=composer/composer:latest-bin /composer /usr/bin/composer
COPY --link settings.ini /usr/local/etc/php/conf.d/settings.ini

USER dev
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2023-2024 WickedByte LLC

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
62 changes: 62 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
SHELL := bash

app = docker compose run --rm app

build:
@docker compose build --pull
@$(app) composer install
@$(app) mkdir -p build

.PHONY: clean
clean:
@rm -rf ./build ./vendor

.PHONY: update
update: build
@$(app) composer update --with-all-dependencies
@$(app) composer bump

.PHONY: upgrade
upgrade: build
@$(app) composer require --dev --update-with-all-dependencies \
phpstan/phpstan \
phpunit/phpunit \
psy/psysh \
squizlabs/php_codesniffer \
slevomat/coding-standard \
rector/rector
@$(app) composer require --update-with-all-dependencies \
symfony/console
@$(app) app composer bump

.PHONY: bash
bash: build
@$(app) bash

.PHONY: phpunit
phpunit: build
@$(app) composer phpunit

.PHONY: psysh
psysh: build
@$(app) composer psysh

.PHONY: phpcs
phpcs: build
@$(app) composer phpcs

.PHONY: phpcbf
phpcbf: build
@$(app) composer phpcbf

.PHONY: phpstan
phpstan: build
@$(app) composer phpstan

.PHONY: rector
rector: build
@$(app) composer rector

.PHONY: ci
ci: build
@$(app) composer ci
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# PHP Project Skeleton (CLI)

Run `make` to build the project Docker image, create the "./build" cache directory
and install vendor dependencies with Composer.

To upgrade the project dependencies to their current major versions, run `make upgrade`, or
to just update them within the bounds of their currently defined constraints, run `make update`

Common Actions with Makefile targets:
- `make bash`
- `make phpunit`
- `make psysh`
- `make phpcs`
- `make phpstan`
- `make rector`
- `make ci`

To get a fresh start, run `make clean` to delete the vendor and build directories,
which will trigger a docker image rebuild, the next time `make` or `make build` is run.

For anything else not defined in the Makefile, use:
```shell
docker compose run --rm -it app {your-command-here}
```
16 changes: 16 additions & 0 deletions app
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env php
<?php

declare(strict_types=1);

use Symfony\Component\Console\Application;
use WickedByte\Tombstone\Commands\FooCommand;

require __DIR__ . '/vendor/autoload.php';

$app = new Application('Project Skeleton');
$app->addCommands([
new FooCommand(),
]);

$app->run();
54 changes: 54 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "wickedbyte/tombstone",
"description": "Basic implementation of the Tombstone pattern for PHP to uncover zombie code",
"type": "project",
"license": "MIT",
"authors": [
{
"name": "Andy Snell",
"email": "[email protected]"
}
],
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": false
},
"sort-packages": true
},
"require": {
"php": "8.2.* || 8.3.*"
},
"autoload": {
"psr-4": {
"WickedByte\\Tombstone\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"WickedByte\\Tests\\Tombstone\\": "tests/"
}
},
"scripts": {
"phpcbf": "@php vendor/bin/phpcbf --parallel=$(nproc) --report=full",
"phpcs": "@php vendor/bin/phpcs --parallel=$(nproc) --report=full",
"phpstan": "@php vendor/bin/phpstan analyze --memory-limit=-1",
"phpunit": "@php -d xdebug.mode=coverage vendor/bin/phpunit --coverage-text",
"psysh": "@php vendor/bin/psysh",
"rector": "@php vendor/bin/rector process",
"rector-dry-run": "@php vendor/bin/rector process --dry-run",
"ci": [
"@phpcs",
"@phpunit",
"@phpstan",
"@rector-dry-run"
]
},
"require-dev": {
"phpstan/phpstan": "^1.10.64",
"phpunit/phpunit": "^11.0.8",
"psy/psysh": "^0.12.2",
"rector/rector": "^1.0.3",
"slevomat/coding-standard": "^8.15",
"squizlabs/php_codesniffer": "^3.9"
}
}
Loading

0 comments on commit d425685

Please sign in to comment.