PHP has two modes of including files: based on relative paths, and based on absolute paths:
require 'foo/bar.php';
require '/var/www/foo/bar.php';
When using relative paths, the lookup is performed based on the PHP include path, which is basically a list of directories PHP will look up stuff in similar to the UNIX $PATH
environment variable. Iif you're using PEAR or other module installers which install PHP modules and files in some external directories, then it makes perfect sense to use that mechanism to locate and include external modules. You might even use that mechanism for files inside your own app. It gives you more leeway when deploying apps on a server in deciding on the exact file placement.
However, in practice this somehow turned out to be rather annoying and you'll run into all sorts of issues when trying to use that system. Not least of all because PEAR and PECL didn't turn out to be particularly popular, and composer is the de-facto mechanism to manage dependencies in PHP these days. So the include-by-relative-path mechanism is all but dead and you should be using absolute paths, for which __DIR__
is kind of a must really.