For my comfort in Windows, I want to prepare some PHP tools launched like in Unix.
f.e.: composer create-project symfony/framework-standard-edition path/
Not: php composer.phar create-project symfony/framework-standard-edition path/
I made composer.bat file in system path dir:
php C:\path\to\composer\composer.phar
and its works in simply usage. But how to forward all parameter and flags to command inside?
You can pass in the batch1. bat variables as arguments to batch2. bat. @echo off cls set file_var1=world set file_var2=%computername% call arg_batch2.
Use double percent signs ( %% ) to carry out the for command within a batch file. Variables are case sensitive, and they must be represented with an alphabetical value such as %a, %b, or %c. Required. Specifies one or more files, directories, or text strings, or a range of values on which to run the command.
%%parameter : A replaceable parameter: in a batch file use %%G (on the command line %G) FOR /F processing of a command consists of reading the output from the command one line at a time and then breaking the line up into individual items of data or 'tokens'.
Use >filename. txt 2>&1 to merge Standard Output and Standard Error and redirect them together to a single file. Make sure you place the redirection "commands" in this order.
in your batch file composer.bat, simply put:
php C:\path\to\composer\composer.phar %*
windows gives you %*
to refer to all parameters.
Your new composer.bat file will then becomephp C:\path\to\composer\composer.phar %*
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With