• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Module Assets

#1
Hi all! I ran into a new scenario today and I wanted to head out what everyone else thought. CI4 leverages namespaces to allow a lot of power from modules. As a module developer I can package migrations and models, can claim routes and add views, and can even provide services, config, and helpers - all of it automatically enabled by Composer installation or by adding the module to Config/Autoload.php. The one thing I can’t do is include any assets without the user relocating files. 
My current scenario is a module that uses a custom pic for display - but it could be a CSS code, or JavaScript or any number of things. Having a user copy the files in takes an otherwise plug-and-play module and adds configuration steps, and it also takes those assets out of the update stream (or requires the user to recopy them every update). 
Because files (ideally) are only sever out of public/ and the only guaranteed place the framework can modify the file system is writable/, I don’t see any way to work around this as things sit now. 

My question to YOU! Is this worth exploring some structure change to work around? How do you handle module assets currently? If you have experience with other frameworks, any idea how they do it?
Reply

#2
Currently I am using my own asset manager at ci3 to do the copiing from the module's dir (wiredesign hmvc) to my public assets folder then minify and compile them into one. If that is done then I create a .deployed file in the module's folder. I have a check in place at the modules admin to do the deployment automatic if neccessary. I think i will go stg similar solution with CI4...
Reply

#3
Ah very interesting - I hadn’t thought about a module that would handle this locally. Could you link me something? Also, does this run at CLI after deployment (and thus circumvent framework filesystem permission limitations)?
Reply

#4
No its my companys closed source thing, but the concepts similar with the old pyrocms 2 solution, our cms based on those concepts at large. Its not CLI based, when you open the module manager its automatically deploy the assets except the module is disabled or lacks assets. Its not that efficient and has other disadvantages but it proven good at the time when we developed years ago...

Recently I read a lot about about Laravel Mix and I very like it too, maybe I will create stg similar with an admin interface, I will see...
Reply

#5
Thanks @orionstar! This has given me some great ideas. I will be adding a CLI command to my assets module (https://packagist.org/packages/tatter/assets) that will handle publishing of assets from namespaced modules (and some supported Composer components as well). Maybe down the road a UI too.
I really appreciate the insight and that you took the time to explain it.
Reply

#6
Most people that use modules store that information into the database.

But you can also like above create your asset library to handle them.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#7
In my case (CI3 + HMVC), I use a special module directory structure + htaccess for protection this directories. This way can be update/install module with all assets and work on them as separate unit. Ofcourse in CI4 this variant can be problematic because it use public directory for all assets, but if change directories structure it can be worked.


Attached Files Thumbnail(s)
   
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.