Download the PHP package negartarh/apiwrapper without Composer

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

# Laravel Missed API Response Wrapper ![GitHub Repo stars](https://img.shields.io/github/stars/negartarh/apiwrapper) ### Super Fast | Light Weight | Standard | Octane Compatible | High Customizable ###### Built for Applications Ranging from Small to Large Scale


![Static Badge](https://img.shields.io/badge/passing-tests?label=tests&style=for-the-badge&color=%388E3C) ![Static Badge](https://img.shields.io/badge/passing-tests?label=PHP%20Composer&style=for-the-badge&color=%388E3C) ![Static Badge](https://img.shields.io/badge/passing-tests?label=Codacy%20Security%20Scan&style=for-the-badge&color=%388E3C) ![GitHub License](https://img.shields.io/github/license/negartarh/apiwrapper?style=for-the-badge&color=%388E3C) ![GitHub Release](https://img.shields.io/github/v/release/negartarh/apiwrapper?style=for-the-badge&color=%388E3C) ![Packagist Downloads](https://img.shields.io/packagist/dt/negartarh/apiwrapper?style=for-the-badge&color=%388E3C)
![GitHub commit activity](https://img.shields.io/github/commit-activity/t/negartarh/apiwrapper?style=for-the-badge&color=%23303F9F) ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/negartarh/apiwrapper?style=for-the-badge&color=%23303F9F) ![GitHub repo file or directory count](https://img.shields.io/github/directory-file-count/negartarh/apiwrapper?style=for-the-badge&color=%23303F9F) ![GitHub Discussions](https://img.shields.io/github/discussions/negartarh/apiwrapper?style=for-the-badge&color=%23303F9F) ![Languages](https://img.shields.io/badge/04-languages?label=languages&style=for-the-badge&color=%23303F9F)



Introduction

The Laravel Missed API Response Wrapper package is a high-quality and standard package that makes the process of creating and managing standard API responses in Laravel easy. This package is both fast and lightweight, and fully compatible with Laravel Octane, highly customizable, and automatically enables the standardization of all API responses. By using this package, you can easily manage errors and develop standard API services that automatically provide responses according to HTTP and REST standards.

This package is usable anywhere, from validators to controllers and other components, and automatically provides features such as request status, message, errors, and execution time. Additionally, adding custom values to responses or disabling these features is easily achievable.

Using this package guarantees the standardization of API responses, meaning you can continuously and reliably provide high-quality responses that are easily understandable and usable for consumers of your API, while also being fully compliant with standards. All done automatically.

Installation

To install Laravel Missed API Response Wrapper, just run the following command:

Configuration

After installing the package, you need to publish its configuration file. To do that, run the following command:

This will publish the apiwrapper.php configuration file to your config directory and publish localization files to your languages/vendor/apiwrapper directory.

Basic usage

There are two ways of utilizing the package: using the facade, or using the helper functions. Either way you will get the same result, it is totally up to you.

Facade

Example 1.

Helper functions

Example 1.

The result of the above codes is as follows:

As you can see, the simple output information has been automatically replaced with the classified information suitable for API requests. Look at the output keys, they are all changeable and editable, but before that, it is better to do more research on the package and get acquainted with its more features.

Advanced Usage

Automatic output based on HTTP standards

Example 1. Storing data

The result of the above code is as follows:

Example 2. No content

The result of the above code is as follows:

Example 3. Validating data

The result of the above code is as follows:

Let’s also take a look at the server response and output headers,

everything looks great, If it is hard for you to remember the HTTP standards, no problem, pay attention to the next example.

Alternative method

Example 1. Status method

and the result is:

Wait a moment, isn't it better to customize the output message? So pay attention to the following example:

Customized messages

Example 1.

and guess the result:

But wait, there is a better solution, why not implement our own team standard? To do this, just add your own standard to the apiwrapper.php file in the config folder of your project and or make changes to it as needed.

Customized methods

Example 1.

and easily use the defined method in your project.

If you pay attention to the above example, you will see that the header value for each status is adjustable, but what to do to adjust it at runtime? To do this, pay attention to the following example:

Adjustable headers

Example 1.

Localization

If your API is multilingual, this package is translatable and has been translated into Persian, Arabic and Turkish. To work with translations, refer to the Laravel documents. for more information, pay attention to the next example:

Example 1. Localized response

and the result:

If you do not need to translate the messages, you can disable it through the configuration file.

Example 2. Disabling localization

Sorting Responses

If you wish to further standardize your responses, you can sort them alphabetically. You can achieve this by using the 'sort' key in the configuration file. By setting this key to true, your responses will be sorted alphabetically. The default state of this option is false.

Example 1. Enabling sorting responses

Customizing responses

To enable, disable or customize default keys in the response, just do it through the configuration file.

Example 1. Disabling default keys

Example 2. change the algorithm

You can get more information on this by studying the configuration file.

Changing the default key names

Like the previous examples, to change the default key names in the response, just do it through the configuration file.

Example 1.

result:

Adding custom values

To add custom values to the API response, do the following in the configuration file.

Example 1.

and the result:

Hints

Example 1. Real-World software development with axios

Back-End:
Front-End:

Example 2. Handle 404 status in api responses

Built-in methods

In the table below, the predefined methods are given with the HTTP code and message text. All these values are accessible and changeable through the config file.

No. METHOD HTTP STATUS MESSAGE
#0 ok 200 OK
#1 success 200 Success
#2 created 201 Created
#3 accepted 202 Accepted
#4 nonAuthoritativeInformation 203 Non Authoritative Information
#5 noContent 204 No Content
#6 resetContent 205 Reset Content
#7 partialContent 206 Partial Content
#8 multiStatus 207 Multi Status
#9 alreadyReported 208 Already Reported
#10 imUsed 226 IM Used
#11 multipleChoices 300 Multiple Choices
#12 movedPermanently 301 Moved Permanently
#13 found 302 Found
#14 seeOther 303 See Other
#15 notModified 304 Not Modified
#16 useProxy 305 Use Proxy
#17 temporaryRedirect 307 Temporary Redirect
#18 permanentRedirect 308 Permanent Redirect
#19 badRequest 400 Bad Request
#20 unauthorized 401 Unauthorized
#21 paymentRequired 402 Payment Required
#22 forbidden 403 Forbidden
#23 notFound 404 Not Found
#24 methodNotAllowed 405 Method Not Allowed
#25 notAcceptable 406 Not Acceptable
#26 proxyAuthenticationRequired 407 Proxy Authentication Required
#27 requestTimeout 408 Request Timeout
#28 conflict 409 Conflict
#29 gone 410 Gone
#30 lengthRequired 411 Length Required
#31 preconditionFailed 412 Precondition Failed
#32 requestEntityTooLarge 413 Request Entity Too Large
#33 requestURITooLong 414 Request URI Too Long
#34 unsupportedMediaType 415 Unsupported Media Type
#35 requestedRangeNotSatisfiable 416 Requested Range Not Satisfiable
#36 expectationFailed 417 Expectation Failed
#37 unprocessableEntity 422 Unprocessable Entity
#38 locked 423 Locked
#39 failedDependency 424 Failed Dependency
#40 tooEarly 425 Too Early
#41 upgradeRequired 426 Upgrade Required
#42 preconditionRequired 428 Precondition Required
#43 tooManyRequests 429 Too Many Requests
#44 requestHeaderFieldsTooLarge 431 Request Header Fields Too Large
#45 noResponse 444 No Response
#46 unavailableForLegalReasons 451 Unavailable For Legal Reasons
#47 internalServerError 500 Internal Server Error
#48 notImplemented 501 Not Implemented
#49 badGateway 502 Bad Gateway
#50 serviceUnavailable 503 Service Unavailable
#51 gatewayTimeout 504 Gateway Timeout
#52 httpVersionNotSupported 505 HTTP Version Not Supported
#53 variantAlsoNegotiates 506 Variant Also Negotiates
#54 insufficientStorage 507 Insufficient Storage
#55 loopDetected 508 Loop Detected
#56 notExtended 510 Not Extended
#57 networkAuthenticationRequire 511 Network Authentication Require

Requirments

Contributing

We will be happy if we see PR from you.

License

This is a free package released under the MIT License.


All versions of apiwrapper with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
illuminate/support Version ^v9.0.0|^v10.0.0|^v11.0.0|^v12.0.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 negartarh/apiwrapper contains the following files

Loading the files please wait ....