PHP Classes

File: example/index.php

Recommend this page to a friend!
  Packages of Boss Ibrahim Mussa   hitilafu   example/index.php   Download  
File: example/index.php
Role: Example script
Content type: text/plain
Description: Example script
Class: hitilafu
Error handler that displays the error context
Author: By
Last change:
Date: 3 months ago
Size: 1,767 bytes
 

Contents

Class file image Download
<?php

/**
 * Hitilafu Error Handler Example
 *
 * This file demonstrates how to use the error handler in your PHP application
 */

use Wepesi\Hitilafu\Hitilafu;

require_once
__DIR__ . '/../vendor/autoload.php';

// Register the error handler and configure it

Hitilafu::register()
    ->
setAppName('My Awesome App')
   
// ->setTheme('dark') // default is 'light'
    // Add custom solutions for specific errors
   
->addSolution(
       
'mysqli_connect',
       
'MySQL Connection Issue',
       
'Make sure your MySQL server is running and the credentials in your configuration file are correct. Check if the MySQL port (default 3306) is open and accessible.',
        [
            [
'text' => 'MySQL Connection Guide', 'url' => 'https://dev.mysql.com/doc/refman/8.0/en/connecting.html'],
            [
'text' => 'Common Connection Errors', 'url' => 'https://dev.mysql.com/doc/mysql-errors/8.0/en/server-error-reference.html']
        ]
    )
    ->
addSolution(
       
'Composer\Autoload',
       
'Composer Autoload Issue',
       
'Run "composer install" or "composer dump-autoload" to regenerate the autoloader. Make sure composer.json is properly configured.',
        [
            [
'text' => 'Composer Documentation', 'url' => 'https://getcomposer.org/doc/']
        ]
    )
    ->
addSolution(
       
'redis',
       
'Redis Connection Failed',
       
'Ensure Redis server is running on the specified host and port. Check if Redis is installed and the service is active. Verify firewall rules allow connection to Redis port (default 6379).',
        [
            [
'text' => 'Redis Quick Start', 'url' => 'https://redis.io/docs/getting-started/']
        ]
    );

// include a file with syntax errors to test parse error handling
include 'example.php';