-1

I'm just a starter in command line applications. I want to know how I can be able to pass environment variables to a php script running in the command line on windows 7 machine.

I want to do something similar to this:

QUEUE=notification VVERBOSE=1 php resque.php

Thank you for help..!

Sagar Naliyapara
  • 3,971
  • 5
  • 41
  • 61
phptrend
  • 1
  • 5
  • You can use php's `putenv()` – Daan Apr 03 '15 at 13:15
  • I thought putenv() could be possible inside the script itself, but in this case I want to pass them when invoking the script. The process for unix and osx users is described in this link:[link] (http://kamisama.me/2012/10/12/background-jobs-with-php-and-resque-part-4-managing-worker/), but when I try that in windows it tells me the environment command QUEUE is not recognized – phptrend Apr 03 '15 at 13:21
  • I some how think there is a way around this while using windows – phptrend Apr 03 '15 at 13:22
  • Please consult the documentation of your operating system or search a website that is deidcated to computer use like [Super User - how to set ENV variable in windows CMD line](http://superuser.com/questions/212150/how-to-set-env-variable-in-windows-cmd-line) – hakre Apr 03 '15 at 13:28
  • @hakre thanks! for the link. It helped me and finally got it working – phptrend Apr 03 '15 at 15:00

1 Answers1

0

I finally got this working.

On Unix systems you can set the environment variables on the same line invoking the script.

QUEUE=notification VVERBOSE=1 php resque.php

But for windows Os, you need to first set the environment variable like this

SET QUEUE=notification

SET VVERBOSE=1

Then you invoke the script

php resque.php

Thank you to all who contributed...!

phptrend
  • 1
  • 5