How To Install GEMVC

15 minutes BEGINNER

Get GEMVC up and running on your system in minutes. We'll cover system requirements, Docker installation (recommended), and manual setup options.

What You'll Learn

System Requirements

What you need before installing

Docker Installation

Quick setup with Docker (recommended)

Video tutorial thumbnail
Watch Tutorial

Prerequisites

  • Basic knowledge of PHP and command line
  • A computer with internet connection
  • Text editor or IDE (VS Code, PHPStorm, etc.)

Your development environment System Requirements

Minimum Requirements

PHP Version

PHP 8.1 or higher

installed Docker Desktop

depends on OS (Windows, macOS, Linux) on your local machine

Composer

Latest version

Note: For OpenSwoole support, PHP 8.2+ and OpenSwoole extension are required if you do not use Docker.

Check requirements (Recommended)

Why Docker? it provides a consistent environment with all dependencies pre-configured. ensures NOT ONLY "it works on my machine", also Docker Guarantees it will work everywhere!

Install Docker Desktop if you do not have it installed it on your local machine

  • Download Docker Desktop from docker.com
  • Install and start Docker Desktop
  • Verify installation by running:
Terminal
docker --version

check composer

Run this command to check if you have composer installed:

Terminal
composer --version

if you do not have composer installed, you can Download and install Composer from getcomposer.org if you do not have it installed.

1

Initialize your project

Step 1.1: Create new folder

Create a new directory for your project (anywhere on your PC you want) for "example my-gemvc-project" and navigate to it:

Terminal
mkdir my-gemvc-project
cd my-gemvc-project

Step 1.2: Download GEMVC Library via Composer

Run this command to download GEMVC Library in your project directory root:

Terminal
composer require gemvc/library

Step 1.3: Initialization Project

Gemvc comes with powerfull initialization command that will create the project structure and a .env file , also Docker file and Dockercompose file for your project with default settings based on your choice of server type (Apache, Nginx or OpenSwoole).

simply follow instructions in the terminal after you run the command, you can choose between Apache, Nginx or OpenSwoole as your server type.

Terminal
php vendor/bin/gemvc init

if you see the project is initialized successfully, congratulations! 🎉 Project is now initialized and ready to be Dockerized!

2

finilize your installation

Step 4.1: Dockerize your application

check if docker desktop is running and then run the following command:

Terminal
docker compose up -d --build

You can access to your api on http://localhost:9504 if you choose OpenSwoole or http://localhost:80 if you choose Apache or Nginx as your server type during initialization

if you see the GEMVC is running, congratulations! 🎉 GEMVC is now installed successfully!

Step 3.3: Initialization Database

Gemvc comes with MySql database defined in your docker-compose.yml file and database credentials in your .env files which they are located in your project root directory, simply you can initialize your database by running the following command in your terminal after you run step :

Terminal
php vendor/bin/gemvc db:init

this command will create the database and make it ready to cretate the tables in your database

you shall see the database is initialized successfully in terminal after you run the command

🎉 Installation Complete!

Great job! You've successfully installed GEMVC and initialized Database. Now let's build your first API!

Common Issues & Solutions

Port 8000 is already in use

Change the port in your command:

Terminal
php -S localhost:8080 -t public
Composer command not found

Make sure Composer is installed and in your system PATH. Download from:

https://getcomposer.org
Database connection failed

Check your .env file database credentials and ensure MySQL/PostgreSQL is running.

Terminal
# Test MySQL connection
mysql -u root -p