Phalcon PhP - how to use named routes inside a controller


I'm having trouble finding how to get the Urls from named routes inside a Phalcon PhP controller. This is my route:

        'controller' => 'AdminApplication',
        'action' => 'detail' 

I want to get just the Url, example: . With the code below I can get the html to create a link, the same result of the link_to.

$url = $this->tag->linkTo(
            'for' => 'application-details',
            'formUrl' => $form->url,
            'id' => $id

The result I want is just the Url. I'm inside a controller action. I know it must be really simple, I just can't find an example. Can you help me?

Thanks for any help!




You should use the URL helper. Example:

$url = $this->url->get(
        'for' => 'application-details', 
        'formUrl' => $form->url,
        'id' => $id,
        'q' => 'test1',
        'qq' => 'test2',

You can pass second array for query string params if needed.

According to your route definition, the above should output something like:


More info of Generating URIs in the docs.

People are also looking for solutions to the problem: php - if condition in html editable table


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.