tourze / backtrace-helper
Backtrace helper
Installs: 4 351
Dependents: 12
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^8.1
- ext-mbstring: *
- spatie/backtrace: ^1.7.1
- symfony/event-dispatcher: ^6.4
- symfony/http-kernel: ^6.4
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^10.0
README
A PHP package for enhanced backtrace handling and exception printing with useful context information.
Features
- Enhanced backtrace information with cleaner output
- Intelligent filtering of irrelevant stack frames in production environments
- Exception printer with rich context information
- Support for context-aware exceptions
- Clean class name formatting (especially for AOP proxies)
- Easy integration with existing PHP applications
Installation
composer require tourze/backtrace-helper
Quick Start
<?php use Tourze\BacktraceHelper\Backtrace; use Tourze\BacktraceHelper\ExceptionPrinter; // Get a formatted backtrace $backtrace = Backtrace::create(); echo $backtrace->toString(); // Print an exception with enhanced information try { // Some code that might throw an exception throw new \Exception("Something went wrong"); } catch (\Throwable $e) { echo ExceptionPrinter::exception($e); } // Create context-aware exceptions class MyException extends \Exception implements \Tourze\BacktraceHelper\ContextAwareInterface { use \Tourze\BacktraceHelper\ContextAwareTrait; } throw new MyException("Error with context", 0, null, ["user_id" => 123]);
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
The MIT License (MIT). Please see License File for more information.