We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to generate fully qualified URL?

I want to create a HTML mail letter.

How I can write a fully qualified url into html? I need to print something like

<a href="https://my.domain.com/some/action/param1/param2/">https://my.domain.com/some/action/param1/param2/</a>

I have a route:

$router->add('/some/action/{param1}/{param2}', 'something::somewhat', ['GET', 'POST'])->setHostName($domain)->setName('some-action');

This method does not allow to print hostname and print a label with same URL:

{{ link_to(['for': 'some-action', 'param1': '123', 'param2': '456'], "my link") }}

And this method does not allow to 'compile' route with my parameters and does not allow to create link with custom url:

{% set some_route = routes['password-new'] %}
{% set some_url = domain ~ some_route.compilePattern(['param1': '123', 'param2': '456']) %}
{{ link_to(some_url, some_url) }}

Where "domain" is a "https://my.domain.com" and "routes" is an array of all routes.

Problem solved. A solution is

{% set some_url = domain ~ url(['for': 'some-action', 'param1': '123', 'param2': '456']) %}