Sub domain

Hello ,

how can i create a subdomain for Phalcon so i could use it as an external lik for my images ? example :

images are stored in assets/public/posts/images/

and i want to be able to generate an external link like : and NOT access via normal url, example:

Hi hudson you can make a user component to do that

    class ExternalUrl extends \Phalcon\Mvc\User\Component {
        public function getUrl(string $image) : string 
            return '' . ltrim($image, '/');

Then you have to include this in your Di and use everywhere



How do you generate your image html tag.

If you're using phalcon tag component (like {{ image("", false) }} ) you can extend it to always use as a default prefix.

You can also check our website implementation here:

In the Utils class we have a function called getAsset ( This function will return a URL for an asset (CSS/JS) based on what you define in your configuration's staticUrl

If you are in development mode, staticUrl is /. In production mode you can replace it with and that will be prefixed to all of your assets.

Note that in the website implementation we are using the Phalcon Assets Manager to generate our asset links so if you want to use that, you will also need to define in the addCss and addJs functions whether the resource is local or not. This is what this fuction is about:

and the implementation (with assets manager) is here: