Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

explain WHY a path is need for php

Posted on 2014-03-21
13
Medium Priority
?
320 Views
Last Modified: 2014-03-30
This is my path
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\system32\wbem;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\EgisTec\MyWinLocker 3\x86;C:\Program Files (x86)\EgisTec\MyWinLocker 3\x64;C:\Program Files (x86)\Windows Live\Shared;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn;c:\Program Files\Microsoft SQL Server\100\Tools\Binn;c:\Program Files\Microsoft SQL Server\100\DTS\Binn;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE;c:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn;C:\Program Files (x86)\WinSCP;C:\svn\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files (x86)\Smart Projects\IsoBuster;C:\Program Files (x86)\QuickTime\QTSystem;C:\Program Files (x86)\Bitvise Tunnelier;C:\Program Files (x86)\Common Files\SYSTEM\MSMAPI\1033;C:\Program Files (x86)\WinSCP\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\Program Files (x86)\NuSphere\PhpED\php54;C:\Users\Acer\AppData\Roaming\PEAR;C:\Users\Acer\AppData\Roaming\PEAR\pear\PHPUnit;

Open in new window


what happens to php when folders are added to windows environment path


I am told to add folder to path but I do not understand WHY

I am just told to avoid errors.
And when these folders are added, no errors.

Please explain why?
0
Comment
Question by:rgb192
  • 5
  • 5
  • 3
13 Comments
 
LVL 35

Expert Comment

by:Dan Craciun
ID: 39946549
That's because of the way Windows searches for commands.
When you type, in command prompt, php, for ex, Windows will look in the current folder, in the Windows folder and, additionally, in the folders specified in PATH. If it's not found in any of these folders, it will complain that it can't find the file.

So, basically, you add a folder to PATH so you can run programs that are inside that folder from anywhere on the system, without specifying the full path.

HTH,
Dan
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39946551
The PATH environment variable holds a semi-colon-delimited list of locations for the shell to look in if it does not find the currently requested command/executable in the current directory. Adding something to the PATH is usually for convenience, though sometimes applications will check the PATH variable themselves, in which case you may need to manually add some location to PATH. It seems as though you have a PHP-related application that checks the PATH variable, hence your needing to add it.
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39946556
To add to my previous comment, reasons for why an application might want to check the PATH would be that perhaps some commonly-used application is installed to a well-known location within the file system, but some users might choose to override this an install the application to a different location. If the searching app were to try and run the commonly-used application by pointing at the well-known location, then it would error because it could not find the commonly-used application at that path. Inspecting the PATH variable gives the searching application a list of potential locations for where the commonly-used application might reside.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:rgb192
ID: 39947990
So when I type
php -v
pear -v
phpunit -v

windows would search all my path directories for
php.exe
pear.exe
phpunit.exe

but only php.exe exists
how does windows know the name of pear, phpunit
0
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 668 total points
ID: 39949063
If you don't prefix the command with the full path, then Windows will search the current directory first, then look in the places specified by the PATH variable.

As to pear.exe and phpunit.exe, I am not familiar with those utilities, so maybe they each do something special. I'll have to defer on those.
0
 
LVL 35

Assisted Solution

by:Dan Craciun
Dan Craciun earned 1332 total points
ID: 39949065
There are other file types that are executed, not only exe files.
The most popular on Windows are .bat files.

AFAIK, when you call phpunit you're calling phpunit.bat . Same for pear.bat
0
 

Author Comment

by:rgb192
ID: 39949093
ok phpunit.bat, pear.bat
bat and exe files


for example path is one folder with many .exe and .bat
how does php know which file to run in that folder
0
 
LVL 35

Expert Comment

by:Dan Craciun
ID: 39949095
In what folder? What command are you typing that is giving you unexpected results?
0
 

Author Comment

by:rgb192
ID: 39949365
now my path is correct,
but I was having many questions about path

and even though path is correct: I still wonder how file is being chosen
0
 
LVL 35

Accepted Solution

by:
Dan Craciun earned 1332 total points
ID: 39949503
Depends on where you launch your command from. As already pointed out, the order in which windows will look for your command/file is:
- current folder
- path folders
- windows folder

The moment it founds a match, it runs it, ignoring other similarly named files in other folders.
0
 

Author Comment

by:rgb192
ID: 39953916
so if launched in current folder, windows will look for all the .exe / .bat files

 current folder

next will try all the folders in path

next will try c:/windows/
0
 
LVL 35

Expert Comment

by:Dan Craciun
ID: 39953985
Yup
0
 

Author Closing Comment

by:rgb192
ID: 39964925
now I understand path better

thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question