Skip to content

Commit

Permalink
dotenv file plus rector (#983)
Browse files Browse the repository at this point in the history
use docker compose 'env_file' to include all .env file vars in container env
make the default rector action dry-run, which allows developers to inspect code changes
before applying them (and therefore giving the option to disable new rules before they
are applied to WIP).
  • Loading branch information
brettmc authored May 2, 2023
1 parent 77da950 commit 4890bd4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 19 deletions.
5 changes: 3 additions & 2 deletions .env.dist
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
PHP_USER=php
XDEBUG_MODE=debug
#docker-compose or "docker compose" for v1/v2 respectively
DOCKER_COMPOSE=docker-compose
PHP_CS_FIXER_IGNORE_ENV=true
#docker-compose or "docker compose" for v1/v2 respectively, note that v1 support ends 06/2023
DOCKER_COMPOSE=docker compose
19 changes: 9 additions & 10 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ For repeatability and consistency across different operating systems, we use the

Skipping the step above would result in a "`The "PHP_USER" variable is not set. Defaulting to a blank string`" warning

We use `docker` and `docker-compose` to perform a lot of our static analysis and testing. If you're planning to develop for this library, it'll help to install `docker engine` and `docker-compose`.

The installation instructions for these tools are [here](https://docs.docker.com/install/), under the `Docker Engine` and `Docker Compose` submenus respectively.
We use `docker` and `docker compose` to perform a lot of our static analysis and testing. If you're planning to develop for this library, it'll help to install
[docker engine](https://docs.docker.com/engine/install/) and the [compose plugin](https://docs.docker.com/compose/install/).

Development tasks are generally run through a `Makefile`. Running `make` or `make help` will list available targets.

Expand Down Expand Up @@ -115,21 +114,21 @@ We use [Rector](https://github.com/rectorphp/rector) to automatically refactor o
and upgrade the code to supported PHP versions.
The associated configuration can be found [here](./.rector.php)

To refactor your code following our given standards, you can run:
If you want to check what changes would be applied by rector, you can run:

```bash
make rector
```
This command will simply print out the changes `rector` would make without actually changing any code.

This command applies the changes to the code base.
Make sure to run `make style` (see below) after running the `rector`command as the changes might not follow our coding standard.

If you want to simply check what changes would be applied by rector, you can run:
To refactor your code following our given standards, you can run:

```bash
make rector-dry
make rector-write
```
This command will simply print out the changes `rector`would make without actually changing any code.

This command applies the changes to the code base.
Make sure to run `make style` (see below) after running the `rector`command as the changes might not follow our coding standard.

## Styling

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ bash: ## bash shell into container
$(DC_RUN_PHP) bash
style: ## Run style check/fix
$(DC_RUN_PHP) env XDEBUG_MODE=off env PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --using-cache=no -vvv
rector: ## Run rector
rector-write: ## Run rector
$(DC_RUN_PHP) env XDEBUG_MODE=off vendor/bin/rector process src
rector-dry: ## Run rector (dry-run)
rector: ## Run rector (dry-run)
$(DC_RUN_PHP) env XDEBUG_MODE=off vendor/bin/rector process src --dry-run
deptrac: ## Run deptrac
$(DC_RUN_PHP) env XDEBUG_MODE=off vendor/bin/deptrac --formatter=table --report-uncovered --no-cache
Expand Down
7 changes: 2 additions & 5 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ services:
volumes:
- ./:/usr/src/myapp
user: "${PHP_USER}:root"
environment:
XDEBUG_MODE: ${XDEBUG_MODE:-off}
XDEBUG_CONFIG: ${XDEBUG_CONFIG:-''}
PHP_IDE_CONFIG: ${PHP_IDE_CONFIG:-''}
#PHP_CS_FIXER_IGNORE_ENV: "true"
env_file:
- .env
zipkin:
image: openzipkin/zipkin-slim
ports:
Expand Down

0 comments on commit 4890bd4

Please sign in to comment.