Skip to content

Commit 3e23c62

Browse files
committed
wip
1 parent 7433850 commit 3e23c62

File tree

5 files changed

+112
-253
lines changed

5 files changed

+112
-253
lines changed

README.md

Lines changed: 79 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,25 @@
1-
# Laravel API Response Builder
2-
3-
<!-- <p align="center">
4-
<img src="https://raw.githubusercontent.com/lwwcas/laravel-countries/master/assets/map.jpg" alt="Laravel API Response Builder"/>
5-
</p> -->
6-
71
<p align="center">
8-
<img src="https://img.shields.io/packagist/v/doliveira/laravel-api-response-builder" alt="Latest Version" />
9-
<img src="https://img.shields.io/packagist/dt/doliveira/laravel-api-response-builder" alt="Total Downloads" />
10-
2+
  <img src="https://img.shields.io/packagist/v/doliveira/laravel-api-response-builder" alt="Latest Version" />
3+
  <img src="https://img.shields.io/packagist/dt/doliveira/laravel-api-response-builder" alt="Total Downloads" />
114
</p>
125

136
<p align="center">
14-
Welcome to the <strong>Laravel API Response Builder</strong>! This package simplifies the creation of structured and formatted API responses in both JSON and XML formats. 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.
7+
  <strong>Simplify Your API Responses with Laravel API Response Builder!</strong> 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.
158
</p>
169

1710
## 📚 Index
1811

