Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A ready to go, customizable, docker stack for PHP-CRUD-API

NotificationsYou must be signed in to change notification settings

nik2208/php-crud-api-quick-start

Repository files navigation

A customizable, ready-to-go, Docker Compose file featuring

  • PHP-CRUD-API
  • MySQL
  • PHP-FPM
  • NGINX
  • ADMINER/PHPMYADMIN
  • SWAGGER (OPENAPI)

INSTALLATION:

Just pull the repogit clone https://github.com/nik2208/php-crud-api-quick-start.git && cd php-crud-api-quick-start, rename the file.env.sample into.env and set the environment values to suite your needs:

#rename to .env# DOCKER STACK EXPOSED PORT.PORT=8080# API SUBDOMAIN (DNS RECORD A) OR HTTP(S)://IP_ADDRESS:PORT/ IF LOCALLY DEPLOYED# IF YOU DON'T HAVE AN FQDN (FULLY QUALIFIED DOMAIN NAME) AND YOU USE AN IP ADDRESS# (WHETHER PUBLIC OR PRIVATE), THE ADDRESS MUST CONTAIN THE STACK-EXPOSED PORT AS# CONFIGURED IN THE PREVIOUS STEP.SERVER_NAME=http://127.0.0.1:8080/############################################DATABASE PARAMETERSMYSQL_ROOT_PASSWORD=samplepasswordMYSQL_DATABASE=sampledbMYSQL_USER=sampleuserMYSQL_PASSWORD=samplepassword############################################API.PHP PARAMETERS#DEBUG MODEPHP_CRUD_API_DEBUG=1############################################DB ADMIN TOOL ("adminer" OR "phpmyadmin")DB_ADMIN_TOOL=phpmyadmin############################################CONTAINERS' NAME SUFFIXCONTAINERS_NAME_SUFFIX=php-quick-start

Then runstart.sh. Enjoy!🎉🚀

To stop the stack runstop.sh.

Refer toPHP-CRUD-API for further customizations.

REQUIREMENTS:

In case your running your instance on localhost and your selected port is 8080.

Yourtests table will be available athttp://127.0.0.1:8080/records/tests (no need of explicit api.php)1

Your MYSQL ADMIN instance will be available athttp://127.0.0.1:8080/dbadmin/

Your SWAGGER instance will be available athttp://127.0.0.1:8080/swagger/

Change ip and port accordingly if host and port differ.

REQUIREMENTS FOR THE INSTANCE TO BE REACHED OVER THE WEB

  • Any host runningDocker andDocker Compose.
  • A FQDN (Fully Qualified Domain Name), a public IP, areverse proxy to forwardYOUR A RECORD requests (e.g. api.exemple.com) to your Docker host2.

Yourtests table will be available athttps://api.example.com/records/tests (no need of explicit api.php)1

Your MYSQL ADMIN instance will be available athttps://api.example.com/dbadmin/

Your SWAGGER instance will be available athttps://api.example.com/swagger/

PERSISTENCY

After starting the Docker containers usingdocker-compose up -d, the MySQL database will be created and stored in themysql folder of the cloned project. This folder is used to persist the database data between container restarts. It is important to regularly back up this folder to avoid data loss.

GITLAB CI/CD

A.gitlab-ci.yml file is provided.3

The CI/CD flow expects to find a cloned repository on the deploying host, and the.env file properly set for that specific host/environment.The provided Gitlab pipeline encompasses three branches, related to three hosts/environments:

  • develop
  • staging
  • prod

Merges intodevelop will update the development environment, merges intostaging will update the staging environment, a commit tag will update the production environment.

Footnotes

  1. After your first deployment the database will be empty.2

  2. Minimal networking knowledge is required.

  3. Requires Gitlab CI/CD knowledge and Gitlab variables properly set.

About

A ready to go, customizable, docker stack for PHP-CRUD-API

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp