#}

GEMVC Quick Start Guide

Get your first API up and running in minutes with Docker

Quick Start Guide

Prerequisites

Before starting, ensure you have:

Installation Steps

1. Install GEMVC with Composer

Go to your project folder and run:

Terminal
composer require gemvc/library
Tip: Be sure you have installed Composer and PHP 8.1 or higher

2. Initialize Your Project

Run the init command to set up your project:

Terminal
php vendor/bin/gemvc init
info: You can choose webserver type in the prompt after init command

3. Build and Run with Docker

Start your development environment:

Terminal
docker compose up -d --build
info: GEMVC comes with a ready-to-use Docker setup (PHP, MySQL, Redis, PHPMyAdmin)

4. Test Your Installation

Open your browser and visit:

Terminal
http://localhost:9501

Your Achievements

Dockerized Application: PHP, MySQL, Redis, PHPMyAdmin ready
API Access: OpenSwoole: localhost:9501 | Apache: localhost:8080
Database Access: PHPMyAdmin on localhost:8080 (root/rootpassword)
Redis Access: redis-cli on localhost:6379 (rootpassword)

Database Setup

1. Initialize Database

Create the database in MySQL:

Terminal
php vendor/bin/gemvc db:init
info: Change database name in .env file before running this command if needed

2. Migrate User Table

Terminal
php vendor/bin/gemvc db:migrate UserTable
info: To see table structure: php vendor/bin/gemvc db:describe users

Create Your First API

1. Generate CRUD API

Generate a complete CRUD API for a resource:

Terminal
php vendor/bin/gemvc create:crud Product

This creates:

app/api/Product.php
API endpoints for your resource
app/controller/ProductController.php
Business logic and request handling
app/model/ProductModel.php
Data model for your resource
app/table/ProductTable.php
Database schema definition

2. Create Table in Database

Generate table based on your Table-Layer:

Terminal
php vendor/bin/gemvc db:migrate ProductTable
Tip: To see table structure: php vendor/bin/gemvc db:describe products

Test Your API

Try your endpoint:

Terminal
http://localhost:9501/product/list
Tip: OpenSwoole: localhost:9501 | Apache: localhost:80

Or visit the auto-generated API docs.

Sample response:

JSON
{ 
"response_code": 200,
"message": "OK",
"count": 0,
"service_message": "list of products fetched successfully"
"data": [],
}

Next Steps