Download the PHP package arpanpatoliya/response without Composer

On this page you can find all versions of the php package arpanpatoliya/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 response

Laravel Response Package

Latest Version

A comprehensive Laravel package for standardized API responses with full HTTP status code coverage and response macros.

๐Ÿ“‹ Table of Contents

โœจ Features

๐Ÿ› ๏ธ Installation

  1. Install the package via Composer:

  2. The service provider will be automatically registered via Laravel's package discovery.

๐Ÿš€ Quick Start

๐Ÿ“– Usage

Basic Success Responses

Error Responses

Validation Responses

Advanced Responses

Logging Integration

The package provides a chainable log() method to log responses to Laravel's logging system. By default, logs are written to the default logging channel.

Log Parameters:

Log Context: The log automatically includes:

๐ŸŒ HTTP Status Codes

1xx Informational

Macro Status Description
continue() 100 Continue
switchingProtocols() 101 Switching Protocols
processing() 102 Processing
earlyHints() 103 Early Hints

2xx Success

Macro Status Description
ok() 200 OK
success() 200 Success with data
successMessage() 200 Success message only
created() 201 Created
accepted() 202 Accepted
nonAuthoritativeInformation() 203 Non-Authoritative Information
noContent() 204 No Content
resetContent() 205 Reset Content
partialContent() 206 Partial Content
multiStatus() 207 Multi-Status
alreadyReported() 208 Already Reported
imUsed() 226 IM Used

3xx Redirection

Macro Status Description
multipleChoices() 300 Multiple Choices
movedPermanently() 301 Moved Permanently
found() 302 Found
seeOther() 303 See Other
notModified() 304 Not Modified
useProxy() 305 Use Proxy
temporaryRedirect() 307 Temporary Redirect
permanentRedirect() 308 Permanent Redirect

4xx Client Errors

Macro Status Description
badRequest() 400 Bad Request
unauthorized() 401 Unauthorized
paymentRequired() 402 Payment Required
forbidden() 403 Forbidden
notFound() 404 Not Found
methodNotAllowed() 405 Method Not Allowed
notAcceptable() 406 Not Acceptable
proxyAuthenticationRequired() 407 Proxy Authentication Required
requestTimeout() 408 Request Timeout
conflict() 409 Conflict
gone() 410 Gone
lengthRequired() 411 Length Required
preconditionFailed() 412 Precondition Failed
payloadTooLarge() 413 Payload Too Large
uriTooLong() 414 URI Too Long
unsupportedMediaType() 415 Unsupported Media Type
rangeNotSatisfiable() 416 Range Not Satisfiable
expectationFailed() 417 Expectation Failed
imATeapot() 418 I'm a teapot
misdirectedRequest() 421 Misdirected Request
unprocessableEntity() 422 Unprocessable Entity
locked() 423 Locked
failedDependency() 424 Failed Dependency
tooEarly() 425 Too Early
upgradeRequired() 426 Upgrade Required
preconditionRequired() 428 Precondition Required
tooManyRequests() 429 Too Many Requests
requestHeaderFieldsTooLarge() 431 Request Header Fields Too Large
unavailableForLegalReasons() 451 Unavailable For Legal Reasons

5xx Server Errors

Macro Status Description
internalServerError() 500 Internal Server Error
serverError() 500 Server Error (alias)
notImplemented() 501 Not Implemented
badGateway() 502 Bad Gateway
serviceUnavailable() 503 Service Unavailable
gatewayTimeout() 504 Gateway Timeout
httpVersionNotSupported() 505 HTTP Version Not Supported
variantAlsoNegotiates() 506 Variant Also Negotiates
insufficientStorage() 507 Insufficient Storage
loopDetected() 508 Loop Detected
notExtended() 510 Not Extended
networkAuthenticationRequired() 511 Network Authentication Required

Utility Methods

Macro Status Description
errorMessage() 200 Basic error message
error() Variable Error with custom status
validationFailure() 422 Validation errors
custom() Variable Custom response
paginated() 200 Paginated response
withMeta() 200 Response with metadata
updated() 200 Resource updated
deleted() 200 Resource deleted

Logging Method

Method Description
log() Chainable logging method for responses. Supports custom channel, level, message, and context.

๐Ÿ“„ Response Format

Success Response

Error Response

Paginated Response

Response with Metadata

๐Ÿ’ก Examples

Complete User Controller Example

Advanced Usage Examples

๐Ÿงช Testing

To run the tests for this package:

Or run PHPUnit directly:

The tests cover all response macros, ensuring they return the correct status codes and response formats.

Test Coverage

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Development Setup

  1. Fork the repository
  2. Clone your fork
  3. Install dependencies: composer install
  4. Run tests: composer test
  5. Make your changes
  6. Add tests for new features
  7. Submit a pull request

๐Ÿ‘จโ€๐Ÿ’ป Author

Arpan Patoliya

About the Author

Arpan is a passionate Laravel developer with expertise in building robust and scalable web applications. This package was created to provide a comprehensive solution for standardized API responses in Laravel applications.

๐Ÿ“„ License

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


Made with โค๏ธ by Arpan Patoliya

If you find this package helpful, please consider giving it a โญ on GitHub!


All versions of response with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
illuminate/support Version ^9.0|^10.0|^11.0|^12.0|^13.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 arpanpatoliya/response contains the following files

Loading the files please wait ...