0

I have one main Application module and several dependent modules. All modules have their own repositories on github and installed via composer (using satis local repository). During development process I need to make changes either in main module or dependent ones. But dependent modules are located in /vendor directory, and it's bad idea to make changes and git init there. So, I need a local copy of each module in /devmodules folder and add this folder to application.config:

'module_listener_options' => array(
 // ...
  'module_paths' => array(
      './module',
      './vendor',
      './devmodules'
  ),

How to tell ZF don't use /vendor for such modules? Change autoloader / use make tool or hook script in composer to make new copy and clean /vendor? What is the best practice to solve the problem?

P.S. Dependent modules are my own modules I develop in parallel with Application. So I want to see changes immediately, not after commit/push/update.

4orever
  • 105
  • 6
  • Precise what kind of changes You want to make in that modules. Consider extending classes from modules to correct them. Take advantages from inheritance. It's very bad idea to correct libraries, you wont be able to update them later. – Marcin Twardowski Dec 04 '14 at 21:15
  • No, they are my modules too. I describe development process. – 4orever Dec 04 '14 at 21:19
  • Oh, correct me if i'm wrong: You want this changes only during development? – Marcin Twardowski Dec 04 '14 at 21:21
  • I make changes, test and then commit dependent modules. So I need to see changes immediatly for test before commit and push. – 4orever Dec 04 '14 at 21:23
  • Maybe I can use composer's "autoload-dev" section to override required namespaces? And make another package 'development-mode' that will prodvide hooks with copying needed dirs to ./devmodules – 4orever Dec 04 '14 at 21:28
  • I think You can use config.local.php to configure different module_paths for development purposes. – Marcin Twardowski Dec 05 '14 at 10:13

2 Answers2

0

I have had this problem with "SpeckCommerce" where you posted this question as an issue. With SpeckCommerce we had to remove the module from composer.json because the composer autoloader was overriding the devmodules version.

The way to make this work is to remove the module from composer.json, develop in the devmodules folder, commit it back then re-introduce the composer loaded version.

This causes other problems however with dependants. If you remove a module that is a dependency for another module it will cause you dependency resolution problems in composer install/updates.

I think the easier way of working is to tell composer to --prefer-source when you install/update which will then give you a version controlled repository which you can add a remote, switch to that and then push to your own repository before creating PR's and merging etc.

It's a bit of a pain working on libraries in the vendor directory but from my experience that has proven to be the most effective way of working.

0

For me I get the next solution:

1) Add somethink like that to "script"-section in composer.json:

"devmodules": [
    "mkdir devmodules",
    "git clone git://github.com/4orever/ppc-auth/           devmodules/ppc-auth",
    "git clone git://github.com/4orever/ppc-backend/        devmodules/ppc-backend",
    "git clone git://github.com/4orever/ppc-backend-client/ devmodules/ppc-backend-client",
    "git clone git://github.com/4orever/ppc-dev-mode/       devmodules/ppc-dev-mode",
    "git clone git://github.com/4orever/ppc-main-assets/    devmodules/ppc-main-assets",
    "rm -rf vendor/4orever"
]

2) And add "autoload-dev":

 "autoload-dev": {
     "psr-4": {
        "PpcMainAssets\\":  "devmodules/ppc-main-assets/",
        "PpcBackend\\":     "devmodules/ppc-backend/src",
        "PpcAuth\\":     "devmodules/ppc-auth/src"
    },
    "classmap":[
        "devmodules/ppc-backend/Module.php",
        "devmodules/ppc-backend-client/Module.php",
        "devmodules/ppc-auth/Module.php"
    ]
 }

3) For production just use: composer install --no-dev. I haven't test it, but I suppose that 'autoload-dev' must be ignored. If not run composer dumpautoload --no-dev

4) For development: composer install and composer devmodules

I don't like to use standard ./vendor folder made by composer because it's not connected to git by default. I prefer git clone in the folder I need.

I hope it would be usefull.

4orever
  • 105
  • 6