Skip to content

Commit

Permalink
feat: PHP CS Fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
leocavalcante committed Dec 4, 2023
1 parent 0fc7020 commit ae5482a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ RUN apk add --no-cache \
&& mv /etc/php/php.ini /etc/php${PHP}/conf.d/99_phpctl.ini \
&& wget https://raw.githubusercontent.com/composer/getcomposer.org/76a7060ccb93902cd7576b67264ad91c8a2700e2/web/installer -O - -q | php -- --quiet \
&& mv composer.phar /usr/bin/composer \
&& wget https://psysh.org/psysh && chmod +x psysh && mv psysh /usr/local/bin/psysh \
&& wget https://psysh.org/psysh && chmod a+x psysh && mv psysh /usr/local/bin/psysh \
&& wget https://cs.symfony.com/download/php-cs-fixer-v3.phar -O php-cs-fixer && chmod a+x php-cs-fixer && mv php-cs-fixer /usr/local/bin/php-cs-fixer \
&& rm -rf /var/cache/apk/*
ENTRYPOINT [ "/usr/bin/php" ]
CMD [ "-v" ]
25 changes: 13 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,20 @@ phpctl <command> [arguments]

### Commands

| Command | Description |
| --- |---------------------------------------------------------------------------------------------|
| `help` or `man` | Shows a help message. |
| `doctor` | Inspects the current `PHP_VERSION` and `PHPCTL_IMAGE`. |
| `install` | Installs `phpctl` (and `pctl`) globally in your system. |
| `build` | Builds the current `Dockerfile` (useful for custom images). |
| `images` | Shows local `phpctl` images. |
| `php` | **Runs PHP commands** (`phpctl php -v` or `pctl php -m`). |
| `composer` | Runs Composer commands (`phpctl composer install` or `pctl composer validate`). |
| Command | Description |
|-----------------------------|---------------------------------------------------------------------------------------------|
| `help` or `man` | Shows a help message. |
| `doctor` | Inspects the current `PHP_VERSION` and `PHPCTL_IMAGE`. |
| `install` | Installs `phpctl` (and `pctl`) globally in your system. |
| `build` | Builds the current `Dockerfile` (useful for custom images). |
| `images` | Shows local `phpctl` images. |
| `php` | **Runs PHP commands** (`phpctl php -v` or `pctl php -m`). |
| `composer` | Runs Composer commands (`phpctl composer install` or `pctl composer validate`). |
| `server [port] [directory]` | Runs PHP's built-in web-server (default port is `80` and default directory is current `.`). |
| `sh [commands]` | Starts an interactive Shell session or runs `sh` commands. |
| `at [port] [command]` | Run commands within a bound port (default port is `80`). |
| `repl` | Starts a PHP REPL session (powered by [PsySH](https://psysh.org/)). |
| `sh [commands]` | Starts an interactive Shell session or runs `sh` commands. |
| `at [port] [command]` | Run commands within a bound port (default port is `80`). |
| `repl` | Starts a PHP REPL session (powered by [PsySH](https://psysh.org/)). |
| `fix [directory]` | Runs PHP CS Fixer on the given directory. |

### The `.phpctl` file

Expand Down
1 change: 1 addition & 0 deletions src/help.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ help() {
echo " sh [commands] Starts an interactive Shell session or runs sh commands"
echo " at [port] [command] Runs commands within a bound port (default port is 80)"
echo " repl Starts a PHP REPL session (powered by PsySH)"
echo " fix [directory] Runs PHP CS Fixer on the given directory."
echo " "
}
9 changes: 9 additions & 0 deletions src/php.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,12 @@ at() {
port=${1:-80}
$(run "$PHPCTL_TTY -p$port:$port" "$2") ${@:3}
}

fix() {
if [ -n "$1" ]; then
$(run "$PHPCTL_TTY" php-cs-fixer) fix $@
exit 0
fi

$(run "$PHPCTL_TTY" php-cs-fixer) help fix
}

0 comments on commit ae5482a

Please sign in to comment.