humugus
humugus

Reputation: 13

How to get full path URL in phalconphp

I'm new to phalcon and I need assistance because i cannot find a way to get full path url (and add it in an email message) such as : "http://phalcon.mydomain.com/auth/confirmRegistration"

the most i could get is "/auth/confirmRegistration"

using $this->url->getStatic('auth/confirmRegistration')

there might be a build in function but i could not discover it, or maybe i should put the 'http://phalcon.mydomain.com' part in a global variable ??

thank you in advance

Upvotes: 1

Views: 18497

Answers (2)

hanmari
hanmari

Reputation: 1474

Here's a simple way to get the url of the current page in Phalcon:

echo $this->router->getRewriteUri();

Upvotes: 9

Ian Bytchek
Ian Bytchek

Reputation: 9085

You could do two things. Per documentation you could set the full domain url:

<?php

$url = new Phalcon\Mvc\Url();

//Setting a relative base URI
$url->setBaseUri('/invo/');

//Setting a full domain as base URI
$url->setBaseUri('//my.domain.com/');

//Setting a full domain as base URI
$url->setBaseUri('http://my.domain.com/my-app/');

Or you could simply use HTTP_HOST / SERVER_NAME to get the host name and append the rest of it, e.g:

echo 'http://' . $_SERVER['SERVER_NAME'] . '/auth/confirmRegistration';

Upvotes: 2

Related Questions