jcarrasco96 / my-api-rest
PHP library for creating secure and simple REST APIs.
Requires
- php: >=8.2
- ext-fileinfo: *
- ext-json: *
- ext-mbstring: *
- ext-openssl: *
- ext-pdo: *
- firebase/php-jwt: ^v6.10.0
This package is auto-updated.
Last update: 2025-06-22 15:44:06 UTC
README
ð Description
This project is a RESTful microframework written in pure PHP, designed for developing modern APIs in a simple, organized way without external dependencies. It includes dynamic controllers by convention, permission checking via attributes, access control, and request limits (RateLimit
).
ð Features
â
Versioned Controllers
â
Dynamic Routing
â
Custom Attributes
â
Permission Checking and JWT Tokens
â
Request Limiting
â
Layer Separation
â
No External Dependencies
ð Project structure
/attributes/
/core/
/exceptions/
/helpers/
/languages/
/models/
/services/
/validators/
composer.json
ð§ Requirements
â
PHP >=8.1
â
Apache or Nginx server (friendly URLs)
â
PDO extension enabled
â
File system access (for rate limiting)
âïļ Example of use
#[RateLimit(limit: 10, seconds: 60)] #[ControllerPermission(['?'])] #[ControllerMethod(['POST'])] public function actionLogin(): string { // Login logic and token generation }
ðĄ Example routes
GET /v1/user/index
POST /v1/user/create
GET /v1/product/view/5
The URL automatically determines the controller (UserController) and method (actionIndex, actionCreate, etc.).
ðĨ Installation
- Clone this repository
git clone https://github.com/Jcarrasco96/my-api-rest.git
- In composer.json of main application merge:
{ "require": { "jcarrasco96/my-api-rest": "1.0.*@dev" }, "repositories": [ { "type": "path", "url": "path\\to\\my-api-rest" } ] }