danjamesmills/laravel-response

1.0.2 2024-05-28 22:31 UTC

This package is auto-updated.

Last update: 2024-09-04 21:05:13 UTC


README

Latest Version on Packagist Total Downloads GitHub Actions

Introducing the Simple API Response Package for Laravel - a lightweight package that allows you to easily extend the functionality of your API's BaseController. This package provides simple helper methods for returning response codes and data. The methods include "sendResponse", "sendError" and "sendSuccess" which helps to return JSON responses with appropriate status codes and messages. With this package, you can streamline your API's response handling and ensure consistency throughout your application. This package is easy to use, and it can help you to keep your code clean and well-organized. The package is built with flexibility in mind, and it can easily adapt to your application's specific needs.

Installation

You can install the package via composer:

composer require danjamesmills/laravel-response

Usage

<?php

namespace App\Http\Controllers\Api;

use DanJamesMills\LaravelResponse\Http\Controllers\BaseController;

class PostAPIController extends AppBaseController
{
    public function store(PollAPIRequest $request)
    {
        return $this->sendResponse($poll->toArray(), 'Poll saved successfully');
    }
    
    public function destroy($id)
    {
        return $this->sendSuccess('Poll deleted successfully');
    }
}

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email daniel620@hotmail.co.uk instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.