19-
- [Installation](#installation)
20-
- [Technologies](#technologies)
21-
- [Concepts & Patterns](#concepts--patterns)
22-
- [Prerequisites](#prerequisites)
23-
- [Documentation](#documentation)
24-
- [Links](#links)
25-
- [Contributing](#contributing)
26-
- [License](#license)
27-
- [Contact](#contact)
12+
- [Features](#-features)
13+
- [Requirements](#-requirements)
14+
- [Installation](#-installation)
15+
- [Translations](#-translations)
16+
- [Technologies](#-technologies)
17+
- [Concepts & Patterns](#-concepts--patterns)
18+
- [Documentation](#-documentation)
19+
- [Links](#-links)
20+
- [Contributing](#-contributing)
21+
- [License](#-license)
22+
- [Contact](#-contact)
2823

2924
## 🚀 Features
3025

@@ -33,39 +28,61 @@
3328
- **Error Handling & Logging:** Detailed logging for both responses and requests.
3429
- **Flexible Configuration:** Adjust settings for data wrapping, response languages, and more.
3530

36-
## ⚙️ Prerequisites
31+
## ⚙️ Requirements
3732

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

4035
- **Laravel Framework:** Version 8.12 or higher.
4136
- **PHP:** Version 7.3 or higher.
4237
- **Composer:** PHP dependency manager.
4338

39+
With these features in place, let’s dive into the installation process!
40+
4441
## 📦 Installation
4542

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

4845
1. **Install via Composer:**
4946

50-
Run the following command in your terminal:
47+
Run the following command in your terminal:
5148

52-
```bash
53-
composer require doliveira/laravel-api-response-builder
54-
```
49+
```bash
50+
composer require doliveira/laravel-api-response-builder
51+
```
5552

56-
2. **Publish the Configuration:**
53+
2. **Publish the Configuration (Optional):**
5754

58-
After installation, publish the configuration file:
55+
After installation, publish the configuration file:
5956

60-
```bash
61-
php artisan vendor:publish --provider="Doliveira\LaravelResponseBuilder\Providers\ResponseBuilderServiceProvider"
62-
```
57+
```bash
58+
php artisan vendor:publish --provider="Doliveira\LaravelResponseBuilder\Providers\ResponseBuilderServiceProvider"
59+
```
6360

64-
This will create a configuration file at `config/responsebuilder.php` where you can customize the package settings.
61+
This will create a configuration file at `config/responsebuilder.php`, where you can customize the package settings.
6562

6663
3. **Configuration:**
6764

68-
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.
65+
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.
66+
67+
With the configuration in place, your package is ready to go!
68+
69+
## 🌍 Translations
70+
71+
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:
72+
73+
1. **Publish the Translation Files (Optional):**
74+
75+
If you wish to customize or add new languages, you can publish the translation files to your project by running:
76+
77+
```bash
78+
php artisan vendor:publish --tag=lang
79+
```
80+
81+
This will create a `resources/lang/vendor/responsebuilder` directory where you can modify or add new translation files (e.g., `es`, `fr`).
82+
83+
2. **Use Existing Translation Files:**
84+
85+
If you do not need custom translations, the package will automatically use the default language files from the `vendor/doliveira/laravel-api-response-builder/resources/lang` directory.
6986

7087
## 🧰 Technologies
7188

@@ -77,10 +94,6 @@ The **Laravel API Response Builder** utilizes the following technologies:
7794
- **XML:** Data format for API responses (currently under development).
7895
- **Log:** Laravel's logging facilities for recording response details.
7996

80-
Claro, aqui está uma versão aprimorada para a seção "Concepts & Patterns", baseada no código e na funcionalidade descrita:
81-
82-
---
83-
8497
## 📚 Concepts & Patterns
8598

8699
The **Laravel API Response Builder** package integrates several advanced concepts and patterns designed to enhance API response management:
@@ -89,42 +102,48 @@ The **Laravel API Response Builder** package integrates several advanced concept
89102

90103
- **Detailed Logging:** The package offers comprehensive logging capabilities for both responses and requests. Using Laravel’s built-in logging facilities, it captures key details such as response status, headers, and content. This feature supports various logging levels and allows you to specify log file paths, enabling efficient debugging and monitoring of your API interactions.
91104

105+
_Example: You can view response logs in your designated log file, set in the configuration file under `logging.channels`. For instance, responses with status codes `500` will be logged as errors, helping you track and debug critical issues._
106+
92107
- **Flexible Configuration Management:** Leveraging Laravel’s configuration system, the package provides extensive options for customizing the response structure. You can easily configure data wrappers, API key headers, default status codes, and response languages. This flexibility allows you to tailor the package’s behavior to fit the specific needs of your project.
93108

94109
- **Standardized Error Handling:** The package standardizes the way error messages and statuses are generated. It provides a consistent approach to error responses, allowing for easier troubleshooting and improved user experience. Configuration options are available to adjust error message formats and response codes, ensuring that error handling aligns with your application’s requirements.
95110

96111
## 🌐 Documentation
97112

98-
### [JSON Response](#json-response)
99-
100-
- **Auto** - [Description](#) | [Examples](#)
101-
- **Success** - [Description](#) | [Examples](#)
102-
- **Error** - [Description](#) | [Examples](#)
103-
104-
### [Config](#config)
105-
106-
- **Custom Response Structure** - [Details](#custom-response-structure)
107-
- [Data Wrapper](#data-wrapper)
108-
- [API Key Header](#api-key-header)
109-
- [Response Language](#response-language)
110-
- [Default Status Code](#default-status-code)
111-
- [JSON Options](#json-options)
112-
- **Logs** - [Details](#logs)
113-
- [Log Responses](#log-responses)
114-
- [Request Logging](#request-logging)
115-
- [Response Time Logging](#response-time-logging)
116-
- [Logging Level](#logging-level)
117-
- [Log Files Path](#log-files-path)
113+
### [JSON Response](./wiki/json-response.md)
114+
115+
- **Success** - [Description](./wiki/json-response.md#success) | [Examples](./wiki/json-response.md#success-examples)
116+
- **SuccessWithMeta** - [Description](./wiki/json-response.md#successwithmeta) | [Examples](./wiki/json-response.md#successwithmeta-examples)
117+
- **SuccessWithHeaders** - [Description](./wiki/json-response.md#successwithheaders) | [Examples](./wiki/json-response.md#successwithheaders-examples)
118+
- **SuccessWithPagination** - [Description](./wiki/json-response.md#successwithpagination) | [Examples](./wiki/json-response.md#successwithpagination-examples)
119+
- **Error** - [Description](./wiki/json-response.md#error) | [Examples](./wiki/json-response.md#error-examples)
120+
- **ErrorWithTrace** - [Description](./wiki/json-response.md#errorwithtrace) | [Examples](./wiki/json-response.md#errorwithtrace-examples)
121+
- **ErrorWithSuggestions** - [Description](./wiki/json-response.md#errorwithsuggestions) | [Examples](./wiki/json-response.md#errorwithsuggestions-examples)
122+
123+
### [Config](./wiki/config.md)
124+
125+
- **Custom Response Structure** - [Details](./wiki/config.md#custom-response-structure)
126+
  - [Data Wrapper](./wiki/config.md#data-wrapper)
127+
  - [API Key Header](./wiki/config.md#api-key-header)
128+
  - [Response Language](./wiki/config.md#response-language)
129+
  - [Default Status Code](./wiki/config.md#default-status-code)
130+
  - [JSON Options](./wiki/config.md#json-options)
131+
- **Logs** - [Details](./wiki/config.md#logs)
132+
  - [Log Responses](./wiki/config.md#log-responses)
133+
  - [Request Logging](./wiki/config.md#request-logging)
134+
  - [Response Time Logging](./wiki/config.md#response-time-logging)
135+
  - [Logging Level](./wiki/config.md#logging-level)
136+
  - [Log Files Path](./wiki/config.md#log-files-path)
118137

119138
## 🔗 Links
120139

121-
- [Official Documentation](#documentation)
122-
- [GitHub Repository](https://github.com/doliveira/laravel-api-response-builder)
123-
- [Support & Issues](https://github.com/doliveira/laravel-api-response-builder/issues)
140+
- [Official Documentation](https://github.com/DaniloWA/laravel-api-response-builder)
141+
- [GitHub Repository](https://github.com/DaniloWA/laravel-api-response-builder)
142+
- [Support & Issues](https://github.com/DaniloWA/laravel-api-response-builder/issues)
124143

125144
## 🤝 Contributing
126145

127-
To contribute to the development of this package, please fork the repository and submit a pull request.
146+
You can contribute by forking the repository and submitting a pull request.
128147

129148
## 📝 License
130149

@@ -139,4 +158,4 @@ For any questions or feedback, please reach out to:
139158

140159
---
141160

142-
**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.
161+
**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.

READMEOld.md

Lines changed: 0 additions & 170 deletions
This file was deleted.

src/providers/ResponseBuilderServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function boot()
2222
], 'config');
2323

2424
$this->publishes([
25-
__DIR__.'/../resources/lang' => resource_path('lang/vendor/responsebuilder'),
25+
__DIR__.'/../resources/lang' => resource_path('lang/responsebuilder'),
2626
], 'lang');
2727
}
2828

0 commit comments

Comments
 (0)