You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+55-15Lines changed: 55 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,34 +2,58 @@
2
2
3
3
## Description
4
4
5
-
This is a lightweight and extendable **PHP-API Framework** designed to help developers quickly build RESTful APIs. It supports common HTTP methods (GET, POST, PUT, DELETE) and provides a standardized JSON response structure. You can also customize the framework’s response wrapper to meet your specific needs.
5
+
This is a lightweight and extendable **PHP-API Framework** designed to help developers quickly build RESTful APIs. It provides easy management of API parameters (GET, POST) with support for defining allowed parameters, their required status, and data types. It also allows for flexible response formatting, making it easy to create custom APIs.
6
6
7
7
This framework can be easily integrated into any PHP project using Composer.
8
8
9
9
## Features
10
10
11
-
-**Standardized JSON Response**: All responses are returned in JSON format.
12
-
-**Custom Response Wrapper**: Allows you to define a custom response structure using a flexible wrapper.
13
-
-**Easy API Integration**: Very easy to use and integrate into any PHP project.
11
+
-**Standardized API Parameter Handling**: Easily manage allowed API parameters, including data types and required status.
12
+
-**Custom Response Wrapper**: Define a custom response structure using a flexible wrapper.
$api->setResponse(['message' => 'Parameters received successfully']);
71
95
$api->send();
72
96
```
73
97
@@ -82,7 +106,7 @@ The response will be wrapped in the custom format:
82
106
"execution_time": 0.02
83
107
},
84
108
"content": {
85
-
"message": "Hello, World!"
109
+
"message": "Parameters received successfully"
86
110
}
87
111
}
88
112
```
@@ -98,7 +122,25 @@ The response will be wrapped in the custom format:
98
122
-`getAllParameters()`: Returns all given GET and POST parameters as an array.
99
123
-`getGETParameters()`: Returns all given GET parameters as an array.
100
124
-`getPOSTParameters()`: Returns all given POST parameters as an array.
101
-
-`__get(string $property)`: ✨Magic✨ getter method for accessing properties dynamically through the $parameters array. Returns the property’s value or null if not found.
125
+
-`__get(string $property)`: ✨Magic✨ getter method for accessing properties dynamically through the `$parameters` array. Returns the property’s value or null if not found.
126
+
-`addParameter(APIParameter $parameter)`: Adds an allowed API parameter to the API instance. This defines the name, required status, and data type of the parameter.
127
+
128
+
## API Parameter Management
129
+
130
+
The `APIParameter` class helps you define the parameters for your API. Each parameter can be configured with the following properties:
131
+
132
+
-**Name**: The name of the parameter (e.g., `username`, `age`).
133
+
-**Required**: Whether the parameter is required for the request. Default is `false`.
134
+
-**Data Type**: The data type for the parameter (e.g., `string`, `integer`, `boolean`).
0 commit comments