Skip to content

Commit

Permalink
Update README.md - Remove unused methods
Browse files Browse the repository at this point in the history
  • Loading branch information
HPWebdeveloper committed Feb 2, 2024
1 parent 78a1a3f commit 8e5f1d8
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 67 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/main-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: tests

on:
push:
branches:
- main
pull_request:
schedule:
- cron: '0 0 * * *'

jobs:
tests:
runs-on: ubuntu-22.04

services:
redis:
image: redis
ports:
- 6379:6379
options: --entrypoint redis-server

strategy:
fail-fast: true
matrix:
php: [7.3, 7.4, '8.0', 8.1, 8.2, 8.3]
laravel: [8, 9, 10, 11]
exclude:
- php: 7.3
laravel: 9
- php: 7.3
laravel: 10
- php: 7.3
laravel: 11
- php: 7.4
laravel: 9
- php: 7.4
laravel: 10
- php: 7.4
laravel: 11
- php: '8.0'
laravel: 10
- php: '8.0'
laravel: 11
- php: 8.1
laravel: 11
- php: 8.2
laravel: 8
- php: 8.3
laravel: 8
- php: 8.3
laravel: 9

name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, redis, zip
ini-values: error_reporting=E_ALL
tools: composer:v2
coverage: none

- name: Install dependencies
run: |
composer require "illuminate/contracts=^${{ matrix.laravel }}" --dev --no-update
composer update --prefer-dist --no-interaction --no-progress
- name: Execute tests
run: vendor/bin/phpunit
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
<p align="center">
<a href="https://github.com/HPWebdeveloper/laravel-failed-jobs/actions"><img src="https://github.com/HPWebdeveloper/laravel-failed-jobs/workflows/tests/badge.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/HPWebdeveloper/laravel-failed-jobs"><img src="https://img.shields.io/packagist/dt/HPWebdeveloper/laravel-failed-jobs" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/HPWebdeveloper/laravel-failed-jobs"><img src="https://img.shields.io/packagist/v/HPWebdeveloper/laravel-failed-jobs" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/HPWebdeveloper/laravel-failed-jobs"><img src="https://img.shields.io/packagist/l/HPWebdeveloper/laravel-failed-jobs" alt="License"></a>
</p>

# Laravel Failed Jobs

If you're running an application and the queue driver isn't Redis, which Laravel Horizon supports, you might be missing out on the elegant features it offers. Laravel Horizon is known for its elegance and a wide range of implemented features. One of its standout features is its ability to present detailed information about failed job payloads and automatically load new failed jobs.
## Introduction:

If you're running an application with a queue driver other than Redis, which is exclusively supported by [Laravel Horizon](https://github.com/laravel/horizon), you might be missing out on the elegant features that Horizon offers. Laravel Horizon is known for its elegance and a wide range of implemented features. One of its standout features is its ability to present detailed information about failed job payloads and automatically load new failed jobs.

In your specific application, if you've been longing for a similar Horizon-like UI to monitor failed_jobs, the Laravel-Failed-Jobs package has got you covered. This package simplifies the process of visualizing failed jobs.

![Screenshot 2024-02-01 at 7 55 42 PM](https://github.com/HPWebdeveloper/laravel-failed-jobs/assets/16323354/2ec7ebad-1ad9-4927-8bff-5ce4002e1a7c)

## Key Benefits:

Seamless Integration: You can seamlessly integrate the Laravel-Failed-Jobs package into your project, even if you are already using Laravel Horizon. There's no conflict between the two. While Horizon primarily reads and writes data to Redis, Laravel-Failed-Jobs retrieves data from the failed_jobs table.
Expand All @@ -32,12 +35,17 @@ After installing Laravel-Failed-Jobs, publish its assets using the failedjobs:in
```bash
php artisan failedjobs:install
```
## Dashboard

The Laravel-Failed-Jobs dashboard may be accessed via the `/failedjobs` route.

## Dashboard Authorization

Find `app/Providers/FailedJobsServiceProvider.php` and then follow the same tutorial here:
Find `app/Providers/FailedJobsServiceProvider.php` and then follow the [same document of Horizon](https://laravel.com/docs/10.x/horizon#dashboard-authorization) to secure the dashboard in production environment.

![Screenshot 2024-02-01 at 7 54 17 PM](https://github.com/HPWebdeveloper/laravel-failed-jobs/assets/16323354/05abc4ab-ede6-4e90-b713-bc540015435d)

https://laravel.com/docs/10.x/horizon#dashboard-authorization
![Screenshot 2024-02-01 at 7 55 27 PM](https://github.com/HPWebdeveloper/laravel-failed-jobs/assets/16323354/30e1dd9e-316b-4d8e-80a4-ef7df195bbcd)


## Licensing
Expand Down
8 changes: 0 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,6 @@
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": "@prepare",
"clear": "@php vendor/bin/testbench package:purge-skeleton --ansi",
"prepare": "@php vendor/bin/testbench package:discover --ansi",
"build": "@php vendor/bin/testbench workbench:build --ansi",
"serve": [
"@build",
"@php vendor/bin/testbench serve"
],
"lint": [
"@php vendor/bin/phpstan analyse"
],
Expand Down
56 changes: 1 addition & 55 deletions src/Http/Controllers/FailedJobsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class FailedJobsController extends Controller

public function index(Request $request)
{
$perPage = 50;
$perPage = 50;

$failedJobs = DB::table('failed_jobs')
->orderBy('failed_at', 'desc')
Expand Down Expand Up @@ -40,40 +40,6 @@ protected function decodeDatabaseFailedJob($job)
return $job;
}


/**
* Paginate the failed jobs for the request.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Support\Collection
*/
protected function paginate(Request $request)
{
return $this->jobs->getFailed($request->query('starting_at') ?: -1)->map(function ($job) {
return $this->decode($job);
});
}

/**
* Paginate the failed jobs for the request and tag.
*
* @param \Illuminate\Http\Request $request
* @param string $tag
* @return \Illuminate\Support\Collection
*/
protected function paginateByTag(Request $request, $tag)
{
$jobIds = $this->tags->paginate(
'failed:'.$tag, ($request->query('starting_at') ?: -1) + 1, 50
);

$startingAt = $request->query('starting_at', 0);

return $this->jobs->getJobs($jobIds, $startingAt)->map(function ($job) {
return $this->decode($job);
});
}

public function show($uuid)
{
$failedJob = DB::table('failed_jobs')->where('uuid', $uuid)->first();
Expand All @@ -98,24 +64,4 @@ protected function decodeDatabaseJob($job)

return $job;
}

/**
* Decode the given job.
*
* @param object $job
* @return object
*/
protected function decode($job)
{
$job->payload = json_decode($job->payload);

$job->exception = mb_convert_encoding($job->exception, 'UTF-8');

$job->context = json_decode($job->context);

$job->retried_by = collect(json_decode($job->retried_by))
->sortByDesc('retried_at')->values();

return $job;
}
}

0 comments on commit 8e5f1d8

Please sign in to comment.