Local module development - how to handle custom modules and autoload paths?

Hi,
I have client OXID project (EE 6.2) where are installed external modules (bought modules from external developers) and my custom modules which are taken from remote repositories. All modules handle composer installation strategy (metadata: 2.1)

Question 1:
How you keep you local development?
I mean…
let’s say you installed a new project with composer install command.
Composer will install OXID and your custom modules from remote repository.
In that case all .git folders are in vendor directory.

It’s a little bit confusing for me… because when I want to do some changes I need execute composer update each time to see the results?
or maybe I should do symlink from vendor/custommodule to source/custommodule?

Question 2:
Do I need to put all autoload paths in project composer.json file to my custom modules when I am working in local development?

Thanks for suggestions.

Q1: it depends mostly on the kind of changes, you want to make visible:

  1. if you added external dependency in module’s composer.json and need to install it now, you got to use composer.
  2. if you have changed metadata.php ite enough to install module configuration vendor/bin/oe-console oe:module:install-configuration <module path>

Q2: if your module’s directory and file names match their namespaces, e.g. Vendor\Module\Core\Class is located in source/modules/vendor/Module/Core/Class.php then it enough to add your vendor folder to the autoload path:

"autoload": {
  "psr-4": {
    "Vendor\\": "source/modules/vendor",
...

Thanks for reply :slight_smile: but probably you understand me wrong or I could describe my problem better :slight_smile:

Q1:

  • 1.1: but where you have stored your custom module? where you implement code? in which directory? {project}/source/modules/{vendor}/{mycustommodule} or maybe {project}/vendor/{vendor}/{mycustommodule}?
  • 1.2: do you execute git push in this directory?
  • 1.3: what you do when you execute composer update --no-scripts --no-plugins && composer update and OXID ask you if copy module from vendor to source dir?

Q2:

  • 2.1: this means for development purposes it’ is required to add manually namespaces in {project}/composer.json file, even if we have namespaces declared in composer.json file in path {project}/source/modules/{vendor}/{mycustommodule}. Yes?
  • 2.2: you add namespaces in “autoload”: {…} or “autoload-dev”: {…} in {project}/composer.json section?

Thanks for your patience :slight_smile:

ok, i think i understand the intention now.
Bascially. you have two ways of ading your modules to OXID:

  1. as composer dependency
  2. installing module-configuration manually

If your module does not have external dependencies, that needs to be installed via composer, then you can install module configuration manually and use composer only to create new classmap.

1.1 {project}/source/modules/{vendor}/{mycustommodule}
1.2 99% of my modules are project-related, so them will always be only in this one particular shop and there will be no updates outside of this shop. Those modules do not have own repositories, so they are part of the project repository for the whole shop. when i run gut push there, its pushed to the main project repositoy
1.3 i dont use this command, but you are probably adding source/modules/vedor/yourmodule as repository in composer.json, in this case you have to say “no” at this point, as mentioned here

2.1 no, if you are installing your modules as a composer dependency, you do not have to do that. Only if you install module configuration manually (without composer), then you have to add your namespace there and run “composer dump-autoload”
2.2 is answered in previous post

1 Like

OK, it’s clear for me :slight_smile: thanks.