Skip to content

Repository files navigation

PHPJsonBeautifier

CI workflowReleasePHPPHPStanPHPStanLICENSE

An example project that uses the following techniques:

Run the app

Create a docker-compose.yml

Create a file named docker-compose.yml with the following content:

# ===========================================# ❯ mkdir docker-compose && cd docker-compose# ❯ vi docker-compose.yml# ===========================================version: "3.8"# Configure servicesservices:
# Nginx to serve the app.nginx:
image: "nginx:latest"container_name: "de.ixno.php-json-beautifier.nginx"hostname: "de-ixno-php-json-beautifier-nginx"restart: alwaysports:
- 8000:80volumes:
# Server static pages (uses the data from php service)
- data:/var/www/web# Add nginx configuration (uses the data from php service)
- nginx_config:/etc/nginx/conf.ddepends_on:
- php
- composer# Use ixnode/php-json-beautifier:latest image (originated from image php:8.0.11-fpm) with the data it containsphp:
image: "ixnode/php-json-beautifier:latest"container_name: "de.ixno.php-json-beautifier.php"hostname: "de-ixno-php-json-beautifier-php"restart: alwaysvolumes:
# This container shares the folder /var/www/web via volume data, because the container starts# first and the content already exists
- data:/var/www/web# This container shares the folder /var/www/web/docker/nginx/conf.d via volume nginx_config, because# the container starts first and the content already exists
- nginx_config:/var/www/web/docker/nginx/conf.d# Composer image: This container is executed once and performs a composer install.composer:
image: "composer:latest"container_name: "de.ixno.php-json-beautifier.composer"hostname: "de-ixno-php-json-beautifier-composer"command: ["composer", "install"]volumes:
- data:/app # This container shares the folder /app via volume data, because it already exists# Configure volumesvolumes:
data:
name: "de.ixno.php-json-beautifier.volume.data"nginx_config:
name: "de.ixno.php-json-beautifier.volume.nginx.config"

Create a .env file

If you like nicely named projects, use the .env file

# @see https://docs.docker.com/compose/reference/envvars/#compose_project_name# ❯ vi docker-compose/.env
COMPOSE_PROJECT_NAME=de-ixno-php-json-beautifier

Start containers

❯ docker-compose up -d

Open browser

Or use command line

Via parameter

❯ docker-compose exec php bin/console app:json:beautify '{"value": "123"}'
{
"value": "123"
}

Via STDIN

echo'{"value": "123"}'| docker-compose exec php bin/console app:json:beautify
{
"value": "123"
}

Other tasks

About

A fully working PHP sample project.

Resources

Security policy

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages