Skip to content

Commit

Permalink
docs(readme): updated the description texts
Browse files Browse the repository at this point in the history
  • Loading branch information
Heiko Mamerow committed Apr 12, 2023
1 parent b0a3594 commit 8fa1b89
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@

## Background

If you work with different docker environments at the same time you need to manage the ports. *wp-env* uses port 8888 by default. If this port is already in use by another project then you have a problem. But the solution is easy: Just change the ports.
If you are working with different Docker environments at the same time, you need to manage the ports. *wp-env* uses port 8888 by default. If this port is already used by another project, you have a problem. But the solution is simple: just change the ports.

*wp-env-port-stamp* generates every time a new port address - more or less - randomly. When the package is called, it creates a file *.wp-env.json* in the directory where it was called. With this *.wp-env.json* file you can customize the WordPress installation. In our case dynamic rendered port numbers.
*wp-env-port-stamp* generates a new port address - more or less - randomly. When the package is called, the following happens:

The port number will be generated from the current JavaScript date - the time in milliseconds since the ECMAScript epoch. We take the last 4 numbers of this time as the port number. This solution my not be perfekt but good enough for your daily local web development with a handful docker instances. :-)
* It checks if a file *.wp-env.json* exists in the executing directory.
* If so, only the two ports are set or changed. The other values remain untouched.
* If no, a new file is created.

The port number is generated from the current JavaScript date - the time in milliseconds since the ECMAScript epoch. We take the last digits of this time as the port number. This number is somewhere between 1 and 65535. There is also a filter that prevents commonly used port numbers (e.g. 8888) from being used.

My solution may not be perfect, but it is good enough for daily local web development with a handful of Docker instances :-)

## Install/Remove

Expand All @@ -31,5 +37,3 @@ npm uninstall -g wp-env-port-stamp
3. The file is generated. You can start now with `wp-env`

Normally you only need to call the package for the first time in a new project. Later just start directly *wp-env*.

**Attention:** If there is already existing *.wp-env.json* file, *wp-env-port-stamp* will overwrite it! (There will be an improvement for this later.)

0 comments on commit 8fa1b89

Please sign in to comment.