### Ignition UI Development Setup Source: https://github.com/spatie/ignition/blob/main/README.md Steps to set up the development environment for the Spatie Ignition UI. This involves cloning multiple repositories, creating a unified package.json for workspaces, installing dependencies with Yarn, and configuring the project for local testing. ```json { "private": true, "workspaces": [ "ignition-ui", "ignition" ] } ``` ```bash # Clone repositories into a common directory (e.g., ~/code/flare) # cd ~/code/flare # Create package.json # yarn install # In ~/code/flare/ignition-test directory: # composer update # cp .env.example .env # php artisan key:generate # Run development servers # yarn dev in ignition and ignition-ui projects # Access the UI at http://ignition-test.test/ ``` ```php php artisan key:generate ``` -------------------------------- ### Install OpenAI Dependency Source: https://github.com/spatie/ignition/blob/main/README.md Provides the command to install the necessary dependency for using AI-powered solutions with OpenAI. ```bash composer require openai-php/client ``` -------------------------------- ### Install Ignition via Composer Source: https://github.com/spatie/ignition/blob/main/README.md This command installs the Ignition package for PHP projects using Composer, the standard dependency manager for PHP. ```bash composer require spatie/ignition ``` -------------------------------- ### Throwing an Exception Source: https://github.com/spatie/ignition/blob/main/README.md A simple example of how to throw a standard PHP Exception, which would then be caught and displayed by Ignition if registered. ```php throw new Exception('Bye world'); ``` -------------------------------- ### Instantiate OpenAI Solution Provider Source: https://github.com/spatie/ignition/blob/main/README.md Shows how to create an instance of the `OpenAiSolutionProvider`, which requires an OpenAI API key. This provider enables AI-generated solutions for exceptions. ```php use Spatie\Ignition\Solutions\OpenAi\OpenAiSolutionProvider; $aiSolutionProvider = new OpenAiSolutionProvider($openAiKey); ``` -------------------------------- ### Implement Solution Interface Source: https://github.com/spatie/ignition/blob/main/README.md Shows how to create a custom solution by implementing the `Solution` interface. This involves defining methods for the solution's title, description, and documentation links. ```php use Spatie\Ignition\Contracts\Solution; class CustomSolution implements Solution { public function getSolutionTitle(): string { return 'The solution title goes here'; } public function getSolutionDescription(): string { return 'This is a longer description of the solution that you want to show.'; } public function getDocumentationLinks(): array { return [ 'Your documentation' => 'https://your-project.com/relevant-docs-page', ]; } } ``` -------------------------------- ### Register OpenAI Solution Provider Source: https://github.com/spatie/ignition/blob/main/README.md Demonstrates how to register the `OpenAiSolutionProvider` with Ignition to enable AI-powered solutions. This is done via the `addSolutionProviders` method. ```php \Spatie\Ignition\Ignition::make() ->addSolutionProviders([ $aiSolutionProvider, // other solution providers... ]) ->register(); ``` -------------------------------- ### Add Solution Directly to Exception Source: https://github.com/spatie/ignition/blob/main/README.md Illustrates how to make an exception provide its own solution by implementing the `ProvidesSolution` interface. This requires implementing the `getSolution` method. ```php use Spatie\Ignition\Contracts\Solution; use Spatie\Ignition\Contracts\ProvidesSolution; class CustomException extends Exception implements ProvidesSolution { public function getSolution(): Solution { return new CustomSolution(); } } ``` -------------------------------- ### Register Solution Providers Source: https://github.com/spatie/ignition/blob/main/README.md Demonstrates how to register custom solution providers with Ignition. This allows Ignition to utilize your custom logic for finding solutions to exceptions. ```php \Spatie\Ignition\Ignition::make() ->addSolutionProviders([ YourSolutionProvider::class, AnotherSolutionProvider::class, ]) ->register(); ``` -------------------------------- ### Hint Application Type for AI Source: https://github.com/spatie/ignition/blob/main/README.md Shows how to provide the application type to the AI solution provider to improve the quality of suggested solutions. This is done using the `applicationType` method. ```php $aiSolutionProvider->applicationType('WordPress 6.2') ``` -------------------------------- ### Implement Solution Provider Interface Source: https://github.com/spatie/ignition/blob/main/README.md Defines the contract for classes that can provide solutions for given throwables. It includes methods to determine if a solution can be provided and to retrieve the solutions. ```php interface HasSolutionsForThrowable { public function canSolve(Throwable $throwable): bool; /** @return SpatieIgnitionContractsSolution[] */ public function getSolutions(Throwable $throwable): array; } ``` -------------------------------- ### Send Exceptions to Flare Source: https://github.com/spatie/ignition/blob/main/README.md Configures Ignition to send exceptions to Flare. The `runningInProductionEnvironment` method controls whether the error page is displayed or if only the exception is sent to Flare. Requires a Flare API key. ```php \Spatie\Ignition\Ignition::make() ->runningInProductionEnvironment($boolean) ->sendToFlare($yourApiKey) ->register(); ``` -------------------------------- ### Group Custom Context Items for Flare Source: https://github.com/spatie/ignition/blob/main/README.md Enables grouping custom context items by a provided key for better organization and visual differentiation within Flare's interface. ```php use Spatie\FlareClient\Flare; \Spatie\Ignition\Ignition::make() ->runningInProductionEnvironment($boolean) ->sendToFlare($yourApiKey) ->configureFlare(function(Flare $flare) { $flare->group('Custom information', [ 'key' => 'value', 'another key' => 'another value', ]); }) ->register(); ``` -------------------------------- ### Cache OpenAI Requests Source: https://github.com/spatie/ignition/blob/main/README.md Explains how to enable caching for OpenAI requests to avoid sending duplicate error information. This involves using the `useCache` method with a PSR-16 compatible cache implementation. ```php public function useCache(CacheInterface $cache, int $cacheTtlInSeconds = 60 * 60) ``` -------------------------------- ### Set Application Path in Ignition Source: https://github.com/spatie/ignition/blob/main/README.md Configures Ignition to trim a specified application path from all displayed file paths, making the error output cleaner and more focused on relevant parts of the project. ```php \Spatie\Ignition\Ignition::make() ->applicationPath($basePathOfYourApplication) ->register(); ``` -------------------------------- ### Send Custom Context to Flare Source: https://github.com/spatie/ignition/blob/main/README.md Allows adding custom key-value information to exceptions sent to Flare for enhanced debugging. This context is sent along with every exception. ```php use Spatie\FlareClient\Flare; \Spatie\Ignition\Ignition::make() ->runningInProductionEnvironment($boolean) ->sendToFlare($yourApiKey) ->configureFlare(function(Flare $flare) { $flare->context('Tenant', 'My-Tenant-Identifier'); }) ->register(); ``` -------------------------------- ### Register Custom Middleware for Flare Reports Source: https://github.com/spatie/ignition/blob/main/README.md Enables the use of custom middleware classes that implement `FlareMiddleware` to modify exception reports before they are sent to Flare. This allows for dynamic data manipulation. ```php use Spatie\FlareClient\Flare; use Spatie\FlareClient\Report; use Spatie\FlareClient\FlareMiddleware\FlareMiddleware; use Closure; class MyMiddleware implements FlareMiddleware { public function handle(Report $report, Closure $next) { $report->message("{$report->getMessage()}, now modified"); return $next($report); } } \Spatie\Ignition\Ignition::make() ->runningInProductionEnvironment($boolean) ->sendToFlare($yourApiKey) ->configureFlare(function(Flare $flare) { $flare->registerMiddleware([ MyMiddleware::class, ]) }) ->register(); ``` -------------------------------- ### Register Ignition Error Page Source: https://github.com/spatie/ignition/blob/main/README.md This snippet demonstrates the basic registration of the Ignition error page in a PHP application. It requires the autoloader and then calls the make() and register() methods on the Ignition class. ```php use Spatie\Ignition\Ignition; include 'vendor/autoload.php'; Ignition::make()->register(); ``` -------------------------------- ### Anonymize IP Address for Flare Source: https://github.com/spatie/ignition/blob/main/README.md Disables the collection and sending of user IP addresses to Flare, ensuring user privacy by anonymizing this data. ```php use Spatie\FlareClient\Flare; \Spatie\Ignition\Ignition::make() ->runningInProductionEnvironment($boolean) ->sendToFlare($yourApiKey) ->configureFlare(function(Flare $flare) { $flare->anonymizeIp(); }) ->register(); ``` -------------------------------- ### Enable Dark Mode in Ignition Source: https://github.com/spatie/ignition/blob/main/README.md Activates the dark theme for the Ignition error page. This is useful for developers who prefer a darker interface or for environments with low ambient light. ```php \Spatie\Ignition\Ignition::make() ->setTheme('dark') ->register(); ``` -------------------------------- ### Prevent Ignition in Production Source: https://github.com/spatie/ignition/blob/main/README.md Configures Ignition to conditionally display the error page based on a provided boolean value. This is crucial for preventing the exposure of sensitive information in production environments. ```php \Spatie\Ignition\Ignition::make() ->shouldDisplayException($inLocalEnvironment) ->register(); ``` -------------------------------- ### Censor Request Body Fields for Flare Source: https://github.com/spatie/ignition/blob/main/README.md Allows censoring specific fields from the request body before sending them to Flare, protecting sensitive information like passwords. ```php use Spatie\FlareClient\Flare; \Spatie\Ignition\Ignition::make() ->runningInProductionEnvironment($boolean) ->sendToFlare($yourApiKey) ->configureFlare(function(Flare $flare) { $flare->censorRequestBodyFields(['password']); }) ->register(); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.