lemaur/toolbox

Toolbox full of useful packages to keep your Laravel project compliant with your coding standards.

Fund package maintenance!
lemaur

4.2.0 2022-12-29 10:14 UTC

README

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 Total Downloads License GitHub PHPMD GitHub Sponsors Trees

What's Included

Support Me

Hey folks,

Do you like this package? Do you find it useful, and it fits well in your project?

I am glad to help you, and I would be so grateful if you considered supporting my work.

You can even choose 😃:

Installation

Install the package via composer:

composer require lemaur/toolbox --dev 

if you still using php8.0 you should use:

composer require "lemaur/toolbox:^3.2" --dev

Launch the installation:

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:

php artisan toolbox:install

⬇️ configure only Pest and Dusk test suites. Those files will be overwritten.

php artisan toolbox:install --test-suites

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

⬇️ will overwrite phpstan.neon.

php artisan toolbox:install --only="static-analysis"

or you can specify multiple values, ⬇️ will overwrite phpstan.neon and pint.json.

php artisan toolbox:install --only="static-analysis" --only="code-style"

Available values for the --only option:

- static-analysis
- code-style
- refactor
- tests
- common

Add those scripts to your composer.json:

"scripts": {
    "ide-helper": [
        "@php artisan ide-helper:models --write-mixin --reset",
        "@php artisan ide-helper:generate",
        "@php artisan ide-helper:eloquent",
        "@php artisan ide-helper:meta"
    ],
    "analyse": "./vendor/bin/phpstan analyse --memory-limit=2G",
    "refactor": "./vendor/bin/rector process  --memory-limit=2G",
    "format": "./vendor/bin/pint",
    "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=50 --coverage-html=.coverage --coverage-clover=coverage.xml",
    "test:e2e": "@php artisan pest:dusk",
    "test:mutation": [
        "Composer\\Config::disableProcessTimeout",
        "XDEBUG_MODE=coverage vendor/bin/infection --show-mutations --threads=4 --only-covering-test-cases --min-msi=25 --min-covered-msi=85 --test-framework=pest --test-framework-options='--configuration=phpunit.xml --exclude-group=e2e'"
    ]
}

Allow plugins to be executed by Composer, by putting these lines on composer.json:

"config": {
    ...
    "allow-plugins": {
        "phpstan/extension-installer": true,
        "pestphp/pest-plugin": true,
        "infection/extension-installer": true
    }
}

Available Commands

Generate PHPDoc for your models and
other (helpful for your IDE and static analysis tools) for more info

composer ide-helpers

Run code refactoring for more info

composer refactor

Run code style formatting for more info

composer format

Run static analysis for more info

composer analyse

Run tests for more info

composer test

Run tests with coverage for more info

composer test:coverage

Run e2e tests for more info

composer test:e2e

Run mutation tests for more info

composer test:mutation

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.