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

Setting absolute path in Phalcon\Assets\Resource:: setTargetUri()

In order to use a different server to deliver static files

When setting: $this->assets->setTargetUri('https://static.otherserver.com/js/final.js')

This results in

<script src="/https://static.otherserver.com/js/final.js" type="text/javascript"></script>

with a slash at the beginning. Am I right, when saying there's no possibilty to change this? :)

edited Jul '14

Hi metin. I think now you can use /static.domain.com/js.final.js for hack it and please create a bug report on github for it.

: $this->assets->setTargetUri('/static.otherserver.com/js/final.js')


404

Why not use addJs method?

$this->assets->addJs('https://static.otherserver.com/js/final.js', false);

@andrey i think he use compress js code to 1 file and put it to static subdomain. My opinion u misunderstood what he wants to do.

https://docs.phalcon.io/en/latest/reference/url.html#static-vs-dynamic-uris

$url->setStaticBaseUri('https://static.otherserver.com/');
...
$this->assets->setTargetUri('/js/final.js')
edited Jul '14

@boston hm bad idea when I use it in layout I rewrite base uri. on my project I use 2 subdomains it's bug because if you try to \Phalcon\Tag::linkTo(array(''https://static.otherserver.com/test'')) you see that url is /https://static.otherserver.com/ global bug with urls and subdomains