Solved

explain WHY a path is need for php

Posted on 2014-03-21
13
272 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 34

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
 

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 167 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 34

Assisted Solution

by:Dan Craciun
Dan Craciun earned 333 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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 34

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 34

Accepted Solution

by:
Dan Craciun earned 333 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 34

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This article discusses four methods for overlaying images in a container on a web page
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

911 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now