Solved

explain WHY a path is need for php

Posted on 2014-03-21
13
306 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

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 35

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
 

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

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

636 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