This docker image aims to containerize PHP CLI with useful devtools such as:
- composer v1.5.1
- php-cs-fixer v2.5.0
- phpmd v2.6.0
- phpunit v6.3.0
- phploc v4.0.0
- phpcs
v3.0.2v2.9.1 - coke v2.2.0
- Symfony coding standard v3.3.0
- Show PHP's version :
docker run -it --rm jeremyjumeau/phpcli --version
- Run a single PHP script :
docker run --rm -v $(pwd):$(pwd) -w $(pwd) jeremyjumeau/phpcli php your-script.php
- Describe @Symfony coding styles rules
docker run --rm jeremyjumeau/phpcli php-cs-fixer describe @Symfony
- Fix a php file's coding style to fit Symfony coding standard
# get the example file
wget https://raw.githubusercontent.com/jeremyjumeau/docker-phpcli/master/example-script.php
docker run --rm -v $(pwd):$(pwd) -w $(pwd) jeremyjumeau/phpcli php-cs-fixer fix example-script.php --rules=@Symfony --path-mode=override --using-cache=no --no-interaction
- Show PSR-2 (default) coding style violations
# get the example file
wget https://raw.githubusercontent.com/jeremyjumeau/docker-phpcli/master/example-script.php
docker run -i --rm -v $(pwd):$(pwd) -w $(pwd) docker-phpcli-with-devtools phpcs example-script.php
First, let's create the php
script file in /usr/local/bin
:
sudo vi /usr/local/bin/php
(your can replace vi
with your favourite editor)
Copy/paste the content below:
#!/bin/sh
docker run -i --rm -v $(pwd):$(pwd) -w $(pwd) jeremyjumeau/phpcli php $@
Then, give permissions to all users to execute this file:
sudo chmod +x /usr/local/bin/php
Finally, test the php
command:
php --version
wget https://raw.githubusercontent.com/jeremyjumeau/docker-phpcli/master/cli-setup.sh
chmod +x cli-setup.sh
sudo ./cli-setup.sh
This will install php
commands and all commands listed in the Overview section.
For Atom.io users
Now that you've set the shell commands above (have you?), just install those atom.io packages:
Should work out of the box 👍!
Should work out of the box 👍!
Go to the Settings panel, then in the Packages section, search phpcs
and click Settings to set set those values:
- Executable Path :
/usr/local/bin/phpcs
- Uncheck "Search for executables"
- Code Standard Or Config File :
vendor/m6web/symfony2-coding-standard/Symfony2
Notice that you'll have to add the dev dependency to the package in yourcomposer.json
config:composer require --dev m6web/symfony2-coding-standard
- Uncheck "Disable When No Config File"
- Check "Search for configuration files"
Go to the Settings panel, then in the Packages section, search php-cs-fixer
and click Settings to set set those values:
- Executable Path :
/usr/local/bin/php-cs-fixer
- If you're a Symfony user, set the "PHP-CS-Fixer Rules" to
@Symfony
Feel free to report any issue!