Download the PHP package nextphp/rest without Composer
On this page you can find all versions of the php package nextphp/rest. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package rest
Short Description The NextPHP Rest package provides powerful routing capabilities and HTTP handling for PHP developers. This package supports all RESTful methods (GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD, TRACE, CONNECT, PRI) and various response formats such as JSON, XML, HTML, TEXT, and CSV. It is part of the NextPHP Framework, a modern and lightweight PHP framework designed for performance and scalability.
License MIT
Homepage https://nextphp.io
Informations about the package rest
NextPHP Rest Package
The NextPHP Rest package provides powerful routing capabilities and HTTP handling for PHP developers. This package supports all RESTful methods (GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD, TRACE, CONNECT, PRI) and various response formats such as JSON, XML, HTML, TEXT, and CSV. It simplifies the creation of APIs by allowing developers to define routes and controllers using attributes, ensuring a clean and efficient codebase.
This package is part of the NextPHP Framework, a modern and lightweight PHP framework designed for performance and scalability. NextPHP aims to provide a comprehensive suite of tools and libraries to streamline the development process.
Features
- Support for all RESTful methods (GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD, TRACE, CONNECT, PRI)
- Response formats: JSON, XML, HTML, TEXT, CSV
- Attribute-based route definitions
- Middleware support
- Easy integration with existing projects
Installation
Installing via Composer
To install the NextPHP Rest package, you need to add it to your project using Composer.
Example Project using NextPHP Rest
This is an example project demonstrating the usage of the NextPHP Rest package, which includes routing and HTTP handling capabilities.
Basic Usage Defining Routes Define routes using attributes to map HTTP methods to controller actions.
Usage
Using Controller
Advanced Entity Usage
Middleware Usage
Define middleware using attributes to apply them to routes. You can apply middleware to an entire controller class with #[Middleware(AuthMiddleware::class)]
, or to individual routes with method-specific attributes.
Generate AuthMiddleware Class
AuthMiddleware handle JWT authentication check for HTTP request and response.
Service Layer Example
Services provide business logic and interact with repositories.
Example Project
Example for your Project Structure
Example or example.php
To use the NextPHP Rest package, you can create an index.php file and use the router to handle various HTTP requests. Here is an example of how you can do this:
Example index.php
Contributing
We welcome contributions! Here’s how you can help:
- Report Issues: Found a bug? Report it on GitHub.
- Suggest Features: Have an idea? Share it with us.
- Submit Pull Requests: Improve the codebase.
- Enhance Documentation: Help us improve our docs.
For more details, see our Contribution Guidelines.
Resources
Join Our Community
Contact Us
- Email: [email protected]
- Forum: NextPHP Mastodon
- GitHub Issues: NextPHP GitHub
Thank you for being part of the NextPHP community!
FAQ
Q: How do I define a route?
A: Use the #[Get], #[Post], #[Put], #[Delete], #[Patch], etc. attributes to define a method as a route handler. Use #[RouteGroup] to define a common prefix for a group of routes.
For more details, see our FAQ.