how to get current url from codeception & phantomjs test?

If you don't have an AcceptanceHelper/FunctionalHelper class (and so $this->getModule or $this->client are undefined) then the following in your AcceptanceTester/FunctionalTester class should work:

public function getCurrentUrl() {
    return $this->executeJS("return location.href");
}

The solution was to add a helper method to AcceptanceHelper in _support/AcceptanceHelper.php file:

    class AcceptanceHelper extends \Codeception\Module
    {

        /**
         * Get current url from WebDriver
         * @return mixed
         * @throws \Codeception\Exception\ModuleException
         */
        public function getCurrentUrl()
        {
            return $this->getModule('WebDriver')->_getCurrentUri();
        }

    }

and then use it in test:

$url = $I->getCurrentUrl();