jcarrasco96/my-api-rest

PHP library for creating secure and simple REST APIs.

dev-main 2025-06-22 15:42 UTC

This package is auto-updated.

Last update: 2025-06-22 15:44:06 UTC


README

PHP

Ask DeepWiki

📝 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

  1. Clone this repository
    git clone https://github.com/Jcarrasco96/my-api-rest.git
    
  2. In composer.json of main application merge:
    {
      "require": {
        "jcarrasco96/my-api-rest": "1.0.*@dev"
      },
      "repositories": [
        {
          "type": "path",
          "url": "path\\to\\my-api-rest"
        }
      ]
    }

ðŸŠĪ Pull requests are welcome