paragonie/corner
Corner provides extended PHP exceptions/errors with richer context: helpful long-form messages, source code snippets around the failure, and support links. Inspired by Rust-style diagnostics, useful even outside UI error pages.
Pros:
App\Exceptions\Handler) and debugging needs (e.g., Whoops alternatives).Throwable interface, ensuring backward compatibility with Laravel’s exception stack.Cons:
render() hooks for HTTP responses).paragonie/corner).App\Exceptions\CustomException) can extend Corner\Exception for enhanced debugging.ExceptionHandler expects render() methods; Corner focuses on structured data (not UI). Workaround:
getHelpfulMessage() in logs (Monolog) or API responses (JSON).Whoops for user-facing errors while using Corner for internal diagnostics.Throwable changes). Test with phpunit/phpunit@^9.5.getSnippet() uses file reading (may slow down high-throughput APIs). Cache snippets if used frequently.composer audit).getHelpfulMessage() map to JSON/Laravel’s response()->json()?symfony/error-handler or spatie/laravel-ignition for Laravel-native solutions.App\Exceptions\Handler to leverage Corner for structured errors.DatabaseException, ValidationException).getHelpfulMessage() in logs (via custom processor).getHelpfulMessage() in response()->json() for debug endpoints (e.g., /debug/error).getSnippet() in command error handling for better debugging.paragonie/corner to composer.json (dev/prod).App\Exceptions\CornerException) extending Corner\Exception.App\Exceptions\Handler to use getHelpfulMessage() in logs/API responses.public function render($request, Throwable $exception)
{
if ($exception instanceof Corner\Exception) {
return response()->json([
'error' => $exception->getHelpfulMessage(),
'snippet' => $exception->getSnippet(2, 2),
]);
}
// Fallback to default Laravel handling
}
Corner-extended ones.symfony/error-handler or whoops.HttpException, QueryException).getSnippet() may fail if source files are not readable (e.g., Docker containers). Use realpath() checks.Corner support to Monolog handlers.getSnippet, getHelpfulMessage).getSupportLink() pointing to docs or runbooks.getSnippet() is I/O-bound (file reads). Mitigate by:
getMessage() only).Throwable).5xx errors).| Failure Scenario | Impact | Mitigation |
|---|---|---|
getSnippet() fails (file missing) |
Error messages lack context | Fallback to getMessage() + stack trace |
| PHP 8.2+ deprecations | Package breaks in new Laravel | Pin to paragonie/corner:^2.0 |
| Abandoned package | No security updates | Fork or switch to symfony/error-handler |
| Overly verbose errors | API responses bloat | Filter getHelpfulMessage() in prod |
Corner-compatible exceptions.getSnippet() usage in debugging.Corner for new exceptions.Corner-extended ones.Corner usage in custom exceptions.How can I help you explore Laravel packages today?