[Solved] Incorrect BaseUrl

I am having an issue with dynamically determining the basepath within phalcon. I can do it through php but I want to know if there is something I am not understanding or missing.

my environment:

I am using userdir in apache document root is /home/rwilbert/workspace
phalcon project code is at /home/rwilbert/phalcon/public

the url for the site is http://localhost/~rwilbert/phalcon/public

the issue I have is that url->get('login') resolves to /public/login. I believe this is because $url->getBaseUrl() == '/publc'. I can call $url->setBaseUrl () to correct this but that is for every instantiation of the URL object + it would also have to be added to volt templates. Because the css paths are also incorrect.

So before I start writing volt functions, is there something I am missing?


baseUri is set in app/config/config.php.

You can solve this problem with this code in you services.php:

$di->set('url', function() {
    $url = new \Phalcon\Mvc\Url();

    return $url;
}, true);


Thank you. I missed that in the routing documentation


How to configure routing if my project is in foldername like: http://localhost/projectname/index.php

folder phalcon :

/.htaccess => rewrite ke /public/index.php /public/index.php

/projectname/ =>

./controllers ./models ./views

I use this setBaseUrl but route still goes wrong