Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Cannot getBaseUri() correctly.

My phalcon app is in folder /_test-php-framework/phalcon/ And i'm already set application->baseUri = /_test-php-framework/phalcon/

In config/services.php i have this code running

$di = new FactoryDefault();

/**
 * The URL component is used to generate all kind of urls in the application
 */
$di->set('url', function () use ($config) {
    $url = new UrlResolver();
    $url->setBaseUri($config->application->baseUri);

    return $url;
});

Everythingelse works find except when i call to getBaseUri().

$url = new Phalcon\Mvc\Url();
echo $url->getBaseUri()."<br>\n";

The result should be /_test-php-framework/phalcon/ but it becomes /public/

How to get its value correctly?

Hello I tried "url.getBaseUri()" and the output is "/_whateveryousay/" (in my case). * *It worked



3.8k
edited Mar '15

Hello I tried "url.getBaseUri()" and the output is "/_whateveryousay/" (in my case). * *It worked

Are you sure that is php code? url.getBaseUri()?



3.8k
Accepted
answer

I use it in controller (mvc). So, i changed to $this->uri->getBaseUri() and it work!

This works in the view's too.

I use it in controller (mvc). So, i changed to $this->uri->getBaseUri() and it work!