Solved

explain WHY a path is need for php

Posted on 2014-03-21
13
298 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
Industry Leaders: 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 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
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 …

729 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