Build a container that automatically formats Docker x Laravel code

What is PHP CS Fixer?

PHP CS Fixer (PHP Coding Standards Fixer) is, as the name suggests, a tool that modifies PHP code to comply with coding standards. ..

Premise

-Build the strongest Laravel development environment using Docker [new edition]

This article is a supplement to the above article.

Edit docker-compose.yml

docker-compose.yml


services:
  cs:
    image: herloct/php-cs-fixer
    volumes:
      - ./backend:/project

Add services.cs.

command

#Do not automatically shape(Difference display only)
$ docker-compose run cs fix --dry-run -v --diff --diff-format udiff .

#Automatically shape
$ docker-compose run cs fix -v --diff --diff-format udiff .

Makefile

Since the command is long, it is good to prepare a Makefile.

dry-cs:
	docker-compose run cs fix --dry-run -v --diff --diff-format udiff .
fix-cs:
	docker-compose run cs fix -v --diff --diff-format udiff .

You can execute it with the following command.

$ make dry-cs
$ make fix-cs

reference

-Laravel PHP-CS-Fixer rule settings -Check your PHP file with php-cs-fixer

Recommended Posts

Build a container that automatically formats Docker x Laravel code
Build a container for Docker x Laravel phpMyAdmin
Build a Laravel / Docker environment with VSCode devcontainer
Build a Kotlin app using OpenJDK's Docker container
Build a docker container for a python simple web server
One file of Docker x Laravel threat! Build a local development environment with the minimum configuration
Build a SPA for Laravel 6.2 / Vue.js / Nginx / Mysql / Redis with Docker
A little happy that Nginx's Docker container defaults to graceful shutdown
I tried to build a laravel operating environment while remembering Docker
Build a Node.js environment with Docker
Run React on a Docker container
Build Clang x VSCode on Docker (1)
Run PureScript on a Docker container
Build docker + laravel environment with laradock
Build WebRTC Janus with Docker container
[Copy and paste] Build a Laravel development environment with Docker Compose Part 2
Run x11 apps in a Docker container (supports network access from the container)
How to build a Ruby on Rails development environment with Docker (Rails 6.x)
[Docker] How to build when the source code is bind-mounted on the container
[Copy and paste] Build a Laravel development environment with Docker Compose Participation
How to build a Ruby on Rails development environment with Docker (Rails 5.x)
Template: Build a Ruby / Rails development environment with a Docker container (Ubuntu version)
Template: Build a Ruby / Rails development environment with a Docker container (Mac version)
Build a PureScript development environment with Docker
Quick build maven project using maven docker container
Build a Wordpress development environment with Docker
Docker container build fails to install php-radis
Build Redmine code reading environment on Docker
Build by specifying docker as a file
Build a simple Docker + Django development environment
[Part 1] Creating a Docker container that delivers Markdown in HTML with Apache / Pandoc
Point memo that was moss when building a docker container created by a colleague