Download the PHP package yohan/rest-flex-php without Composer
On this page you can find all versions of the php package yohan/rest-flex-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download yohan/rest-flex-php
More information about yohan/rest-flex-php
Files in yohan/rest-flex-php
Package rest-flex-php
Short Description RestFlexPHP is a robust PHP package meticulously crafted to simplify the intricacies of handling HTTP requests, with a primary focus on supercharging your experience in managing RESTful APIs. This package provides an elegant and developer-friendly interface, allowing you to effortlessly send requests, handle responses, and navigate RESTful endpoints with finesse. Elevate your PHP-based API interactions with RestFlexPHP and enjoy a seamless development journey.
License Apache-2.0
Informations about the package rest-flex-php
RestFlexPHP
RestFlexPHP
is a lightweight PHP package designed to simplify handling RESTful requests and responses. It includes a flexible controller class (RestFlexController
) for routing requests and a request class (RestFlexRequest
) for encapsulating request-related data.
Installation
You can install RestFlexPHP
using Composer:
Setting up URL Rewriting
To enable URL rewriting for your RESTful API, you need to create an .htaccess
file in the same directory as your main logic file (e.g., index.php
). The file should contain the following mod_rewrite rules:
Usage
RestFlexController
The RestFlexController
class provides a simple routing mechanism for handling HTTP requests. You can define routes using the get, post, put, and delete methods.
Example:
Example: Separating different routes with separate classes.
Here's a simple example demonstrating how to use RestFlexPHP
to create a basic UserController with user-related routes.
UserController.php
index.php
RestFlexRequest
The RestFlexRequest
class encapsulates request-related data and provides a convenient method (sendResponse) for sending JSON responses.
Example:
Contributing
If you find a bug, have a feature request, or want to contribute, please open an issue or submit a pull request. Contributions are welcome!
License
This package is licensed under the Apache-2.0 License