artisanpack-ui/code-style-pint
Laravel Pint preset matching ArtisanPack UI coding standards. Publishes a ready-made pint.json for apps or generates it via builder for packages. Optional WordPress-style spacing support via PHP-CS-Fixer stubs and commands.
This guide covers how to integrate Laravel Pint with the ArtisanPack UI code style in popular IDEs and editors.
PintFormat with Laravel Pint$ProjectFileDir$/vendor/bin/pint$FilePath$$ProjectFileDir$Usage: Right-click on a file or folder > External Tools > Pint
Laravel PintPHPProject Files$ProjectFileDir$/vendor/bin/pint$FilePath$$FilePath$$ProjectFileDir$Ctrl+Alt+L or Cmd+Shift+P)To align PhpStorm's built-in formatter with Pint:
pint.json fileNote: This provides approximate alignment; always use Pint for final formatting.
settings.json:{
"laravel-pint.enable": true,
"laravel-pint.configPath": "pint.json",
"laravel-pint.formatOnSave": true,
"laravel-pint.fallbackToPsr12": false
}
settings.json:{
"emeraldwalk.runonsave": {
"commands": [
{
"match": "\\.php$",
"cmd": "${workspaceFolder}/vendor/bin/pint ${file}"
}
]
}
}
.vscode/tasks.json:{
"version": "2.0.0",
"tasks": [
{
"label": "Format with Pint",
"type": "shell",
"command": "./vendor/bin/pint",
"args": ["${file}"],
"presentation": {
"reveal": "silent"
},
"problemMatcher": []
}
]
}
keybindings.json:{
"key": "ctrl+shift+f",
"command": "workbench.action.tasks.runTask",
"args": "Format with Pint",
"when": "editorLangId == php"
}
{
"shell_cmd": "${project_path}/vendor/bin/pint $file",
"selector": "source.php",
"working_dir": "${project_path}"
}
Pint.sublime-buildUsage: Press Ctrl+B (or Cmd+B on Mac) to format the current file.
Add to your .vimrc or init.vim:
let g:ale_fixers = {
\ 'php': ['pint'],
\}
let g:ale_php_pint_executable = './vendor/bin/pint'
let g:ale_fix_on_save = 1
local null_ls = require("null-ls")
null_ls.setup({
sources = {
null_ls.builtins.formatting.pint.with({
command = "./vendor/bin/pint",
}),
},
})
Add to .vimrc:
autocmd FileType php nnoremap <buffer> <leader>f :!./vendor/bin/pint %<CR>
(use-package php-cs-fixer
:config
(setq php-cs-fixer-command "./vendor/bin/pint"))
(add-hook 'php-mode-hook
(lambda ()
(add-hook 'before-save-hook 'php-cs-fixer-before-save nil t)))
Create .git/hooks/pre-commit:
#!/bin/sh
# Get staged PHP files
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.php$')
if [ -n "$STAGED_FILES" ]; then
echo "Running Pint on staged files..."
# Run Pint on staged files
echo "$STAGED_FILES" | xargs ./vendor/bin/pint
# Re-add formatted files
echo "$STAGED_FILES" | xargs git add
fi
exit 0
Make it executable:
chmod +x .git/hooks/pre-commit
npm install husky --save-dev
npx husky install
npx husky add .husky/pre-commit "./vendor/bin/pint --dirty"
composer require --dev captainhook/captainhook
captainhook.json:{
"pre-commit": {
"actions": [
{
"action": "./vendor/bin/pint --dirty"
}
]
}
}
Ensure Pint is installed:
composer require laravel/pint --dev
Verify pint.json exists in your project root:
php artisan artisanpack:publish-pint-config
Disable other PHP formatters when using Pint:
"editor.formatOnSave": false for PHP files if using Pint extensionFor large files or projects:
--dirty flag to only format changed filespint.jsonHow can I help you explore Laravel packages today?