Welcome Guest, Not a member yet? Register   Sign In
(Modules) Extends Configs
#11

Personally, I don't see this as an improvement - it's more of a straight path to "mess".

It may be ideal for your project, but we need to think beyond that when introducing features into the framework.
Reply
#12

I think the issue stems from ozornick having concerns about future upgrades, multiple modules colliding/overwriting each other and sort of an "interface/attribute" based approach to configuration (my word choice may be poor there). I have faced similar concerns whenever I run composer upgrade on the root of a project.

To allay or mitigate those issues/concerns I've adopted a workflow for developing locally in a docker container where the dockerfile always instantiates the shiniest version of codeigniter and then builds the project up from zero using dockerfile commands. I haven't looked into it, but perhaps a combination of Registrars, Publishers, and running an entire site as a Code Module would be a comparable approach that achieves the desired results for ozornick's hypothetical starter app.

My halberd module uses the Code Module approach but instead of using Config files it makes use of the settings library (as that seemed a somewhat more "surgical way" of modifying an already existing configuration). It does however, create an issue wherein removing the module, leaves the register and login actions for shield overwritten. Therefore, your login/register pages would now be affected/broken and you would have to manually update these, but perhaps the onus is on me as its developer to create an "uninstall" command for it.

I can't say I am understanding what the proposed problems/approaches are in the PR, but I can understand the pain points of the current install/upgrade cycle. It does create some technical debt frustrations. Perhaps that's CodeIgniter's intent, to burden the developer more so you don't have the 'mess' that, for instance, Wordpress plugins create?
Reply
#13

IMO if we want to have a full feature module system using Registrars is not the way to go. We have to have the option to install, uninstall, enable, disable, and upgrade. Registrars will be applied whenever the module is available via autoload. Using the Settings library is a much better idea. Of course, we would have to build some solid skeleton around module management functionality, but this would be a better solution than relying on Registrars.

IMO the expectations of CodeIgniter in this area are a bit too high. If you need a solid module management system, you need to build it yourself or see if someone in the community has already done it.
Reply
#14

(This post was last modified: 02-10-2025, 01:49 AM by ozornick.)

Go next. 
My structure dirs: modules/Main modules/Users ... and in composer.json psr-4 as "Acme\\": "modules/ "
But FileLocator::getNamespaces() narrows down the FQCN search, only from Config/Autoload.php. In fact Acme\Main, this will be the correct NS for the psr-4. Can we fix this case or is there another way besides hard coded in the config?
 https://github.com/codeigniter4/CodeIgni...r.php#L241

For now, the solution is not to specify the parent folder, but to register each module separately "Acme\\Main\\": "modules/Main/"
Simple CI 4 project for beginners codeigniter-expenses ( topic )
Reply
#15

1. CodeIgniter expects explicit mappings for each namespace component. This is a design choice which is related to performance.

2. FileLocator::getNamespaces() will include all namespaces - also those that are declared in the composer.json file.

3. If you declare "Acme\\": "modules/ " in composer.json, then this is your component namespace. CodeIgniter does not interfere/modify Composer-generated namespaces.
Reply
#16

yes, I know that. It seems that writing each module in composer.json is the best option. This way the module can be moved to another place.

Regarding my first questions. The only working way is to develop a project (based on appstarter). Because after creating the modules I need to finish the project in app. In this case there are more options for customization.

Modules are not perfect at the moment. When the time comes for "bundles" CI will be early in the journey, possibly too late if you look at other frameworks  Undecided
Simple CI 4 project for beginners codeigniter-expenses ( topic )
Reply
#17

Is there a way that, if a user isn't modifying a particular Config file, that it could be removed from the user's app/Config folder, and instead have CodeIgniter use the copy of the config file in the app/Config folder inside the vendor folder?

Code modules appear to be using the configs in the parent project when the config files are missing, so I didn't know if it was possible to extend this concept further.
Reply
#18

I tried, but to no avail. You can try changing the config folder in composer.json or Autoload.php. But NS Config\ is hardcoded in vendor Autoload.php
Simple CI 4 project for beginners codeigniter-expenses ( topic )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB