How do i run a php file in windows?

  • Home
  • Products
  • AlwaysUp
  • Applications
  • PHP Script

How do i run a php file in windows?

Start your PHP script in the background when your PC boots. Keep it running 24/7 or schedule it to restart several times a day

PHP is a popular programming language. It is often integrated with web servers but works just as well when creating standalone applications.

Note: This video shows how to add a PHP Windows Service the traditional way, before we developed the easy-to-use Application Advisor. The steps below show how to add PHP with the Application Advisor.

To set up a PHP script to run as a background windows service with AlwaysUp:

  1. Download and install the PHP package, if necessary.

    We have installed PHP in C:\PHP and we'll reference that location throughout this tutorial.

  2. Next, please ensure that your PHP script can run normally from the command line.

    1. Start a command prompt (Start button > Run > cmd.exe)

    2. In the window that appears, type the full path to the PHP executable (php.exe) followed by the full path to the script you wish to run as a windows service. Be sure to quote each component containing at least one space!

      Since we have placed PHP in C:\PHP, and our script is C:\PHP\sample-php-script.php, our command line is:

      C:\PHP\php.exe C:\PHP\sample-php-script.php
    3. Hit the Enter key to execute the command line. If your script doesn't work as expected please resolve the issues now.

      Note that if your script doesn't work here then it won't work with AlwaysUp!

      Here is the code of our simple script:

      How do i run a php file in windows?

      And here is the result from running it on the command line:

      How do i run a php file in windows?

      Everything looks good!

  3. Next, start AlwaysUp.

  4. Select Application > Advisor to launch the Application Advisor:

    How do i run a php file in windows?

  5. Click Next to get started:

    How do i run a php file in windows?

  6. Choose PHP from the list of applications and click Next:

    How do i run a php file in windows?

  7. The Advisor will spend a few seconds gathering information about your PHP installation.

    Afterwards, enter the full path to your PHP executable (php.exe) and click Next to move on:

    How do i run a php file in windows?

  8. Enter the full path to the PHP script you would like to run and click Next to continue:

    How do i run a php file in windows?

  9. For best results, PHP should run in an account where have run it successfully. Enter the user name and password of your Windows account and click Next to continue:

    How do i run a php file in windows?

  10. We're almost done! Click Next to continue:

    How do i run a php file in windows?

  11. The Add Application window contains all the recommended settings for running your PHP script 24x7 after your PC boots. If you are curious, you can cycle through the tabs and review the options that have been chosen.

    Click Save to record your new PHP service:

    How do i run a php file in windows?

  12. This next window provides guidance if you want your script to run periodically (that is, not 24x7). If that is the case, this article may be helpful too.

    Click Done when you are ready to move on.

    How do i run a php file in windows?

  13. A new entry for your PHP script will appear in the AlwaysUp window. However, the state will be "Stopped" because the service and your script are not yet running:

    How do i run a php file in windows?

  14. To start the service, which will kick off the PHP script, choose Application > Start "PHP:...". In a few seconds, the state will transition to "Running":

    How do i run a php file in windows?

  15. That's it! Next time your computer boots, your PHP script/service will be launched immediately, before anyone logs on.

    We encourage you to edit the entry in AlwaysUp and check out the full complement of settings that may be appropriate for your environment. For example, you can boost the priority of the PHP process, monitor the executable for excessive CPU usage, configure a weekly report, and much more.



PHP script not working properly as a Windows Service?

  • Visit the AlwaysUp Troubleshooter — our online tool that can help you resolve the most common problems encountered when running an application as a windows service.

  • From AlwaysUp, select Application > Report Activity > Today... to bring up a HTML report detailing the interaction between AlwaysUp and PHP. The AlwaysUp Event Log Messages page explains the more obscure messages.

  • Consult the AlwaysUp FAQ for answers to commonly asked questions and troubleshooting tips.

  • Contact us and we will be happy to help!

Fully Compatible with 140+ Applications...

How do I run PHP on my PC?

PHP on Windows PHP does not come pre-installed on Windows systems. To work with PHP on Windows, PHP will need to be manually downloaded and installed. You can download PHP from the PHP download page at http://www.php.net/downloads.php. Download the zip package from the "Windows Binaries" section.

How do I run a PHP file in Windows 10?

How to Run a PHP Application on Windows 10 Using XAMPP.
Install XAMPP. XAMPP is the most popular PHP development environment. ... .
Create a database(only if our PHP app needs a DB) ... .
Paste/clone the PHP app to “htdocs” directory. ... .
Running our PHP file or project..

How do I open a PHP file in Windows?

Next, please ensure that your PHP script can run normally from the command line..
Start a command prompt (Start button > Run > cmd.exe).
In the window that appears, type the full path to the PHP executable (php.exe) followed by the full path to the script you wish to run as a windows service..

How do I run a PHP file locally?

To run PHP for the web, you need to install a Web Server like Apache and you also need a database server like MySQL. There are various web servers for running PHP programs like WAMP & XAMPP. WAMP server is supported in windows and XAMP is supported in both Windows and Linux.