Solved

explain WHY a path is need for php

Posted on 2014-03-21
13
266 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
Comment Utility
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 74

Expert Comment

by:käµfm³d 👽
Comment Utility
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 74

Expert Comment

by:käµfm³d 👽
Comment Utility
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
Comment Utility
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 74

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 167 total points
Comment Utility
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
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:rgb192
Comment Utility
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
Comment Utility
In what folder? What command are you typing that is giving you unexpected results?
0
 

Author Comment

by:rgb192
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Yup
0
 

Author Closing Comment

by:rgb192
Comment Utility
now I understand path better

thanks
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
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…
The viewer will learn how to count occurrences of each item in an array.
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…

763 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

6 Experts available now in Live!

Get 1:1 Help Now