
php
Articles in our magazine for php:
PHP and the Command Line: the perfect match
PHP happens mostly in the IDE and with the command line you come into contact less often. Nevertheless, there are many helpful commands.
List of commands for php:
-
php:ai:9b080 Retrieve ext-mongodb version$ php -i | grep mongo -C 2 | head -n 1 | awk -F ' ' '{print $3}'try on your machineexplain this command
-
php:ai:9fbda Get the version of an installed PHP extension$ php -i | grep ${extension_name} | grep 'Version'try on your machineexplain this command
-
php:code-beautifier-and-fixer:install:dev Install "PHP Code Beautifier and Fixer" from a Composer package as a dev dependency$ composer require --dev squizlabs/php_codesniffertry on your machineexplain this command
-
php:code-beautifier-and-fixer:run Run PHP Code Beautifier and Fixer$ php vendor/bin/phpcbftry on your machineexplain this command
-
php:code:run Run PHP code (Notes: Don't use ?> tags; escape double quotes with backslash).$ php -r "${code}"try on your machineexplain this command
-
php:config:show Show the PHP configuration for the CLI version$ php -itry on your machine
-
php:extensions:list Get a list of installed PHP extensions.$ php -mtry on your machineexplain this command
-
php:function:information Display information about a specific function.$ php --rf ${function_name}try on your machineexplain this command
-
php:ini:which Show the location of the php.ini file (CLI)$ php -i | grep php\.initry on your machine
-
php:lint Check for syntax errors in php files (linting)$ php -l ${filename}try on your machine
-
php:phar:decompress Decompress a phar file to a given directory$ php -r '$phar = new Phar("${phar_file}"); $phar->extractTo("${directory_to_decompress_to}");'try on your machine
-
php:script:run Run a PHP CLI script$ php ${filename}try on your machine
-
php:script:run:memory_limit Run a PHP CLI script with a defined memory limit$ php -d memory_limit=${limit_in_megabyte}M ${filename}try on your machineexplain this command
-
php:server:start Starting the built-in web server$ php -S localhost:8000try on your machineexplain this command
-
php:version:install Install a given PHP version.$ sudo apt install software-properties-common
$ sudo add-apt-repository ppa:ondrej/php
$ sudo apt update
$ sudo apt install php${version}try on your machineexplain this command