Skip to content

Commit

Permalink
refactor: laravel 9 (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
leMaur authored Feb 3, 2022
1 parent c173bae commit 1b184a5
Show file tree
Hide file tree
Showing 21 changed files with 557 additions and 157 deletions.
2 changes: 0 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ If the project maintainer has any additional requirements, you will find them li

- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer).

- **Add tests!** - Your patch won't be accepted if it doesn't have tests.

- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.

- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option.
Expand Down
7 changes: 0 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
.idea
.php-cs-fixer
.php-cs-fixer.cache
.phpunit.result.cache
build
composer.lock
coverage
docs
phpunit.xml
psalm.xml
vendor
node_modules
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

All notable changes to `toolbox` will be documented in this file.

## 3.0.0 - 2023-02-03

- added laravel 9 support
- added new packages:
- barryvdh/laravel-ide-helper
- infection/infection
- roave/security-advisories
- removed packages:
- fakerphp/faker
- jasonmccreary/laravel-test-assertions
- mheap/phpunit-github-actions-printer
- mockery/mockery
- orchestra/testbench
- nunomaduro/collision
- phpunit/phpunit

## 2.2.0 - 2021-08-24

- add pestphp/pest-plugin-parallel
Expand Down
122 changes: 94 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Tools for Artisan!

Toolbox full of useful packages to keep your Laravel project compliant with your coding standards.
It provides a minimum configuration to help you start with `static analysis`, `code styling` and `testing`.

