Catch current directory on either PHAR runs

Asked

Viewed 23 times

0

Many PHP managers are available in PHAR files, which are installed globally via Composer or in operating system environment variables.

This is the case of Composer himself, and also of Phpunit.

In any directory I can run the command phpunit that it will collect the directory in which I ran and the phpunit.xml file.

The question is just this, on a phar or PHP executable how did I get the directory in which it ran? Because most of the time the directory is not the same as phar. The solution should work on all systems.

I searched but I couldn’t find anything like it. You can help?

  • Isn’t that right? http://php.net/manual/en/phar.running.php

  • 1

    I think the function getcwd does that.

  • @Andersoncarloswoss that’s right, post the answer so I can mark it right.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.