Download the PHP package danilowa/laravel-api-response-builder without Composer

On this page you can find all versions of the php package danilowa/laravel-api-response-builder. 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 laravel-api-response-builder

  Latest Version   Total Downloads

  Simplify Your API Responses with Laravel API Response Builder! This package helps you create structured and formatted API responses in both JSON and XML formats effortlessly. It provides customizable status codes, messages, and data handling, making it a versatile tool for managing API responses, including error handling, logging, and extensive configuration options.

📚 Index

🔍 How to Use
Overview of the most commonly used methods and their brief descriptions.

🚀 Features

⚙️ Requirements

Ensure your project meets the following requirements before using this package:

With these features in place, let’s dive into the installation process!

📦 Installation

To integrate the Laravel API Response Builder into your Laravel project, follow these steps:

  1. Install via Composer:

Run the following command in your terminal:

  1. Publish the Configuration (Optional):

After installation, publish the configuration file:

This will create a configuration file at config/responsebuilder.php, where you can customize the package settings.

  1. Configuration:

Open the config/responsebuilder.php file and adjust the settings as needed for your project. Configure options such as data wrappers, API key headers, and logging preferences.

With the configuration in place, your package is ready to go!

🌍 Translations

The Laravel API Response Builder supports multiple languages for API responses. By default, it includes English (en) and Brazilian Portuguese (pt_BR). To use translations in your project, follow these steps:

  1. Publish the Translation Files (Optional):

If you wish to customize or add new languages, you can publish the translation files to your project by running:

This will create a resources/lang/vendor/responsebuilder directory where you can modify or add new translation files (e.g., es, fr).

  1. Use Existing Translation Files:

If you do not need custom translations, the package will automatically use the default language files from the vendor/danilowa/laravel-api-response-builder/resources/lang directory.

🧰 Technologies

The Laravel API Response Builder utilizes the following technologies:

📚 Concepts & Patterns

The Laravel API Response Builder package integrates several advanced concepts and patterns designed to enhance API response management:

📝 How to Use Resume

In this section, we highlight the two most frequently used methods (Success and Error ) in the package for quick reference. For a comprehensive overview and detailed explanations of all available methods, including additional functionalities and usage scenarios, please consult the full documentation.

Customizing Response Settings

You can customize the response structure and behavior in the package configuration file. Here are some key options:

These configuration options allow you to tailor the response structure to fit the needs of your application and ensure consistency across your API responses.


success()

Description:

The success() method returns a JSON response with a successful status code (200) and a success message. This is useful for standardizing success responses in your API.

Parameters:

Returns:

Usage Examples:

  1. Default Success Response:

    • Description: Returns a JSON response with the user data and a default success message.
    • Example Output:
  2. Basic Success Response:

    • Description: Returns a JSON response with the user data and a default success message.
    • Example Output:
  3. Success Response with Custom Message:

    • Description: Returns a JSON response with the user data and a custom success message.
    • Example Output:
  4. Success Response with Wrapping:

    • Description: Returns a JSON response with the user data wrapped under the key 'items' by default and a custom success message.
    • Example Output:
  5. Success Response with Custom Wrap key:

    • Description: Returns a JSON response with the user data wrapped under the custom key 'customWrap' and a custom success message.
    • Example Output:

error()

Description:

The error() method returns a JSON response with an error status code and an error message. This is useful for standardizing error responses in your API.

Parameters:

Returns:

Usage Examples:

  1. Default Error Response

    • Description: Returns a JSON response with a 404 status code and a default error message.
    • Example Output:
  2. Basic Error Response:

    • Description: Returns a JSON response with a 404 status code and a default error message.
    • Example Output:
  3. Error Response with Custom Message and Data:

    • Description: Returns a JSON response with a 400 status code, a custom error message, and additional data describing the validation error.
    • Example Output:
  4. Error Response with Wrapping:

    • Description: Returns a JSON response with a 500 status code and the error wrapped under the key 'items' by default.
    • Example Output:
  5. Error Response with custom Wrap key:

    • Description: Returns a JSON response with a 500 status code and the error wrapped under the custom key 'error'.
    • Example Output:

🌐 Documentation

JSON Response

Config

🔗 Links

🤝 Contributing

You can contribute by forking the repository and submitting a pull request.

📝 License

This package is licensed under the MIT License.

📬 Contact

For any questions or feedback, please reach out to:


Note: This package is currently under development, and XML support is still in progress. As an early release, there might be bugs or incomplete features. We appreciate your patience and feedback.


All versions of laravel-api-response-builder with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1|^8.2
laravel/framework Version ^8.0|^9.0|^10.0|^11.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 danilowa/laravel-api-response-builder contains the following files

Loading the files please wait ....