How to run XAMPP’s PHP CLI and CakePHP console

XAMPP is one of the easiest options to develop using PHP or PHP CLI. I use CakePHP for development and one of the features of CakePHP is to back the MVC. In this guide, we’ll see how to get started. This tutorial doesn’t teach you how to use CakePHP’s bake feature. This guide is specifically written for Windows Vista or Windows 7.

0. Objective

To run XAMPP’s PHP CLI, you first have to set up the environment variables for PHP CLI. Also introduce how to get started on CakePHP’s console.

1. Setting up environment variables

Firstly, we would need to let the command prompt know where to find php.exe. In my computer set up, it is located in ‘C:xamppphp’. Yours might be in ‘C:xampp-litephp’ depending on where you install your XAMPP.

We need to edit some system environment variables:

Editing system environment variables in Windows Vista.

Click on ‘Edit the system environment variables’, a dialog box will pop up. Click on ‘Environment Variables…’, you should be greeted with the following dialog box:

Editing the path for environment variables

My path looks like this before I add anything:


Append your XAMPP PHP directory at the back of what is already there:


Open a new command prompt (don’t use existing one), and type “php” and see if there are any problems.

2. Avoiding MSVCR71.dll error

I encountered an error: “php.exe – System Error: The program can’t start because MSVCR71.dll is missing from your computer. Try reinstalling the program to fix this problem.”.

PHP MSVCR71 dll error
PHP MSVCR71 dll error

This error is caused by the “php_pgsql.dll” extension. We can proceed by disabling PostgreSQL if we don’t use it. If you do need it, you may consider installing Microsoft .NET Framework 1.1.

Open the file ‘php.ini’ in ‘C:xamppphp’ and search for “pgsql”. Disable the extension by placing a semicolon in the beginning of the line this way:

[code lang=”dos”];extension=php_pgsql.dll[/code]

3. Command Prompt’s “Start in” setting

You can have multiple shortcuts of command prompts in your desktop. I set my command prompt shortcut to start in ‘C:xampphtdocsdevapp’ which is my CakePHP application folder:

Command prompt properties start in setting
Command prompt properties start in setting

And when I run the command prompt, it will show:

[code lang=”dos”]Microsoft Windows [Version 6.1.7000]
Copyright (c) 2006 Microsoft Corporation. All rights reserved.


This is just more convenient without having to navigate through the folders again and again.


4. Running the CakePHP console

You should run the Cake console in your application folder this way:

[code lang=”dos”]C:xampphtdocsdevapp>”../cake/console/cake” bake[/code]

This runs the ‘cake’ program and tells it to bake.

For a list of CakePHP console commands to use, you can try:

[code lang=”dos”]C:xampphtdocsdevapp>”../cake/console/cake” help[/code]

That’s all

You can also put the CakePHP console path in your Windows environment variables. However note that if you have multiple projects with different versions, this method is less than ideal. Hope it helps.

15 thoughts on “How to run XAMPP’s PHP CLI and CakePHP console”

  1. Thank for info. Finally I found useful information.
    Can you explain some examples of commands? I entered the followings but I get error message.

    C:xampphtdocsblogapp>$ cake bake controller
    C:xampphtdocsblogapp>$ cake bake model
    C:xampphtdocsblogapp>$ cake bake view
    C:xampphtdocsblogapp>$ cake bake project


    It says ‘$’ is not recognized as an internal or external command, operable program or batch file.

  2. Hi shin, why do you have a dollar sign? I think you probably copy and paste the code from somewhere that uses a UNIX environment.

    You should instead run C:xampphtdocsdevapp>”../cake/console/cake” bake

  3. Excellent tutorial, really spot on! Saved me hours of searching. Many thanks

    Also just to add if your doing database backups/exports then you want to use:

    ../cake/console/cake” schema generate
    ../cake/console/cake” schema dump filename.sql

  4. open your C:xampphtdocscakephpcakeconsolecake.bat

    in your text editor
    then this line
    php -q “%lib%cake.php” -working “%CD%” %*


    “C:xamppphpphp.exe” -q “%lib%cake.php” -working “%CD%” %*

    if you installed xampp under c drive or choose correct patch towords php.exe file

    its working for me.

  5. Thanks a lot for all these info.
    I did the edit Environment Variable but with case recognizing cakephp
    but still not recognized in cmd ???

    any help… please
    thanks in Advance .

Leave a Reply

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