jcarrasco96/my-api-rest

PHP library for creating secure and simple REST APIs.

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/jcarrasco96/my-api-rest

dev-main 2025-08-05 16:34 UTC

This package is auto-updated.

Last update: 2025-12-05 17:21:25 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
✅ Request Limiting
✅ Layer Separation
✅ No External Dependencies

📁 Project structure

/attributes/
/console/
/core/
/db/
/exceptions/
/languages/
/query/
/rest/
/validators/
composer.json
LICENSE.md
README.md (this file)

🔧 Requirements

✅ PHP >=8.2
✅ Apache or Nginx server (friendly URLs)
✅ PDO extension enabled
✅ File system access (for logs and rate limiting)

⚙ïļ Example of use of Rate Limit Checker

#[RateLimit(limit: 10, seconds: 60)]
#[Route('auth/login', [Route::ROUTER_POST])]
public function actionLogin(): string
{
    // Login logic and token generation
}

ðŸ“Ą Example routes

GET  /v1/user
POST /v1/user
GET  /v1/product/5

The URL automatically determines the controller and method.

ðŸ“Ĩ 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/simple-api-rest": "1.0.*@dev"
      },
      "repositories": [
        {
          "type": "path",
          "url": "path\\to\\my-api-rest\\src"
        }
      ]
    }
  3. In index.php of main application
    require_once 'vendor/autoload.php';
    
    $config = require_once 'config/rest.php'; // config file
    
    (new Rest($config))->run();

ðŸŠĪ Pull requests are welcome