Code Style Pint - v1.1.0
IDE Integration Guide
This guide covers how to integrate Laravel Pint with the ArtisanPack UI code style in popular IDEs and editors.
PhpStorm / JetBrains IDEs
Method 1: External Tool
- Go to Settings/Preferences > Tools > External Tools
- Click the + button to add a new tool
- Configure the tool:
- Name:
Pint - Description:
Format with Laravel Pint - Program:
$ProjectFileDir$/vendor/bin/pint - Arguments:
$FilePath$ - Working directory:
$ProjectFileDir$
- Name:
- Click OK to save
Usage: Right-click on a file or folder > External Tools > Pint
Method 2: File Watcher (Auto-format on Save)
- Go to Settings/Preferences > Tools > File Watchers
- Click the + button and select Custom
- Configure the watcher:
- Name:
Laravel Pint - File type:
PHP - Scope:
Project Files - Program:
$ProjectFileDir$/vendor/bin/pint - Arguments:
$FilePath$ - Output paths to refresh:
$FilePath$ - Working directory:
$ProjectFileDir$
- Name:
- Under Advanced Options:
- Uncheck "Auto-save edited files to trigger the watcher"
- Check "Trigger the watcher on external changes"
- Click OK to save
Method 3: Keyboard Shortcut
- Set up Pint as an External Tool (Method 1)
- Go to Settings/Preferences > Keymap
- Search for "Pint" under External Tools
- Right-click and select Add Keyboard Shortcut
- Assign your preferred shortcut (e.g.,
Ctrl+Alt+LorCmd+Shift+P)
PhpStorm Code Style Import
To align PhpStorm's built-in formatter with Pint:
- Go to Settings/Preferences > Editor > Code Style > PHP
- Click the gear icon > Import Scheme > PHP-CS-Fixer
- Select your
pint.jsonfile
Note: This provides approximate alignment; always use Pint for final formatting.
Visual Studio Code
Laravel Pint Extension
- Install the Laravel Pint extension from the VS Code marketplace
- Configure in
settings.json:
{
"laravel-pint.enable": true,
"laravel-pint.configPath": "pint.json",
"laravel-pint.formatOnSave": true,
"laravel-pint.fallbackToPsr12": false
}
Alternative: Run on Save Extension
- Install the Run on Save extension
- Add to
settings.json:
{
"emeraldwalk.runonsave": {
"commands": [
{
"match": "\\.php$",
"cmd": "${workspaceFolder}/vendor/bin/pint ${file}"
}
]
}
}
Format on Save with Tasks
- Create
.vscode/tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "Format with Pint",
"type": "shell",
"command": "./vendor/bin/pint",
"args": ["${file}"],
"presentation": {
"reveal": "silent"
},
"problemMatcher": []
}
]
}
- Bind to a keyboard shortcut in
keybindings.json:
{
"key": "ctrl+shift+f",
"command": "workbench.action.tasks.runTask",
"args": "Format with Pint",
"when": "editorLangId == php"
}
Sublime Text
Using Build System
- Go to Tools > Build System > New Build System
- Add the following configuration:
{
"shell_cmd": "${project_path}/vendor/bin/pint $file",
"selector": "source.php",
"working_dir": "${project_path}"
}
- Save as
Pint.sublime-build
Usage: Press Ctrl+B (or Cmd+B on Mac) to format the current file.
Using Package: SublimeLinter-contrib-pint
- Install via Package Control
- Configure in Sublime settings
Vim / Neovim
Using ALE (Asynchronous Lint Engine)
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
Using null-ls.nvim (Neovim)
local null_ls = require("null-ls")
null_ls.setup({
sources = {
null_ls.builtins.formatting.pint.with({
command = "./vendor/bin/pint",
}),
},
})
Manual Command
Add to .vimrc:
autocmd FileType php nnoremap <buffer> <leader>f :!./vendor/bin/pint %<CR>
Emacs
Using php-cs-fixer.el
(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)))
Git Hooks
Pre-commit Hook
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
Using Husky (npm)
- Install Husky:
npm install husky --save-dev
npx husky install
- Add pre-commit hook:
npx husky add .husky/pre-commit "./vendor/bin/pint --dirty"
Using CaptainHook (Composer)
- Install CaptainHook:
composer require --dev captainhook/captainhook
- Configure
captainhook.json:
{
"pre-commit": {
"actions": [
{
"action": "./vendor/bin/pint --dirty"
}
]
}
}
Troubleshooting
Pint Not Found
Ensure Pint is installed:
composer require laravel/pint --dev
Configuration Not Applied
Verify pint.json exists in your project root:
php artisan artisanpack:publish-pint-config
Conflicts with Other Formatters
Disable other PHP formatters when using Pint:
- PhpStorm: Disable built-in PHP formatter for affected files
- VS Code: Set
"editor.formatOnSave": falsefor PHP files if using Pint extension
Slow Performance
For large files or projects:
- Use
--dirtyflag to only format changed files - Exclude unnecessary directories in
pint.json - Consider running Pint only on staged files via git hooks