Results 1 to 8 of 8

Thread: Php cli

  1. #1

    Thread Starter
    Hyperactive Member xxarmoxx's Avatar
    Join Date
    Mar 2007
    Posts
    378

    Php cli

    I want to be able to run php scripts from the command line in Vista. Can someone please give me the setx code I need to get it to work?

    Thanks

    I tried: setx php "C:\the\path\to\php.exe"

    It didnt work.

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Php cli

    well, the "setx" command sets an environment variable, it doesn't run anything. I don't know why you'd be trying to use it to run a script.

    to run something with PHP, you just need to point the PHP executable to your script. this should run script.php:
    Code:
    E:\root\php5\php.exe E:\root\www\script.php
    you can read more about using PHP from the command line with arguments and options here on php.net
    Last edited by kows; Apr 1st, 2009 at 04:58 AM.

  3. #3

    Thread Starter
    Hyperactive Member xxarmoxx's Avatar
    Join Date
    Mar 2007
    Posts
    378

    Re: Php cli

    Thats wack, cant I have the php command work like the java command?

    Isn't that what a environment variable is for?

  4. #4
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Php cli

    huh? you don't need an environment variable to run java either. I think you're getting things very mixed up.

    environment variables are variables stored for the system. they aren't required for anything you're doing. variables provide shortcuts; they do not run programs.

    if you wanted a shorthand way to run php files (without needing to provide the full path of PHP), you could append the environment variable "path" with the path to PHP's installed directory. this will let you run "php.exe" without needing to be in PHP's native directory.
    Code:
    set path=%path%;E:\root\php5
    then, you could run this:
    Code:
    php E:\root\www\script.php
    if you'd like to permanently add that path to the "path" variable, then you'll need to change the environment variables. in windows explorer, type in the path, "Control Panel\System and Maintenance\System", then click on "Change Settings." you'll need to confirm with UAC if you have it on. go to the "Advanced" tab, then to "Environment Variables" at the bottom. under "System Variables," there will be one named "Path." you can simply append ";E:\root\php5" to it, not forgetting to add the semi-colon. and don't get rid of any of the information inside of that variable already.

  5. #5

    Thread Starter
    Hyperactive Member xxarmoxx's Avatar
    Join Date
    Mar 2007
    Posts
    378

    Re: Php cli

    Code:
    set path=%path%;E:\root\php5
    was exactly what I was looking for. Thanks guy.

  6. #6

    Thread Starter
    Hyperactive Member xxarmoxx's Avatar
    Join Date
    Mar 2007
    Posts
    378

    Re: Php cli

    Code:
    set path=%path%;E:\root\php5
    This works but when I reboot it no longer works. How do I make it stick?

  7. #7
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Php cli

    read the last paragraph of my last post in this thread.

  8. #8

    Thread Starter
    Hyperactive Member xxarmoxx's Avatar
    Join Date
    Mar 2007
    Posts
    378

    Re: Php cli

    woops, missed it. Got to excited about set path=%path%;E:\root\php5. It works, thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width