From c846bea1ff55473f82db08662e8dbc6d57e93df5 Mon Sep 17 00:00:00 2001 From: Louis Chemineau Date: Sat, 14 Sep 2024 20:29:46 +0200 Subject: [PATCH] fix: Dependency hell documentation Signed-off-by: Louis Chemineau --- .../app_development/dependency_management.rst | 80 ++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) diff --git a/developer_manual/app_development/dependency_management.rst b/developer_manual/app_development/dependency_management.rst index e3df8d800d8..c243f0a5fd0 100644 --- a/developer_manual/app_development/dependency_management.rst +++ b/developer_manual/app_development/dependency_management.rst @@ -4,7 +4,7 @@ Dependency management ===================== -It's possible to build a Nextcloud app with existing software packages. +You can leverage existing software packages to build a Nextcloud app. .. _app-composer: @@ -34,6 +34,84 @@ Dependency hell Be careful with which packages you add to an app. PHP can not load two version of the same class twice, hence there can be conflicts between Nextcloud Server and an app or between two or more apps if they require the same package. So try to keep the number of production dependencies to a minimum and see :ref:`app-composer-bin-tools`. +Alternatively you can use [composer-bin-plugin](https://github.com/bamarni/composer-bin-plugin) to avoid dependency conflicts between apps. + +1. Install composer-bin-plugin according to their docs. + + .. code-block:: shell + + composer require --dev bamarni/composer-bin-plugin + +2. Install the tools you need in the vendor-bin directory. + + .. code-block:: shell + + composer bin psalm require --dev psalm/phar + composer bin psalm require --dev nextcloud/ocp:dev-master + +3. Adjust some config (see below) + - Add in `composer.json`: + + .. code-block:: json + :caption: composer.json + + { + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": true + } + } + } + + - Add in `composer.json`: + + .. code-block:: json + :caption: composer.json + + { + "scripts": { + "post-install-cmd": [ + "[ $COMPOSER_DEV_MODE -eq 0 ] || composer bin all install --ansi" + ], + "post-update-cmd": [ + "[ $COMPOSER_DEV_MODE -eq 0 ] || composer bin all update --ansi" + ] + } + } + + - Adjust `psalm.xml`: + - Ensure the schemaLocation is correct: + + .. code-block:: xml + :caption: psalm.xml + + xsi:schemaLocation="https://getpsalm.org/schema/config vendor-bin/psalm/vendor/vimeo/psalm/config.xsd" + + - Ensure it has something like this: + + .. code-block:: xml + :caption: psalm.xml + + + + + + + + + + + + + + - Adjust `.php-cs-fixer.dist.php` + + .. code-block:: PHP + :caption: .php-cs-fixer.dist.php + + require_once __DIR__ . '/vendor-bin/cs-fixer/vendor/autoload.php'; + Conflict example ****************