[![Latest Version on Packagist](https://img.shields.io/packagist/v/lemaur/toolbox.svg?style=flat-square)](https://packagist.org/packages/lemaur/toolbox)
[![Total Downloads](https://img.shields.io/packagist/dt/lemaur/toolbox.svg?style=flat-square)](https://packagist.org/packages/lemaur/toolbox)
[![License](https://img.shields.io/packagist/l/lemaur/toolbox.svg?style=flat-square&color=yellow)](https://github.com/leMaur/toolbox/blob/master/LICENSE.md)
Expand All @@ -8,11 +11,22 @@
[![Trees](https://img.shields.io/badge/dynamic/json?color=yellowgreen&style=flat-square&label=Trees&query=%24.total&url=https%3A%2F%2Fpublic.offset.earth%2Fusers%2Flemaur%2Ftrees)](https://ecologi.com/lemaur?r=6012e849de97da001ddfd6c9)

## What's Included
- [Rector](https://github.com/rectorphp/rector)
- [Pest](https://pestphp.com/)
- [Dusk](https://laravel.com/docs/8.x/dusk)
- [Larastan](https://github.com/nunomaduro/larastan)
- [Laravel Debugbar](https://github.com/barryvdh/laravel-debugbar)
- [Laravel Ide Helper](https://github.com/barryvdh/laravel-ide-helper)
- [Php Cs Fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer)
- [Analyzer](https://github.com/GrahamCampbell/Analyzer)
- [Infection](https://github.com/infection/infection)
- [Phpunit SpeedTrap](https://github.com/johnkary/phpunit-speedtrap)
- [Laravel Dusk](https://github.com/laravel/dusk)
- [Mockery](https://github.com/mockery/mockery)
- [Collision](https://github.com/nunomaduro/collision)
- [Larastan](https://github.com/nunomaduro/larastan)
- [Laravel Mojito](https://github.com/nunomaduro/laravel-mojito)
- [Pest](https://pestphp.com)
- [Phpunit](https://github.com/sebastianbergmann/phpunit)
- [Rector](https://github.com/rectorphp/rector)
- [Security Advisories](https://github.com/Roave/SecurityAdvisories)
- [Laravel Ray](https://github.com/spatie/laravel-ray)

## Support Me

Expand All @@ -36,63 +50,115 @@ composer require --dev lemaur/toolbox
```

Launch the installation:
> Be careful, this command (with `--force` option) will overwrite [existing files](https://github.com/leMaur/toolbox/blob/master/src/Commands/PublishCommand.php#L38) in your project.
> Be careful, this package was created to be used on a fresh new Laravel project.
> Commands listed below will OVERWRITE your existing files!
If you install this package in a fresh Laravel installation, you can simply run:

```bash
php artisan toolbox:install
```
php artisan toolbox:install --test-suites --force

⬇️ configure only Pest and Dusk test suites. [Those files will be overwritten](/src/Commands/PublishCommand.php#L22).
```bash
php artisan toolbox:install --test-suites
```

Otherwise, you can install only the group of files you may need without test suites:
Otherwise, you can install only the group of files you need without test suites:

⬇️ will overwrite [phpstan.neon](/src/Commands/PublishCommand.php#L24).
```bash
php artisan toolbox:install --only="static-analysis"
```
php artisan toolbox:install --force --only="static-analysis"

# or you can specify multiple values
php artisan toolbox:install --force --only="static-analysis" --only="code-style"
or you can specify multiple values, ⬇️ will overwrite [phpstan.neon](/src/Commands/PublishCommand.php#L24) and [.php-cs-fixer.php](/src/Commands/PublishCommand.php#L28).
```bash
php artisan toolbox:install --only="static-analysis" --only="code-style"
```

# Available values:
Available values for the `--only` option:
```bash
- static-analysis
- code-style
- rector
- refactor
- tests
- common
```

Add those scripts to your `composer.json`:
```
```bash
"scripts": {
"post-update-cmd": [
...
"@php artisan clear-compiled",
"@php artisan ide-helper:generate",
"@php artisan ide-helper:meta"
],
"models": "@php artisan ide-helper:models --write",
"analyse": "./vendor/bin/phpstan analyse --memory-limit=2G",
"rector": "./vendor/bin/rector process",
"refactor": "./vendor/bin/rector process",
"format": "./vendor/bin/php-cs-fixer fix --allow-risky=yes",
"test": "./vendor/bin/pest --coverage --min=100 --coverage-html=.coverage --coverage-clover=coverage.xml"
"paratest": "./vendor/bin/pest --parallel --coverage --min=100 --coverage-html=.coverage --coverage-clover=coverage.xml"
"test": "./vendor/bin/pest --exclude-group=e2e",
"test:fast": "./vendor/bin/pest --exclude-group=e2e --parallel",
"test:coverage": "./vendor/bin/pest --exclude-group=e2e --coverage --min=100 --coverage-html=.coverage --coverage-clover=coverage.xml",
"test:e2e": "@php artisan pest:dusk",
"test:mutation": "XDEBUG_MODE=coverage ./vendor/bin/infection --test-framework=pest --show-mutations"
}
```

If you use a continuous integration, you can run your test with a [custom printer](https://github.com/mheap/phpunit-github-actions-printer):
```
# an example from Github Actions
- name: Run Tests
run: ./vendor/bin/pest --printer mheap\\GithubActionsReporter\\Printer --coverage --min=100 --coverage-html=.coverage --coverage-clover=coverage.xml
Allow plugins to be executed by Composer, by putting these lines on `composer.json`:
```bash
"config": {
...
"allow-plugins": {
"phpstan/extension-installer": true,
"pestphp/pest-plugin": true
}
}
```

## Available Commands

Generate PHPDoc on your models (helpful for static analysis) [for more info](https://github.com/barryvdh/laravel-ide-helper#automatic-phpdocs-for-models)
```bash
composer models
```
# Analyse
composer analyse

# Run Rector
composer rector
Run code refactoring [for more info](https://github.com/rectorphp/rector)
```bash
composer refactor
```

# Run Code Style Formatting
Run code style formatting [for more info](https://github.com/FriendsOfPHP/PHP-CS-Fixer)
```bash
composer format
```

Run static analysis [for more info](https://github.com/nunomaduro/larastan)
```bash
composer analyse
```

# Run tests
Run tests [for more info](https://pestphp.com)
```bash
composer test
```

Run tests with coverage [for more info](https://pestphp.com/docs/coverage)
```bash
composer test:coverage
```

Run e2e tests [for more info](https://pestphp.com/docs/plugins/laravel#laravel-dusk)
```bash
composer test:e2e
```

Run mutation tests [for more info](https://infection.github.io/guide)
```bash
composer test:mutation
```

## Changelog

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
Expand Down
34 changes: 20 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
{
"name": "lemaur/toolbox",
"description": "",
"description": "Toolbox full of useful packages to keep your Laravel project compliant with your coding standards.",
"keywords": [
"lemaur",
"laravel",
"toolbox"
"toolbox",
"rector",
"pest",
"dusk",
"phpstan",
"php-cs-fixer",
"code style",
"refactor",
"testing",
"tests",
"static analysis"
],
"homepage": "https://github.com/lemaur/toolbox",
"license": "MIT",
Expand All @@ -17,21 +27,17 @@
],
"require": {
"php": "^8.0",
"barryvdh/laravel-debugbar": "^3.5",
"barryvdh/laravel-debugbar": "^3.0",
"barryvdh/laravel-ide-helper": "^2.0",
"ergebnis/phpstan-rules": "^1.0",
"fakerphp/faker": "^1.14",
"friendsofphp/php-cs-fixer": "^v3.0",
"graham-campbell/analyzer": "^3.0",
"illuminate/contracts": "^8.37",
"jasonmccreary/laravel-test-assertions": "^2.0",
"illuminate/contracts": "^8.0|^9.0",
"infection/infection": "^0.26.4",
"johnkary/phpunit-speedtrap": "^v4.0",
"laravel/dusk": "^6.15",
"mheap/phpunit-github-actions-printer": "^1.5",
"mockery/mockery": "^1.4",
"nunomaduro/collision": "^5.3",
"nunomaduro/larastan": "^1.0",
"laravel/dusk": "^6.0",
"nunomaduro/larastan": "^1.0|^2.0",
"nunomaduro/laravel-mojito": "^0.2.8",
"orchestra/testbench": "^6.15",
"pestphp/pest": "^1.0",
"pestphp/pest-plugin-faker": "^1.0",
"pestphp/pest-plugin-laravel": "^1.0",
Expand All @@ -40,10 +46,10 @@
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-strict-rules": "^1.0",
"phpunit/phpunit": "^9.3",
"rector/rector": "^0.12",
"roave/security-advisories": "dev-latest",
"spatie/laravel-package-tools": "^1.4.3",
"spatie/laravel-ray": "^1.9",
"spatie/laravel-ray": "^1.0",
"spatie/pest-plugin-snapshots": "^1.0",
"spatie/pest-plugin-test-time": "^1.0"
},
Expand Down
Loading

0 comments on commit 1b184a5

Please sign in to comment.