DEV Community

Mesak
Mesak

Posted on

1

Laravel package api-response

I mentioned a method before, which is to use the unified processing of the controller return value to output the API response. For this reason, I wrote my method into a package to make it more convenient to use.

package in :
https://github.com/mesak/laravel-api-response

in Laravel 8 or 9

use command :

composer require mesak/laravel-api-response
Enter fullscreen mode Exit fullscreen mode

your can install this package

then use two step

change Controller and change Exception\Handler

Exception\Handler

change your app/Exceptions/Handler.php file to extend Mesak\LaravelApiResponse\Exceptions\Handler

namespace App\Exceptions;

use Mesak\LaravelApiResponse\Exceptions\Handler  as ExceptionHandler;

Enter fullscreen mode Exit fullscreen mode

Controller

change your api controller, to extend Mesak\LaravelApiResponse\Http\Controllers\Controller

namespace App\Http\Controllers;

use Mesak\LaravelApiResponse\Http\Controllers\ApiController as BaseController;

class MainController extends BaseController
{

}
Enter fullscreen mode Exit fullscreen mode

then enjoy this

Image of Datadog

The Future of AI, LLMs, and Observability on Google Cloud

Datadog sat down with Google’s Director of AI to discuss the current and future states of AI, ML, and LLMs on Google Cloud. Discover 7 key insights for technical leaders, covering everything from upskilling teams to observability best practices

Learn More

Top comments (0)

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay