This package is a Laravel Pint preset for Proxify projects.
You can install the package via composer:
composer require proxify/proxify-php-code-style --dev
// checks new and modified files if they follow coding standar
sh vendor/bin/proxify-cs-checker
// fixes all project php files
php vendor/bin/proxify-cs-fixer
// fixes selected path files
php vendor/bin/proxify-cs-fixer app/Models
// fixes selected files
php vendor/bin/proxify-cs-fixer app/Models/User.php app/Models/Developer.php
These commands will use proxify code style rules by default, which are made on top of laravel preset. For more details you can check laravel pint docs Although it's not recommended, you still can use laravel pint commands directly as well as custom pint.json config file.
To prevent Git from automatically changing line endings, please modify your Git configuration.
git config --global core.autocrlf input
This will change CRLF line separator to LF. ( Linux based )
Install Laravel pint plugin: https://marketplace.visualstudio.com/items?itemName=open-southeners.laravel-pint
Add code style config path to .vscode/settings.json
"laravel-pint.configPath": "vendor/proxify/proxify-php-code-style/pint.json"
Create a new File watcher.
// Pint file watcher settings
$ProjectFileDir$/vendor/bin/proxify-cs-fixer
$FileRelativePath$
$FileRelativePath$
$ProjectFileDir$
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
To make phpstorm ctrl+alt+L hotkey work similar to pint configs, adjust code style by setting laravel and update
“Wrapping and Braces“->”Array initializer”->“align key-value pairs”
“Spaces“->”Around operators”->”Concatenation(.)”
Disable PHP
in the reformat code setting.
create a file in .github/workflows/laravel_checks.yml
or add the below step to your existing jobs workflow
laravel-code-style:
name: Code Style
if: github.ref_name != 'master'
runs-on: "ubuntu-20.04"
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Cache Composer cache directory
uses: actions/cache@v2
with:
path: ~/.composer/cache/files
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ env.php_version }}"
extensions: "${{ env.php_extensions }}"
tools: composer:v2.4
- name: Install dependencies
run: composer install --no-scripts --no-progress --no-suggest --prefer-dist --optimize-autoloader
- name: Code style check
run: |
sh ./vendor/bin/proxify-cs-checker
If you get an error like this:
env: php: No such file or directory
Process finished with exit code 127
Remove value of Environment variables
, in the Pint File Watcher settings.
install pre-commit on your PC then run the command below on your project root to enable pre-commit hook
pre-commit install
Add this to your .pre-commit-config.yaml
repos:
- repo: local
hooks:
- id: laravel-pint
name: laravel-pint
entry: ./vendor/bin/proxify-cs-pre-commit
language: script
types: [php]
pass_filenames: false
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.