Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the env variable for PHP?

Tags:

php

windows

wamp

I am using WAMP. I want to use php from the command prompt. What is the entry in PATH env variable for this ?

like image 656
Bruce Avatar asked Apr 29 '10 10:04

Bruce


People also ask

Can I use .env in PHP?

An . env file is a plain text file which contains environment variables definitions which are designed so your PHP application will parse them, bypassing the Apache, NGINX and PHP-FPM. The usage of . env files is popular in many PHP frameworks such as Laravel which has built-in support for parsing .

What is $_ env in PHP?

Introduction. $_ENV is another superglobal associative array in PHP. It stores environment variables available to current script. $HTTP_ENV_VARS also contains the same information, but is not a superglobal, and now been deprecated. Environment variables are imported into global namespace.


2 Answers

You need to add the PHP directory to your path. On the command line (e.g. in a batch file), it would look like this:

SET PATH=%PATH%;C:\your\wamp\path\php 

if in doubt, it's the directory containing the php.exe.

You can also pre-set the path in Windows' control panel. See here on how to do this in Windows 7 for example.

Be aware that if you call the PHP executable from an arbitrary directory, that directory will be the working directory. You may need to adjust your scripts so they use the proper directories for their file operations (if there are any).

like image 84
Pekka Avatar answered Oct 02 '22 11:10

Pekka


Follow this for Windows operating system with WAMP installed.

System > Advanced System Settings > Environment Variables Click new  Variable name  : path Variable value : c:\wamp\bin\php\php5.3.13\   Click ok 
like image 38
Mukesh Avatar answered Oct 02 '22 13:10

Mukesh