cli/cmd/php/php.go
Snider e4d79ce952 feat(php): add quality commands and split cmd/php for maintainability
Add new PHP quality commands:
- psalm: Psalm static analysis with auto-fix support
- audit: Security audit for composer and npm dependencies
- security: Filesystem security checks (.env exposure, permissions)
- qa: Full QA pipeline with quick/standard/full stages
- rector: Automated code refactoring with dry-run
- infection: Mutation testing

Split cmd/php/php.go (2k+ lines) into logical files:
- php.go: Styles and command registration
- php_dev.go: dev, logs, stop, status, ssl
- php_build.go: build, serve, shell
- php_quality.go: test, fmt, analyse, psalm, audit, security, qa, rector, infection
- php_packages.go: packages link/unlink/update/list
- php_deploy.go: deploy commands

QA pipeline improvements:
- Suppress tool output noise in pipeline mode
- Show actionable "To fix:" suggestions with commands

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 23:58:03 +00:00

121 lines
3.2 KiB
Go

// Package php provides Laravel/PHP development commands.
package php
import (
"github.com/charmbracelet/lipgloss"
"github.com/host-uk/core/cmd/shared"
"github.com/leaanthony/clir"
)
// Style aliases from shared
var (
successStyle = shared.SuccessStyle
errorStyle = shared.ErrorStyle
dimStyle = shared.DimStyle
linkStyle = shared.LinkStyle
)
// Service colors for log output
var (
phpFrankenPHPStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color("#6366f1")) // indigo-500
phpViteStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color("#eab308")) // yellow-500
phpHorizonStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color("#f97316")) // orange-500
phpReverbStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color("#8b5cf6")) // violet-500
phpRedisStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color("#ef4444")) // red-500
phpStatusRunning = lipgloss.NewStyle().
Foreground(lipgloss.Color("#22c55e")). // green-500
Bold(true)
phpStatusStopped = lipgloss.NewStyle().
Foreground(lipgloss.Color("#6b7280")) // gray-500
phpStatusError = lipgloss.NewStyle().
Foreground(lipgloss.Color("#ef4444")). // red-500
Bold(true)
)
// QA command styles
var (
phpQAPassedStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color("#22c55e")). // green-500
Bold(true)
phpQAFailedStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color("#ef4444")). // red-500
Bold(true)
phpQAWarningStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color("#f59e0b")). // amber-500
Bold(true)
phpQAStageStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color("#6366f1")). // indigo-500
Bold(true)
phpSecurityCriticalStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color("#ef4444")). // red-500
Bold(true)
phpSecurityHighStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color("#f97316")). // orange-500
Bold(true)
phpSecurityMediumStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color("#f59e0b")) // amber-500
phpSecurityLowStyle = lipgloss.NewStyle().
Foreground(lipgloss.Color("#6b7280")) // gray-500
)
// AddPHPCommands adds PHP/Laravel development commands.
func AddPHPCommands(parent *clir.Cli) {
phpCmd := parent.NewSubCommand("php", "Laravel/PHP development tools")
phpCmd.LongDescription("Manage Laravel development environment with FrankenPHP.\n\n" +
"Services orchestrated:\n" +
" - FrankenPHP/Octane (port 8000, HTTPS on 443)\n" +
" - Vite dev server (port 5173)\n" +
" - Laravel Horizon (queue workers)\n" +
" - Laravel Reverb (WebSocket, port 8080)\n" +
" - Redis (port 6379)")
// Development
addPHPDevCommand(phpCmd)
addPHPLogsCommand(phpCmd)
addPHPStopCommand(phpCmd)
addPHPStatusCommand(phpCmd)
addPHPSSLCommand(phpCmd)
// Build & Deploy
addPHPBuildCommand(phpCmd)
addPHPServeCommand(phpCmd)
addPHPShellCommand(phpCmd)
// Quality (existing)
addPHPTestCommand(phpCmd)
addPHPFmtCommand(phpCmd)
addPHPAnalyseCommand(phpCmd)
// Quality (new)
addPHPPsalmCommand(phpCmd)
addPHPAuditCommand(phpCmd)
addPHPSecurityCommand(phpCmd)
addPHPQACommand(phpCmd)
addPHPRectorCommand(phpCmd)
addPHPInfectionCommand(phpCmd)
// Package Management
addPHPPackagesCommands(phpCmd)
// Deployment
addPHPDeployCommands(phpCmd)
}