Skip to content

Latest commit

 

History

History
106 lines (82 loc) · 2.07 KB

13.care-for-code.md

File metadata and controls

106 lines (82 loc) · 2.07 KB

Taking care of the code


Laravel Pint

Pint is a package for formatting the code according to Laravel standards.

composer require laravel/pint --dev
./vendor/bin/pint

PHP Insights

PHP Insights: Code analysis for PHP/Laravel PHP Insights Preview

composer require nunomaduro/phpinsights --dev
php artisan vendor:publish --provider="NunoMaduro\PhpInsights\Application\Adapters\Laravel\InsightsServiceProvider"
php artisan insights

Larastan

Larastan finds errors Larastan Preview

composer require nunomaduro/larastan:^2.0 --dev

phpstan.neon or phpstan.neon.dist file in the root of your application

includes:
    - ./vendor/nunomaduro/larastan/extension.neon

parameters:

    paths:
        - app/

    # Level 9 is the highest level
    level: 5
./vendor/bin/phpstan analyse --memory-limit=2G

Tighten Tlint

Tlint is an opinionated code linter.

composer global require tightenco/tlint
tlint format
# option A
$value = 'Hello, World!';

return view('view', compact('value'));

# option B
return view('view', ['value' => 'Hello, World!']);

# option C
return view('view')
    ->with('value', 'Hello, World!');

Bonus: composer command

 "scripts": {

    "phpstan": "./vendor/bin/phpstan analyse --memory-limit=2G",
    "insights": "@php artisan insights --no-interaction --fix -v",
    "pint": "vendor/bin/pint",
    "tlint": "tlint format"
    "analyse": [
        "@pint",
        "@insights",
        "@phpstan",
        "@tlint"
    ]
},
composer analyse

Next