PHP code example of devraeph / laravel-alh

1. Go to this page and download the library: Download devraeph/laravel-alh library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

devraeph / laravel-alh example snippets


return [
    'logging' => [
        'in_productions' => env("ALH_LOG_IN_PRODUCTION",false),
        "to_database" => env("ALH_TO_DB",false),
        "to_file" => env("ALH_TO_FILE",true),
        "file_driver" => env("ALH_FILE_DRIVER","local"),
        "file_path" => env("ALH_FILE_PATH","logs_alh"),
        "separate_by_type" => env("ALH_SEPARATE_BY_TYPE",false),
    ],
    'general' => [
        "clear_logs" => false,
        'retention' => env("ALH_LOG_RETENTION",7), //Keep Logs for 7 days by default
    ],

];

  /*
   * Uses default mechanism
   * configured in config/alh.php
   * default only toFile and not in production
   */
   
   ALH::error("Error message",new Exception("ex"));
   ALH::warning("Warning message",new Exception("ex"));
   ALH::info("Info message");
   ALH::success("Success message");
   ALH::pending("Pending message");

   /*
   * Override config settings
   */

   /* Log Only to DB */
   ALH::toDB()->error("Error message",new Exception("ex"));
   /* Log only to File */
   ALH::toFile()->error("Error message",new Exception("ex"));
   /* Force Log both */
   ALH::toDB()->toFile()->error("Error message",new Exception("ex"));

   /*
   * Option to set Log issuer like User
   */
   ALH::setIssuer(User::first())->error("Error message",new Exception("ex"));

protected function gate(): void
{
    Gate::define('viewALH', function (User $user) {
        return in_array($user->email, [
            //
        ]);
    });
}
bash
php artisan alh:install
bash
php artisan vendor:publish --tag="laravel-alh-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="laravel-alh-config"
bash
php artisan vendor:publish --tag="laravel-alh-views"