spatie/craft-ray
Send debug output from Craft CMS to Ray, Spatie’s desktop debugging app. Inspect arrays, HTML, queries, and more with a consistent API, measure performance, and pause execution. Great for fast feedback across PHP and other languages.
spatie/craft-ray integrates seamlessly with CraftCMS’s debugging ecosystem, leveraging Ray’s cross-language debugging capabilities. It acts as a middleware layer between Craft’s native logging (craft\helpers\Console) and Ray’s desktop UI, making it ideal for teams already using Ray for Laravel/PHP debugging.Craft::$app->getLogger()) without requiring deep architectural changes. This aligns well with Craft’s modular plugin system.APP_ENV=local).Craft::$app->getSecurity()->hashData().8080 by default). Firewall/VPN environments may need configuration.Debugging Workflow:
storage/logs/) for post-mortem analysis?Tooling Alignment:
devMode, Xdebug)?Scaling:
Security:
Maintenance:
spatie/craft-ray package?CraftCMS Ecosystem:
Event::LOG_MESSAGE and Event::REQUEST_HANDLE events to intercept debug output. Works alongside existing plugins like craft/log-viewer.ray() helper (e.g., {{ _debug|ray }} for template variables)../craft migrate/all).Ray Compatibility:
Laravel Synergy:
craftcms/cms or custom integration), Ray’s Laravel support can be unified with Craft’s output via a shared Ray configuration.Pilot Phase:
spatie/craft-ray in a non-production Craft environment.devMode and Xdebug.Gradual Rollout:
Configuration:
config/ray.php (merge with Craft’s config/general.php for environment-specific toggles).return [
'enabled' => getenv('RAY_ENABLED') === 'true',
'channels' => ['*'], // Whitelist/blacklist channels
'sanitize' => [
'fields' => ['password', 'apiToken'],
],
];
| Component | Compatibility Notes |
|---|---|
| Craft CMS | Tested on Craft 4.x; Craft 3.x may require PHP 8.0+ polyfills. |
| PHP Version | Requires PHP 8.1+ (Ray’s PHP client dependency). |
| Ray Desktop App | Must be installed locally (free tier available). |
| Database Drivers | No direct impact, but complex queries may benefit from Ray’s SQL inspection. |
| Third-Party Plugins | Potential conflicts with plugins that log to craft\helpers\Console (e.g., verbb/sunrise). |
Prerequisites:
Installation:
composer require spatie/craft-ray
./craft install/plugin spatie-craft-ray
Configuration:
./craft vendor-publish/spatie/craft-ray.config/app.php:
'modules' => [
'spatie-craft-ray' => [
'enabled' => true,
],
],
Testing:
{{ someVar|ray }}).ray($this->request->getBody())).ray(Craft::$app->getElements()->getContentById(1))).Production Readiness:
.env:
RAY_ENABLED=false
composer.json scripts for CI/CD:
"scripts": {
"debug:ray": "RAY_ENABLED=true craft serve"
}
Package Updates:
spatie/craft-ray for updates (MIT license allows forks if needed).Configuration Drift:
RAY_ENABLED).Deprecation:
composer.json:
"require": {
"spatie/craft-ray": "^1.0",
"spatie/ray": "^1.12.0"
}
Troubleshooting:
RAY_ENABLED and firewall rules (port 8080).ray() to inspect Ray’s internal state (e.g., ray(Ray::getClient()->getConfig())).Documentation:
Escalation Path:
How can I help you explore Laravel packages today?