Skip to main content

Installing, Configuring and Running PHP (via Command Line) on Windows; help by ChatGPT

Pelengkap (lagi) dr 2 Postingan sebelumnya:

Yg mengulas ttg Proses MengKompilasi

SUMMARY
1) INSTALLING PHP or Python via Command Line Interface (CLI) on Windows

2) CONFIGURING/PATH-SETTING (so that being able to run php or python from any folder):
  • Open Environment Variables in Windows
  • Add PHP or Python to your PATH variable 
  • How to check if PHP or Python is already in your PATH (before adding it /to avoid duplicates)

3) RUNNING a PHP/Python file via the Command Line Interface (CLI)


1) INSTALLING PHP or Python via Command Line Interface (CLI) on Windows

Guide to installing PHP and Python via Command Line Interface (CLI) on Windows, step-by-step, no GUI needed.

🐘 INSTALL PHP via CLI

1️⃣ Download PHP (latest stable version)

Open PowerShell (Run as Administrator) and run:

curl -LO https://windows.php.net/downloads/releases/php-8.3.12-Win32-vs16-x64.zip

(You can check the latest version at https://windows.php.net/download/)

2️⃣ Extract the ZIP file

mkdir C:\php
tar -xf php-8.3.12-Win32-vs16-x64.zip -C C:\php

3️⃣ Add PHP to PATH

setx PATH "%PATH%;C:\php"

Then close and reopen PowerShell or CMD.

4️⃣ Verify PHP installation

php -v

You should see something like:

PHP 8.3.12 (cli) (built: Sep 2025)

✅ PHP is ready for CLI use.

🐍 INSTALL PYTHON via CLI

1️⃣ Download Python (latest stable Windows installer)

curl -LO https://www.python.org/ftp/python/3.12.6/python-3.12.6-amd64.exe

(You can replace the version with the latest one from https://www.python.org/downloads/windows/)

2️⃣ Run the installer silently (no GUI)

Start-Process python-3.12.6-amd64.exe -ArgumentList "/quiet InstallAllUsers=1 PrependPath=1 Include_test=0" -Wait

🧩 This installs Python for all users and adds it to PATH automatically.

3️⃣ Verify Python installation

python --version

or

py --version

✅ You should see something like:

Python 3.12.6

🔧 Quick Summary Table

Tool Details Logo
PHP Download:
curl -LO https://windows.php.net/downloads/releases/php-8.3.12-Win32-vs16-x64.zip

Install Location:
C:\php

PATH Command:
setx PATH "%PATH%;C:\php"

Verify:
php -v
PHP Logo
Python Download:
curl -LO https://www.python.org/ftp/python/3.12.6/python-3.12.6-amd64.exe

Install Location:
C:\Program Files\Python312

PATH Command:
(auto)

Verify:
python --version
Python Logo

2) CONFIGURING/PATH-SETTING (so that being able to run php or python from any folder)

A. Here are several ways to open Environment Variables in Windows 👇

🧭 Method 1: Through System Properties

  1. Right-click on This PC (or My Computer) → select Properties.

  2. Click Advanced system settings (on the left sidebar).

  3. In the System Properties window, under the Advanced tab, click Environment Variables….
    ✅ This opens the Environment Variables window.


⚙️ Method 2: Using Windows Search

  1. Press Windows + S and type:

    environment variables
    
  2. Choose “Edit the system environment variables” or “Edit environment variables for your account.”


🏃 Method 3: From Run Command

  1. Press Windows + R

  2. Type:

    SystemPropertiesAdvanced
    
  3. Hit Enter → click Environment Variables button.


💻 Method 4: From Command Prompt / PowerShell

  • You can open the same window by running:

    rundll32 sysdm.cpl,EditEnvironmentVariables
    

    or

    SystemPropertiesAdvanced
    

    → then click Environment Variables.


2) CONFIGURING/PATH-SETTING (so that being able to run php or python from any folder)

B. How to add PHP or Python to your PATH variable (so you can run php or python from any folder)!

🧭 Method 1: Using the Windows GUI

✅ Steps:

  1. Press Windows + S and search for
    “Environment Variables”
    Then choose “Edit the system environment variables”.

  2. In the window that opens, click the Environment Variables… button.

  3. Under System variables, find and select Path, then click Edit.

  4. Click New, then add your folder path:

    • For PHP → C:\php

    • For Python → C:\Python39 (or whatever version you have)

  5. Click OKOKOK again.

  6. Restart Command Prompt or PowerShell for changes to take effect.

  7. Test it:

    php -v
    

    or

    python --version

⚙️ Method 2: Using Command Line

You can also add it via CLI (Command Prompt or PowerShell):

➤ For PHP

setx PATH "%PATH%;C:\php"

➤ For Python

setx PATH "%PATH%;C:\Python39"

(Replace C:\Python39 with your actual Python folder.)

After running that command, close and reopen your terminal.
Then test:

php -v

or

python --version


🧩 Quick Tip:

If PHP or Python is installed in a folder with spaces (like C:\Program Files\PHP), wrap it in quotes:

setx PATH "%PATH%;\"C:\Program Files\PHP\""

2) CONFIGURING/PATH-SETTING (so that being able to run php or python from any folder)

C. How to check if PHP or Python is already in your PATH (before adding it /to avoid duplicates)!

🧭 Method 1: Using Command Prompt

✅ Check current PATH

echo %PATH%

This will print a long list of folders separated by semicolons ;.
👉 Look through it and see if you can find:

  • C:\php

  • C:\Python39 (or another version, like C:\Users\<YourName>\AppData\Local\Programs\Python\Python312)

If you find one — that means PHP or Python is already in your PATH.


⚙️ Method 2: Using PowerShell (cleaner view)

Run:

$env:PATH -split ';'

This splits the PATH into one line per folder.
You’ll easily see if C:\php or C:\Python39 is listed.


🧰 Method 3: Check Directly via the Command

You can also test whether the command is recognized globally.

For PHP:

where php

For Python:

where python

If you get an output like:

C:\php\php.exe

or

C:\Python39\python.exe

✅ It means that program is already in your PATH.

If it says:

INFO: Could not find files for the given pattern(s).

❌ It means it’s not in PATH yet.


3) RUNNING a PHP/Python file via the Command Line Interface (CLI)

How to run a PHP file via the Command Line Interface (CLI) 👇

⚙️ 1. Make sure PHP is installed and in PATH

Test first:

php -v

✅ If you see version info (e.g. PHP 8.3.12), you’re ready.
❌ If not, check your installation or PATH variable (see previous steps).


📂 2. Navigate to your PHP file’s folder

Use cd (change directory). Example:

cd C:\projects\myapp

If your file is at C:\projects\myapp\test.php, you can also drag the folder into the terminal to auto-fill the path.


▶️ 3. Run the PHP script

Type:

php test.php

or use a full path:

php C:\projects\myapp\test.php

🧩 4. Optional: Make It Executable (with .bat wrapper)

If you want to run it like a normal .exe or command (without typing php each time):

  1. Create a new text file named run-php.bat

  2. Inside it, write:

    @echo off
    php "%~dp0yourfile.php" %*
    pause
    
  3. Save and double-click run-php.bat — it will execute your PHP file using PHP CLI.


💡 5. If the script outputs HTML (for web use)

You can preview it locally by running PHP’s built-in web server:

php -S localhost:8000

Then open http://localhost:8000 in your browser.

Comments

Popular posts from this blog

PART 0.1.0 RAD PROTOTYPE Web-App: Post-Video & Comments [program]

Video List — JP Kanji Ultra Translation CONTROL SECTION — Login (Admin) Username: Password: Login CONTROL SECTION — Admin Panel Enable Comments Disable Comments Logout Activity Log Show Video COMMENTS DISABLED BY ADMIN Leave a Comment: Additional Comment Show Video COMMENTS DISABLED BY ADMIN Leave a Comment: Additional Comment Show Video COMMENTS DISABLED BY ADMIN Leave a Comment: Additional Comment Show Video COMMENTS DISABLED BY ADMIN Leave a Comment: Additional Comment

My Pending and Delayed POSTs SUMMARY [APPs]
MADE by ChatGPT

🔗 My Pending and Delayed POSTs SUMMARY Sort by Date Sort by Auto Title Sort by My Title Ascending Descending (Newest First) Insert URL: Your Own Title (Optional): Status: Pending Done ➕ ADD ENTRY 💾 SAVE EDIT (MAIN FORM) DATE / TIME AUTO TITLE MY TITLE STATUS URL ACTIONS 📝 TO DO LIST SUMMARY Sort by Date Sort by Header Sort by Detail ...

Tablet Holder di Mobil dan Konsep DOUBLE Tablet Holder aka +secondary supporting holder

Gw udah pasang Holder khusus Tablet yg menurut gw sudah pilihan terbaik! Karena memiliki Arm KERAS/RIGID yg dibutuhkan utk menggenggam ERAT Dalam hal menopang Tablet yg lebih berat dr HP biasa Cekidot Lapak (click here!!) Namun .. Setelah gw pasang Bukan tidak bagus Tapi kalau melewati jalan jelek GOYANG (sikit) juga Gan! Akan tetapi .... Gw rasa bisa makin dimaksimalkan KERIGIDAN dengan menambah PENOPANG KEDUA Check it out: Dari searching2 di MarketPlace Gw ketemu yg mirip holder lampu belajar zaman doeloe Dan .. namun .. tiba2 gw menemukan Ide (lanjutan) Mekanisme yg bisa diReApplied kalau suatu saat diperlukan di Kreasi Agan2 lain  Gunakan Kombo 2 Perangkat berikut apabila membutuhkan holdingan tablet tambahan yg memiliki  "hold area"  yg lebih sempit karena holder kedua "takutnya/dirasa" tidak akan muat utk menggenggam Tablet sebagai penopang kedua, sebagai akibat holder pertama/utama sudah "cukup banyak" memakan tempat Perangkat Pertama (kon...