roundcube / roundcubemail

The Roundcube Webmail suite
https://roundcube.net
GNU General Public License v3.0
5.57k stars 1.6k forks source link

Allow composer autoloading (to coexist) #9407

Closed mvorisek closed 1 month ago

mvorisek commented 1 month ago

extracted from #9241

This PR is 100% BC and does not imply any functional change.

This PR allows composer autoloading to address the goals from #9241, but keeps the Roundcube autoloading intact.

Later, the transition to composer autoloading can be discussed in the original #9241 with minimal LoC needed.

mvorisek commented 1 month ago

PR is done and does not intact the current autoloading in any way. However, Roundcube/plugins can be newly easily used using composer as deps 🎉🎉🎉

alecpl commented 1 month ago

Looks good. I wonder whether we could do something that does not look like a hack regarding that change in rcmail_oauth. How about skipping rcmail_oauth instantiation in rcmail::startup() if PHP_SAPI == 'cli'?

mvorisek commented 1 month ago

Looks good. I wonder whether we could do something that does not look like a hack regarding that change in rcmail_oauth. How about skipping rcmail_oauth instantiation in rcmail::startup() if PHP_SAPI == 'cli'?

I do not support this. The reason is I belive it should be initialized for every environment (web & CLI).

Here we solve the first composer install/update only. The reason is composer classmap autoloader has not discovered the classes yet (when the roundcube plugin installer composer plugin is called). For consequent run, the class is autoloadable/present, thus disabling this for CLI in general is not needed and IMO not wanted.

alecpl commented 1 month ago

It would also break oauth tests. So, maybe the ExtensionInstaller should include iniset.php instead of clisetup.php. I.e. not initialize rcmail at all. I'm not sure whether this would just work or some more changes would be needed.

mvorisek commented 1 month ago

@alecpl now this PR is complete and fully BC. Please merge it and submit this repo to Packagist. I will then take care of the remaining changes.

alecpl commented 1 month ago

ps. roundcube/roundcubemail has been registered on Packagist.

mvorisek commented 1 month ago

Thank you very much ❤

I did a quick verification using:

{
    "repositories": [
        {
            "type": "path",
            "url": "vendor/roundcube/roundcubemail/plugins/acl"
        }
    ],
    "require": {
        "roundcube/roundcubemail": "dev-master",
        "roundcube/acl": "^1.9"
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "config": {
        "allow-plugins": {
            "roundcube/plugin-installer": true
        }
    }
}

and all works as expected incl. plugins 🎉🎉