Skip to content

Commit

Permalink
Modernize
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkyle committed Aug 28, 2024
1 parent 83e31b4 commit 30209d4
Show file tree
Hide file tree
Showing 10 changed files with 329 additions and 1,084 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#
# Source repository: https://github.com/actions/dependency-review-action
# Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement
#
# Last revised: 2024/02/11
#
name: 'Dependency Review'
on: [pull_request]

Expand All @@ -15,6 +18,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: 'Dependency Review'
uses: actions/dependency-review-action@v1
uses: actions/dependency-review-action@v4
8 changes: 2 additions & 6 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,14 @@ jobs:
fail-fast: false
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
- "8.2"
- "8.3"
dependency-versions:
- "lowest"
- "highest"

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Checkout Repository
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
9 changes: 6 additions & 3 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@
EOF;

$finder = PhpCsFixer\Finder::create()
->in(__DIR__ . '/')
->exclude(__DIR__ . '/vendor');
->in([
__DIR__ . '/src',
__DIR__ . '/tests'
]);

return (new PhpCsFixer\Config())->setRules([
'@PSR12' => true,
'@PER-CS' => true,

'header_comment' => [
'comment_type' => 'PHPDoc',
'header' => $header,
Expand Down
59 changes: 6 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<h1 align="center">PHP Package Boilerplate</h1>

[![Packagist](https://img.shields.io/packagist/v/tomkyle/boilerplate-php.svg?style=flat)](https://packagist.org/packages/tomkyle/boilerplate-php )
[![PHP version](https://img.shields.io/packagist/php-v/tomkyle/boilerplate-php.svg)](https://packagist.org/packages/tomkyle/boilerplate-php )
[![PHP Composer](https://github.com/tomkyle/boilerplate-php/actions/workflows/php.yml/badge.svg)](https://github.com/tomkyle/boilerplate-php/actions/workflows/php.yml)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE)

**A template repository for PHP package.**

Expand All @@ -12,6 +15,7 @@
$ composer create-project tomkyle/boilerplate-php new-project
$ cd new-project
$ composer install
$ npm install
```


Expand Down Expand Up @@ -41,61 +45,10 @@ $ composer require guzzlehttp/guzzle

## Development

### Run all tests

This packages has predefined test setups for code quality, code readability and unit tests. Check them out at the `scripts` section of **[composer.json](./composer.json)**.

```bash
$ composer test
# ... which includes
$ composer phpstan
$ composer phpcs
$ composer phpunit
```

### Unit tests

Default configuration is **[phpunit.xml.dist](./phpunit.xml.dist).** Create a custom **phpunit.xml** to apply your own settings.
Also visit [phpunit.readthedocs.io](https://phpunit.readthedocs.io/) · [Packagist](https://packagist.org/packages/phpunit/phpunit)

```bash
$ composer phpunit
# ... or
$ vendor/bin/phpunit
```

### PhpStan

Default configuration is **[phpstan.neon.dist](./phpstan.neon.dist).** Create a custom **phpstan.neon** to apply your own settings. Also visit [phpstan.org](https://phpstan.org/) · [GitHub](https://github.com/phpstan/phpstan) · [Packagist](https://packagist.org/packages/phpstan/phpstan)

```bash
$ composer phpstan
# ... which includes
$ vendor/bin/phpstan analyse
```

### PhpCS

Default configuration is **[.php-cs-fixer.dist.php](./.php-cs-fixer.dist.php).** Create a custom **.php-cs-fixer.php** to apply your own settings. Also visit [cs.symfony.com](https://cs.symfony.com/) · [GitHub](https://github.com/FriendsOfPHP/PHP-CS-Fixer) · [Packagist](https://packagist.org/packages/friendsofphp/php-cs-fixer)

```bash
$ composer phpcs
# ... which aliases
$ vendor/bin/php-cs-fixer fix --verbose --diff --dry-run
```

Apply all CS fixes:

```bash
$ composer phpcs:apply
# ... which aliases
$ vendor/bin/php-cs-fixer fix --verbose --diff
```

**On PHP 8.2, setting environment variable `PHP_CS_FIXER_IGNORE_ENV` is needed:**
Run `npm update` and watch the file system for PHP code changes. See [package.json](package.json) for a list of all watch and test tasks.

```bash
$ PHP_CS_FIXER_IGNORE_ENV=1 composer phpcs
$ nmp run watch
```


Expand Down
22 changes: 1 addition & 21 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@
"nyholm/psr7": "^1.3",
"guzzlehttp/guzzle": "^7.0",
"symfony/cache": "^5.0|^6.0",

"phpunit/phpunit": "^9.6",
"phpspec/prophecy-phpunit": "^2.0",
"php-coveralls/php-coveralls": "^2.0",
"phpunit/phpunit": "^11.0",
"friendsofphp/php-cs-fixer": "^3.63",
"spatie/phpunit-watcher": "^1.0",
"phpstan/phpstan": "^1.12",
Expand All @@ -47,23 +44,6 @@
"rector/rector": "^1.2"
},

"scripts": {
"watch" : "phpunit-watcher watch",

"phpstan" : "phpstan analyse",

"phpcs" : "php-cs-fixer fix --verbose --diff --dry-run",
"phpcs:apply" : "php-cs-fixer fix --verbose --diff",

"phpunit" : "phpunit --coverage-text",

"test": [
"@phpstan",
"@phpcs",
"@phpunit"
]
},

"suggest": {
"monolog/monolog": "PSR-3 Logger of choice",
"nyholm/psr7": "PSR-17 factories",
Expand Down
Loading

0 comments on commit 30209d4

Please sign in to comment.