app/api/User.php

namespace App\Api;

use Gemvc\Core\ApiService;
use Gemvc\Http\Request;
use Gemvc\Http\JsonResponse;
use App\Controller\UserController;

class User extends ApiService {
    public function __construct(Request $request) {
        parent::__construct($request);
    }
    //API endpoint is https://yourdomain.com/api/user/getUsers    
    public function getUsers(): JsonResponse {
        // Check if the user is admin
        if (!$this->request->auth(['admin'])) {
            return $this->request->returnResponse();
        }
        return (new UserController($this->request))->list();
    }
}

GEMVC - Lightweight PHP Framework built for Microservices

Easy to Learn and implement but Well Documented, modern OpenSwoole/Apache/Nginx PHP library/framework to Build professional, High performant, Dockerized and secure Microservice APIs in minutes, not hours.

... installs
... stars
... forks
... contributors
1

Install with Composer

Terminal
composer require gemvc/library
2

Initialize GEMVC

Terminal
php vendor/bin/gemvc init
3

Run with Docker

Terminal
docker compose up -d --build
php >=8.2 license MIT OpenSwoole Supported Apache Supported Nginx Supported PHPStan Level 9 PHPUnit Supported Pest Supported

Core Features

Security by Principle

Built-in JWT authentication, input sanitization, and comprehensive protection against common vulnerabilities.

Webserver Agnostic

Seamlessly switch between OpenSwoole, Apache or Nginx servers! Your code works identically on all of them.

AI Ready

Built-in APIs and interfaces optimized for AI assistant integration and automation.

Super Light

Whole of GEMVC with its dependencies is under 2MB with very low memory footprint and minimal dependencies.

Database Abstraction

Type-safe queries, ORM capabilities, and table generation with connection pooling for maximum performance.

Postman Collection

Visit /index/documentation in your project root, download and import JSON file to start testing your APIs.

Library & Framework

Use it as a powerful library to modernize legacy projects, or as a complete framework for new applications.

Real-time Ready

WebSocket support with Redis scaling for real-time applications and live updates.

High Performance

OpenSwoole full support with Redis integration, GEMVC is built for high-traffic demands without code changes.

Type-Safe Architecture

Type-Safe from Request to Response lifecycle, in controller, model, and Database.

Powerful CLI

Project Initialization, DB Migration, and code generation based on your own coding style!

Easy Installation

With help of Composer and Docker, you can install and use GEMVC in your project in seconds.

Ready to Start Your Journey?

Begin with learning GEMVC and become an expert developer to build modern, secure PHP applications!

How To Install

Get GEMVC up and running on your system in minutes

learn how to install gemvc

Gemvc Overview

Basic and fast understanding of Gemvc Philosophy, Architecture and Request Lifecycle, it helps to develop effective and efficient application

learn gemvc overview

Authentication

How to Authenticate and Authorize API users and requests with built-in JWT token

Setup Auth

API Documentation

How to create and use documentation for your API

View Docs Guide

How to Use CLI

List of CLI commands for GEMVC and how to use them

CLI Reference

API Security

How to secure your APIs against attacks

Security Guide

Best Practices

How to write clean and maintainable code

Best Practices

AI Assistance

How to use the power of AI Assistance like Copilot, Cursor or Gemini

AI Integration

Complex Model

How to create complex models from different tables and relations

Model Guide

Redis

How to implement and use the power of Redis in your project

Redis Guide

Static Test

How to use the power of Static Test PhpStan Level 9 in your project

Testing Guide

Do you need frontend for your project?

Try STCMS! Power of PHP and React under same roof!