Dynamic extensions: src and/vs web assets

I’m trying to build a dynamic extension/module concept on top of Slim and while I’ve got a basic prototype working, I’ve run into something I don’t quite know how to resolve. My directory structure looks like this:

config
extensions
src
templates
vendor
web

src contains my application source code, extensions contains the source code for dynamically loaded extensions and web contains the index.php along with CSS and JS assets.

My problem is this: I can drop an extension under /extensions and then load & run the source code contained in that extension. However, an extension might also contain JS and CSS assets and those should go under /web. In principle this is fine but this means that I can’t just drop an extension under /extensions and have it work. Some files would have to be copied to reside under /web.

Does anybody have any ideas on how to resolve this issue in a non-hacky way?

Thanks for any ideas.

It’s something Puli is trying to sovle.

I have never really used it thought and it may be a bit over complicated.

1 Like

Thank you, I’ll check it out.

I took a look at Puli and while nice, it seems a bit overkill for my needs. I can do with a symlink and be done with it.

Hi TheLobos!

I will also deal with this.
in my opinion for the web use the cache.
in the source (src, vendor) to use uncompressed css, javascript
and to use for web compress them and put to cache folder is accessible from the Web.
like web/cache or web/assets/cache

IMHO directory structure does not matter. I chose the Symfony directory structure.

I plan install modules via composer and put one module file for init like app/Modules/ModName/init.php.
init depending on route

$app->group(’/forum’, function () {
// root module route
$this->get(’’, ‘\RunBB\Controllers\Index:index’)->setName(‘forum’);
// register all this module routes
(new \Src\Core\Routes($this, ‘forum’))->addRoutes();
});//->add(‘Src\Middlewares\RouteMiddleware’);

Yeah, I think that’s the route I’m going to down as well.

During extension installation/activation, I’ll just symlink the web assets from the extension to a directory under the /web folder. This is easy and painless and should just work fine. At this point I don’t even care if they’re compressed or not since the client will cache them anyways.