2016-04-08 14 views
2

Ich habe Probleme, diesen Befehl Linux verstehen:
php -r "readfile('https://getcomposer.org/installer');" | php -c php.iniLegendes Rohrleitungen: PHP -c

Es erscheint der erste Teil php -r auf php -c kochend. Aber es erscheint php.ini wird lesen.

Wo kann ich mehr über PHP-Befehlsoptionen herausfinden und sie meinen (-v und -c), und damit herausfinden, was der Befehl macht?

+1

Was stimmt nicht mit der [Dokumentation] (http://php.net/manual/en/features.commandline.options.php)? –

+1

@JoeHabadas Ich bin ein PHP-Neuling. Wie hast du das gefunden? Ich habe "PHP-Optionen", "PHP-C", "PHP-V" gegoogelt und habe es nicht gefunden. – Tosh

+0

'php --help',' man php' ... du brauchst dafür nicht mal internet. –

Antwort

3

Von man php:

OPTIONS --interactive -a Run PHP interaktiv. Damit können Sie Snippets von PHP-Code eingeben, die direkt ausgeführt werden. Wenn readline unterstützt Port aktiviert ist, können Sie die Zeilen bearbeiten und haben auch Verlaufsunterstützung.

--bindpath address:port|port 
    -b address:port|port 
       Bind Path for external FASTCGI Server mode (CGI only). 

    --no-chdir 
    -C    Do not chdir to the script's directory (CGI only). 

    --no-header 
    -q    Quiet-mode. Suppress HTTP header output (CGI only). 

    --timing count 
    -T count  Measure execution time of script repeated count times 
       (CGI only). 

    --php-ini path|file 
    -c path|file Look for php.ini file in the directory path or use the 
       specified file 

    --no-php-ini 
    -n    No php.ini file will be used 

    --define foo[=bar] 
    -d foo[=bar] Define INI entry foo with value bar 

    -e    Generate extended information for debugger/profiler 

    --file file 
    -f file  Parse and execute file 

    --help 
    -h    This help 

    --hide-args 
    -H    Hide script name (file) and parameters (args...) from 
       external tools. For example you may want to use this 
       when a php script is started as a daemon and the command 
       line contains sensitive data such as passwords. 

    --info 
    -i    PHP information and configuration 

    --syntax-check 
    -l    Syntax check only (lint) 

    --modules 
    -m    Show compiled in modules 

    --run code 
    -r code  Run PHP code without using script tags '<?..?>' 

    --process-begin code 
    -B begin_code Run PHP begin_code before processing input lines 

    --process-code code 
    -R code  Run PHP code for every input line 

    --process-file file 
    -F file  Parse and execute file for every input line 

    --process-end code 
    -E end_code Run PHP end_code after processing all input lines 

    --syntax-highlight 
    -s    Output HTML syntax highlighted source 

    --server addr:port 
    -S addr:port Start built-in web server on the given local address and 
       port 

    --docroot docroot 
    -t docroot  Specify the document root to be used by the built-in web 
       server 

    --version 
    -v    Version number 

    --strip 
    -w    Output source with stripped comments and whitespace 

    --zend-extension file 
    -z file  Load Zend extension file 

    args...  Arguments passed to script. Use '--' args when first 
       argument starts with '-' or script is read from stdin 

    --rfunction name 
    --rf   name Shows information about function name 

    --rclass  name 
    --rc   name Shows information about class name 

    --rextension name 
    --re   name Shows information about extension name 

    --rzendextension 
       name 
    --rz   name Shows information about Zend extension name 

    --rextinfo  name 
    --ri   name Shows configuration for extension name 

    --ini   Show configuration file names 

Von php.net:

Verbrauch: php [Optionen] [-f] [-] [args ...] php [Optionen] -r [--] [args...] php [options] [-B ] -R [-E ] [--] [args...] php [options] [-B ] -F [-E ] [--] [args...] php [options] -- [args...]
php [options] -a

-a Run interactively -c | Look for php.ini file in this directory -n No php.ini file will be used -d foo[=bar] Define INI entry foo with value 'bar' -e Generate extended information for debugger/profiler -f
Parse and execute . -h This help -i
PHP information -l Syntax check only (lint) -m
Show compiled in modules -r Run PHP without using script tags -B Run PHP before processing input lines -R Run PHP for every input line -F Parse and execute for every input line -E Run PHP after processing all input lines -H Hide any passed arguments from external tools. -S : Run with built-in web server. -t Specify document root for built-in web server. -s
Output HTML syntax highlighted source. -v Version number -w Output source with stripped comments and whitespace. -z Load Zend extension .

args... Arguments passed to script. Use -- args when first argument starts with - or script is read from stdin

--ini Show configuration file names

--rf Show information about function . --rc Show information about class . --re
Show information about extension . --rz Show information about Zend extension . --ri Show configuration for extension .

Edit:

php -r "readfile('https://getcomposer.org/installer');" | php -c php.ini 

This command runs the file https://getcomposer.org/installer using php.ini in the current directory as the config file. The same can be achieved with

php -r "require('https://getcomposer.org/installer');" -c php.ini 
+0

Danke. Könnten Sie hinzufügen, was der Befehl Ihrer Meinung nach macht? – Tosh

2

Running php mit der -c Option sagt ihm einfach, wo seine Konfigurationsdatei zu finden ist. Die -r Option teilt es mit, den bereitgestellten Code auszuführen.

Was Ihr Befehl tut, holt sich entfernten PHP-Code und leitet ihn dann an einen anderen PHP-Prozess weiter, der ausgeführt werden soll.

Sofern Sie keine spezielle Konfigurationsanforderung haben (und eine php.ini Datei im aktuellen Verzeichnis haben), wird die Option -c nicht benötigt.

Ich empfehle, dies übrigens nicht zu tun. Es ist ein unnötiges Risiko, unbekannten Code auf Ihrem Computer auszuführen, selbst wenn er aus einer bekannten Quelle stammt.