I am trying to learn how to access PHP scripts from the command line [CLI]
Below is an image from my attempt, please help. I am running Windows 7
asked Sep 5, 2011 at 11:41
JasonDavisJasonDavis
47.2k97 gold badges306 silver badges527 bronze badges
You need to add your PHP
installation directory to the %PATH%
environment variable, or work from the PHP installation directory.
To add it to path [The best approach - Edited for Windows 7]:
- Right-click on a
My Computer
icon - Click
Properties
- Click
Advanced system settings
from the left nav - Click
Advanced
tab - Click
Environment Variables
button - In the
System Variables
section, selectPath
[case-insensitive] and clickEdit
button - Add a semi-colon [
;
] to the end of the string, then add the full file system path of your PHP installation [e.g.C:\Program Files\PHP
] - Keep clicking
OK
etc until all dialog boxes have disappeared - Close your command prompt and open it again
- Sorted
Alternatively, you can run cd
before you try and run you command, or call your script like
answered Sep 5, 2011 at 11:44
DaveRandomDaveRandom
86.8k11 gold badges150 silver badges174 bronze badges
5
For temporary use, try this: [benefit for use npm
or
composer
]
> SET PATH=c:\wamp\bin\php\php5.3.29\;%PATH%
For test use this:
> echo %PATH%
c:\wamp\bin\php\php5.3.29\;c:\anothers\;
Now you can access to PHP
command:
> php -v
PHP 5.3.29 [cli]
answered May 17, 2018 at 2:29
1
Easy Way: Run CMD then type
C:\wamp\bin\php\php5.4.3\php.exe -f "C:\wamp\www\timenow.php"
Change the last part for a different script, and make sure you have the same version php folder as I do. [php5.4.3]
answered Feb 3, 2014 at 16:02
Mikeys4uMikeys4u
1,43818 silver badges26 bronze badges
1
On 2020 and with Windows 10 there's an easier way to achieve this.
1- Download composer at //getcomposer.org/Composer-Setup.exe
2- Install it as you install any program on windows and [important] when it asks you the path to PHP, browse thru the correct path [for example: c:/wamp/bin/php.exe]
FINNISHED! Close the cmd and reopen and you can run PHP on your command line and also COMPOSER [composer is actually very needed if you use PHP]
answered Jul 4, 2020 at 21:24
gtamborerogtamborero
2,47723 silver badges23 bronze badges
you can run cd before you try and run you command, or call your script like
answered Dec 16, 2021 at 4:18
1 answer to this question.
Hello @kartik,
You can get a full phpinfo[] using :
php -i
And, in there, there is the php.ini file used :
$ php -i | grep 'Configuration File' Configuration File [php.ini] Path => /etc Loaded Configuration File => /etc/php.ini
On Windows use find instead:
php -i|find/i"configuration file"
Hope this is helpfull!!
Thank You!!
• 82,780 points
Related Questions In PHP
- All categories
- Apache Kafka [84]
-
Apache Spark [596]
- Azure [131]
- Big Data Hadoop [1,907]
-
Blockchain [1,673]
- C# [124]
- C++ [268]
-
Career Counselling [1,060]
- Cloud Computing [3,356]
- Cyber Security & Ethical Hacking [145]
- Data Analytics [1,266]
- Database [853]
- Data Science [75]
-
DevOps & Agile [3,500]
- Digital Marketing [111]
- Events & Trending Topics [28]
- IoT [Internet of Things] [387]
- Java [1,178]
- Kotlin [3]
-
Linux Administration [384]
- Machine Learning [337]
- MicroStrategy [6]
-
PMP [423]
- Power BI [516]
- Python [3,154]
- RPA [650]
- SalesForce [92]
- Selenium [1,569]
- Software Testing [56]
- Tableau [608]
-
Talend [73]
- TypeSript [124]
- Web Development [2,999]
-
Ask us Anything! [66]
- Others [1,064]
- Mobile Development [46]
Subscribe to our Newsletter, and get personalized recommendations.
Already have an account? Sign in.