Download the PHP package hyder/json-response without Composer

On this page you can find all versions of the php package hyder/json-response. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package json-response

JSON-Response Laravel Package

Overview

The JSON-Response package provides a simple and minimalistic interface for handling JSON responses in your Laravel applications. It offers convenient methods for returning success responses and error responses with standardized formats.

Installing

You can install the JSON-Response package via Composer. Run the following command in your terminal:

Optional

The service provider will automatically get registered. Or you may manually add the service provider in your config/app.php file:

Uses

Basic Usage

To use the JSON-Response package, you need to import the JsonResponse facade and make use of its methods in your controllers or routes.

Available Success Methods

The following methods are available for returning success responses:

  1. created($message = "Data created successfully!", $data = null)
    Returns a response with a 201 Created status code, a success message, and optional data.
  2. updated($message = "Data updated successfully!", $data = null)
    Returns a response with a 200 OK status code, a success message, and optional data.
  3. success($message = "Request completed successfully!")
    Returns a response with a 200 OK status code and a success message.
  4. withData($data, $message = "Data fetched successfully!")
    Returns a response with a 200 OK status code, a success message, and the provided data.

Method Chaining

You can chain methods together for more flexibility:

Please note that the statusCode() method will not affect the chaining when using the created() method.

Success Response

Available Error Methods

The following methods are available for returning error responses:

  1. badRequest($message = "Bad request!")
    Returns a response with a 400 Bad Request status code and an optional error message. This method is used to indicate a general "bad request" error.

  2. unauthenticated($message = 'Unauthenticated!')
    Returns a response with a 401 Unauthorized status code and an optional error message. It is used to indicate that the user making the request is not authenticated.

  3. invalidRequest($message = 'Invalid request!')
    Returns a response with a 403 Forbidden status code and an optional error message. It is used to indicate that the request is invalid or does not meet the server's expectations.

  4. validationError($message = 'Required field is missing!')
    Returns a response with a 422 Unprocessable Entity status code and an optional error message. It is used to indicate that the request data failed validation checks.

  5. notFound($message = 'Not found!')
    Returns a response with a 404 Not Found status code and an optional error message. It is used to indicate that the requested resource was not found.

  6. internalError($message = 'Internal server error!')
    Returns a response with a 500 Internal Server Error status code and an optional error message. It is used to indicate that an unexpected internal server error occurred.

  7. error($message = 'Something went wrong!', int $statusCode = 500)
    Returns a response with the specified status code and error message.

Please note that you can provide a custom error message for each error response if needed.

Feel free to adjust the method names and default error messages to better suit your application's needs.

Chaining with error method

You can chain methods together for more flexibility:

Please note that the statusCode() method will affect only when chaining with error() method.

Response

Customized Response

In addition to the provided methods, you can also return a customized JSON response using the response() method. This method allows you to specify the data, status code, and headers for the response.

License

This package is open-source software licensed under the MIT license.

Credits

This package is developed and maintained by Tofayel Hyder Abhi.


All versions of json-response with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3|^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package hyder/json-response contains the following files

Loading the files please wait ....