In your DI setup, you could set the URL properties like this:
$di->set('url', function() {
$url = new \Phalcon\Mvc\Url();
// my local dev machine has no virtual domains, just localhost/project-a. localhost/project-b etc
$url->setBaseUri('/fooProject/public_html/');
$url->setBasePath('/home/me/fooProject/');
return $url;
});
In controller or view (I don't know the volt style), use it like this:
// url
echo $this->url->get('bar/baz'); // /fooProject/public_html/bar/baz
echo $this->url->get('bar/baz', ['id'=>'2', 'apple' => 'pie'], true)); // /fooProject/public_html/bar/baz?id=2&apple=pie
// path
echo $this->url->path('path/to/my/files/hat.jpg'); // /home/me/fooProject/path/to/my/files/hat.jpg
If you don't want the BaseUri prefixed to your base uri, set the 3rd param of get()
to false. The path
methods are also in this page: https://docs.phalcon.io/en/latest/api/Phalcon_Mvc_Url.html