collision
💥 Collision is a beautiful error reporting tool for command-line applications
Top Related Projects
Laravel is a web application framework with expressive, elegant syntax. We’ve already laid the foundation for your next big idea — freeing you to create without sweating the small things.
The Symfony PHP framework
Yii 2: The Fast, Secure and Professional PHP Framework
CakePHP: The Rapid Development Framework for PHP - Official Repository
Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.
Open Source PHP Framework (originally from EllisLab)
Quick Overview
Collision is a beautiful and customizable error reporting tool for PHP applications. It provides a user-friendly interface for displaying errors and exceptions, making debugging easier and more efficient for developers.
Pros
- Highly customizable error reporting interface
- Supports various PHP frameworks, including Laravel
- Integrates well with popular testing frameworks like PHPUnit
- Provides detailed stack traces and context for errors
Cons
- May have a slight performance impact in production environments
- Requires PHP 7.2 or higher, which might not be suitable for older projects
- Some advanced features may require additional configuration
Code Examples
- Basic usage in a PHP script:
use NunoMaduro\Collision\Provider;
$provider = new Provider();
$provider->register();
// Your code here
- Integration with Laravel:
// In config/app.php
'providers' => [
// ...
NunoMaduro\Collision\Adapters\Laravel\CollisionServiceProvider::class,
],
- Custom error handler:
use NunoMaduro\Collision\Handler;
$handler = new Handler();
$handler->setEditor('sublime');
$handler->setTheme('dark');
set_exception_handler([$handler, 'handle']);
Getting Started
To get started with Collision, follow these steps:
-
Install Collision using Composer:
composer require nunomaduro/collision --dev
-
For a basic PHP project, add the following code to your entry point:
use NunoMaduro\Collision\Provider; require __DIR__ . '/vendor/autoload.php'; (new Provider)->register(); // Your application code here
-
For Laravel projects, Collision will be automatically discovered and registered.
-
Run your PHP script or Laravel application, and any errors or exceptions will be displayed using Collision's beautiful error reporting interface.
Competitor Comparisons
Laravel is a web application framework with expressive, elegant syntax. We’ve already laid the foundation for your next big idea — freeing you to create without sweating the small things.
Pros of Laravel
- Full-featured PHP web application framework with extensive ecosystem
- Provides a complete development environment out-of-the-box
- Includes built-in tools for routing, authentication, and database management
Cons of Laravel
- Larger codebase and more complex setup compared to Collision
- May include unnecessary features for smaller projects
- Steeper learning curve for beginners
Code Comparison
Laravel (routes/web.php):
Route::get('/', function () {
return view('welcome');
});
Collision (src/Writer.php):
public function write(Throwable $throwable): void
{
$this->renderTitle($throwable);
$this->renderEditor($throwable);
}
Key Differences
- Laravel is a full-stack framework, while Collision is a standalone error handling package
- Laravel provides a complete application structure, whereas Collision focuses on improving error reporting
- Collision can be integrated into Laravel projects to enhance error handling capabilities
Use Cases
- Laravel: Building complex web applications with multiple features
- Collision: Improving error reporting in PHP projects, including Laravel applications
Community and Support
- Laravel has a larger community and more extensive documentation
- Collision, while smaller, is actively maintained and specifically targets error handling improvements
The Symfony PHP framework
Pros of Symfony
- Comprehensive full-stack framework with a wide range of components
- Large, active community and extensive documentation
- Highly modular and flexible architecture
Cons of Symfony
- Steeper learning curve due to its complexity
- Potentially heavier and slower for smaller projects
- More setup and configuration required
Code Comparison
Symfony (Error Handling):
use Symfony\Component\ErrorHandler\Debug;
Debug::enable();
try {
// Your code here
} catch (\Exception $e) {
// Handle exception
}
Collision (Error Handling):
use NunoMaduro\Collision\Provider;
(new Provider)->register();
// Your code here
Summary
Symfony is a full-stack PHP framework offering a comprehensive set of tools and components for building complex web applications. It provides extensive functionality but comes with a steeper learning curve and more setup time.
Collision, on the other hand, is a lightweight error handling package specifically designed for console applications. It offers a simpler, more focused solution for improving error reporting and debugging in command-line environments.
While Symfony provides a complete ecosystem for web development, Collision excels in its specific niche of enhancing console application error handling. The choice between the two depends on the project's scope, complexity, and specific requirements.
Yii 2: The Fast, Secure and Professional PHP Framework
Pros of Yii2
- Full-featured PHP framework with extensive documentation and community support
- Built-in security features and robust database abstraction layer
- Modular architecture allowing for easy extension and customization
Cons of Yii2
- Steeper learning curve due to its comprehensive nature
- Heavier footprint compared to lightweight libraries
- May be overkill for small projects or simple command-line applications
Code Comparison
Yii2 (Controller action):
public function actionIndex()
{
$users = User::find()->all();
return $this->render('index', ['users' => $users]);
}
Collision (Command output):
$this->error('An error occurred!');
$this->info('Operation completed successfully.');
$this->table(['Name', 'Email'], [['John', 'john@example.com']]);
Key Differences
Yii2 is a full-stack PHP framework designed for web application development, while Collision is a lightweight error handling and CLI output library. Yii2 offers a complete ecosystem for building complex web applications, including routing, database management, and view rendering. Collision, on the other hand, focuses on enhancing error reporting and providing a better CLI experience for PHP applications.
Yii2 is better suited for large-scale web projects that require a comprehensive framework, while Collision is ideal for improving error handling and CLI output in various PHP applications, including those built with other frameworks or libraries.
CakePHP: The Rapid Development Framework for PHP - Official Repository
Pros of CakePHP
- Full-featured MVC framework with a wide range of built-in tools and components
- Extensive documentation and large community support
- Follows convention over configuration, promoting rapid development
Cons of CakePHP
- Steeper learning curve due to its comprehensive nature
- Heavier and potentially slower for smaller projects
- Less flexibility compared to more modular frameworks
Code Comparison
CakePHP (Controller example):
class ArticlesController extends AppController
{
public function index()
{
$articles = $this->Articles->find('all');
$this->set(compact('articles'));
}
}
Collision (Error handling example):
use NunoMaduro\Collision\Provider;
$provider = new Provider();
$provider->register();
// Your application code here
Summary
CakePHP is a full-stack PHP framework offering a comprehensive set of tools for web application development. It provides a robust structure and follows the MVC pattern, making it suitable for large-scale projects. However, this comes at the cost of a steeper learning curve and potentially slower performance for smaller applications.
Collision, on the other hand, is a specialized error handling package designed to improve the developer experience when dealing with errors and exceptions in PHP. It focuses on providing clear and informative error messages, making it easier to debug issues in your code.
While CakePHP offers a complete framework solution, Collision is a targeted tool that can be integrated into various PHP projects to enhance error reporting and debugging capabilities.
Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.
Pros of Slim
- Full-featured micro-framework for building web applications and APIs
- Lightweight and flexible, allowing developers to add only the components they need
- Extensive middleware ecosystem for easy integration of additional functionality
Cons of Slim
- Steeper learning curve compared to Collision, which focuses on error handling
- Requires more setup and configuration for basic functionality
- May be overkill for simple projects or those primarily focused on error handling
Code Comparison
Slim (Route definition):
$app->get('/hello/{name}', function (Request $request, Response $response, array $args) {
$name = $args['name'];
$response->getBody()->write("Hello, $name");
return $response;
});
Collision (Error handling):
$handler = new Handler(new Writer());
$handler->register();
throw new Exception('Oops! Something went wrong.');
While Slim is a comprehensive micro-framework for building web applications, Collision focuses specifically on error and exception handling in PHP applications. Slim provides a complete toolkit for routing, middleware, and request/response handling, whereas Collision aims to improve the developer experience by providing more informative and visually appealing error messages during development.
Open Source PHP Framework (originally from EllisLab)
Pros of CodeIgniter4
- Full-featured PHP web framework with a complete MVC architecture
- Extensive documentation and large community support
- Built-in security features and database abstraction layer
Cons of CodeIgniter4
- Steeper learning curve for beginners compared to Collision
- Heavier and more complex, which may be overkill for small projects
- Less focused on CLI applications and error handling
Code Comparison
CodeIgniter4 (Controller example):
<?php
namespace App\Controllers;
class Home extends BaseController
{
public function index()
{
return view('welcome_message');
}
}
Collision (Error handling example):
use NunoMaduro\Collision\Provider;
$provider = new Provider();
$provider->register();
// Your application code here
CodeIgniter4 is a comprehensive web framework, while Collision focuses on error handling and CLI output formatting. CodeIgniter4 offers a complete solution for web development, including routing, database management, and security features. Collision, on the other hand, excels in providing beautiful error reporting and CLI output for PHP applications.
While CodeIgniter4 is more suitable for full-scale web applications, Collision can be easily integrated into existing projects to enhance error handling and CLI experiences. The choice between the two depends on the specific needs of your project and your familiarity with PHP frameworks.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Collision was created by, and is maintained by Nuno Maduro, and is a package designed to give you beautiful error reporting when interacting with your app through the command line.
- It's included on Laravel, the most popular free, open-source PHP framework in the world.
- Built on top of the Whoops error handler.
- Supports Laravel, Symfony, PHPUnit, and many other frameworks.
Installation & Usage
Requires PHP 8.2+
Require Collision using Composer:
composer require nunomaduro/collision --dev
Version Compatibility
Laravel | Collision | PHPUnit | Pest |
---|---|---|---|
6.x | 3.x | ||
7.x | 4.x | ||
8.x | 5.x | ||
9.x | 6.x | ||
10.x | 6.x | 9.x | 1.x |
10.x | 7.x | 10.x | 2.x |
11.x | 8.x | 10.x | 2.x |
11.x | 8.x | 11.x | 3.x |
As an example, here is how to require Collision on Laravel 8.x:
composer require nunomaduro/collision:^5.0 --dev
No adapter
You need to register the handler in your code:
(new \NunoMaduro\Collision\Provider)->register();
Contributing
Thank you for considering to contribute to Collision. All the contribution guidelines are mentioned here.
You can have a look at the CHANGELOG for constant updates & detailed information about the changes. You can also follow the twitter account for latest announcements or just come say hi!: @enunomaduro
License
Collision is an open-sourced software licensed under the MIT license.
Logo by Caneco.
Top Related Projects
Laravel is a web application framework with expressive, elegant syntax. We’ve already laid the foundation for your next big idea — freeing you to create without sweating the small things.
The Symfony PHP framework
Yii 2: The Fast, Secure and Professional PHP Framework
CakePHP: The Rapid Development Framework for PHP - Official Repository
Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.
Open Source PHP Framework (originally from EllisLab)
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot