Using PF CLI with Git Shell on Windows 7
by Tim Santeford (@tsantef), PHP Fog developer
This guide is designed for users who use Github’s Git Shell on Windows. Although there are easier ways to use the PF CLI on Windows, such as using Git for Windows, we wanted to provide instructions for our Git Shell users.
Here are some things to note when using this guide:
Git Shell uses Powershell and may ask you to install .NET Framework 4.0 during the installation process. Only instructions for using Wamp are given below, but other Windows installations of PHP would work but are out of the scope of this guide. Additionally, some of the paths in this document may need to be modified to match the paths on your system. If things are not working the first time be sure to double check that the paths are correct.
PF CLI Documentation
PF CLI Github Repo
Command Line PHP on Microsoft Windows
Step 1 – Downloads
- Download and install Github for Windows at: http://windows.github.com/
- Download and install WampServer 2 32 or 64 bit: http://www.wampserver.com/en/#download
- Take note of where Wamp’s php.exe was installed. The default location should be
c:\wamp\bin\php\php5.3.13. You will need to know this location for several steps below.
Step 2 – Turn on CURL for PHP
- Edit the php.ini located at
c:\wamp\bin\php\php5.3.13\php.ini and remove the semi-colon from the beginning of the extension line “;extension=php_curl.dll” and save. Note: Using the Wamp tray tool to enable php_curl does not work for the purposes of running PF CLI.
- From the Wamp tray icon “Start All Services”
Step 3 – Environment Variables
Open the control panel and search for environment variables. Click on the link with the shield icon labeled “Edit the system environment variables.” In the System Properties dialog click “environment variables.”
- Under system variables add the following to the end of the Path var list (include the semicolon):
- Add the following PF CLI bin path to the end of Path var. Note that the path needs to have your windows user name. The path does not exist yet but will be made later on in this guide:
- Add the following to the end of the PATHEXT var:
Step 4 – Associate PHP files
In order for the
pf command to work PHP CLI must be configured to execute php scripts without the .php extension. You must run the below commands with CMD.exe as the Admin in order for this to work. From the Start Menu search for cmd and when the cmd apears listed above, right click and select “Run as administrator.” Run the following commands:
- (Edit the path to match your wamp’s php folder)
ftype phpfile="C:\wamp\bin\php\php5.3.13\php.exe" -f "%1" -- %~2
Step 5 – Registry
Create a registry file with the text below and run it from the desktop. You may need to show extensions for known file types in order to correct name the registry file. Edit the paths in the file to reflect the actual path to Wamp’s php.exe file:
Windows Registry Editor Version 5.00
@="\"C:\\wamp\\bin\\php\\php5.3.13\\php.exe\" -f \"%1\" -- %~2"
Step 6 – Download and install PF CLI
Open up a new Git Shell and run the following command:
curl -s https://raw.github.com/phpfog/pf/master/bin/installer | php
Sometimes you will get PHP Parse errors. Just keep re-running the command until it completes successfully.
If you get a warning dialog popup with the message “PHP Startup: Unable to load dynamic library” regarding the
php_curl.dll then you will need to download a newer version of the DLL. Newer DLLs can be found linked in this post.
Replace the php_curl.dll found at
C:\wamp\bin\php\php5.3.13\ext with the one in the download. Retry the curl command above until the installation runs.
Step 7 – Rename the pf executable
Find the “pf” file located at C:\Users\<username>\PHPFog\pf\bin\pf and rename it to
Step 8 – Restart
In order for all the changes to take effect you must restart and start up the wamp server. Once restarted make sure that the wamp server try icon indicates that the services are up and running.
Now open a new Git Shell console and you should be able to run the “pf” command even without the .php extension.