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

Accessing assets inside Modules

Using Phalcon\Assets\Manager() im able to add assets like JS, CSS file into volt file.

But Phalcon\Assets\Manager() will always looks inside "Public" folder for assets.

How can we access "assets" folder which is inside Module directory?

  • Project

  • ...........apps

  • ..................module_1

  • ................................controllers

  • ................................models

  • ................................views

  • ........................................assets // how to access this assets folder to get JS, CSS, Img files into Volt Template?

  • ...........public

  • ...................assets // currently all assets are accessed by this folder by default

I'm not entirely sure if it is possible. or if it is even a good idea to do, but project structure is personal preference so if you want to do that according to https://docs.phalcon.io/en/latest/reference/assets.html#local-remote-resources

Local resources are those who’re provided by the same application and they’re located in the document root of the application. URLs in local resources are generated by the ‘url’ service, usually Phalcon\Mvc\Url.

Reseting your static base uri to the root should allow you to do that, but will interfere with your other asset loading I imagine


$url->setStaticBaseUri('/');

I has a same problem like Sravis. Please help me ???

How do you access your assets from a module into the public/assets directory ? My project structure looks like this :

├── apps
│   ├── cms
│   ├── frontend
│   └── user
├── config
├── index.html
└── public
    └── assets
    └── index.php

But if I use the assets manager in the frontend module, indexController, Volt outputs

<link rel="stylesheet" type="text/css" href="bootstrap/dist/css/bootstrap.min.css" />

which of course does not work ... Do I have to put the whole domain as basUrl ? It will create problems on my team mates environnements, and on cloud9.