Running PHP using Windows command line with XAMPP

If you have installed XAMPP, and want to use command line to run PHP on Windows, here is how you can do so.

1. Right click on the Computer icon on your Desktop and choose Properties option.
2. In the System window click on Advanced system settings in the left pane as highlighted below
3. In the System Properties window select Advanced tab and click on Environment Variables… button given at the bottom of the window as highlighted below
4. In the Environment Variables window you will notice two columns User variables for a Username and System variables.
5. Under System variables there is a Path variable, click edit
6. At the end of the line, add where you installed your xampp, for my case it is: ‘;C:\xampp\php’
7. Click OK.
Now you can start running Windows Command Line

Be Sociable, Share!

About Shi Chuan

I am a web developer.
This entry was posted in PHP and tagged . Bookmark the permalink.

7 Responses to Running PHP using Windows command line with XAMPP

  1. Hugo says:

    Hi ShiChuan,

    I really admire your background and experience, which could help me solve the problem I am facing:

    Having installed Xampp on my desktop running Windows 7 Ultimate SP1 ( c:\xampp ), I created mysql logged in with username and a password.
    As I am unable to use phpmyadmin to import a large dump file, I tried using the shell command by opening mysql.exe

    However, I am lost here since I am not familiar with any of the command strings especially running in Windows 7 OS as I understand it’s a bit different than running in linux/unix.
    I tried using the following without any success:

    1. mysql> -h localhost -u root -p password (the password to access mysql and phpmyadmin)
    –> use dbname
    –> source C:\xampp\tmp\dumpfile.sql
    Result: errors
    unknown command : ‘\x’
    outfile disabled
    outfile disabled

    2. mysql > dbname (even when I input – use dbname – same negative result)
    –> C:\\xampp\\tmp\\dumpfile.sql
    Result: errors
    unknown command: ‘\\’
    unknown command: ‘\\’
    unknown command: ‘\\’

    Please kindly assist and guide me to using the right command strings to successfully import the dump file into the database.
    Your kindness to help me solved the above, would be much appreciated.

    Thank you in advance and best wishes to you and your loved ones.


  2. Davdi says:

    Helpful tips . thanks

  3. Vipin says:

    Thanks for the tips.



  4. nollir says:

    thank youuuuuu :DD

  5. Hello there, just became aware of your blog through Google, and
    found that it is really informative. I am gonna watch out for brussels.
    I will appreciate if you continue this in future. Numerous
    people will be benefited from your writing. Cheers!

    My homepage: protandim abc

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>