Skip to content

Commit

Permalink
fix: Dependency hell documentation
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chemineau <louis@chmn.me>
  • Loading branch information
artonge authored and backportbot[bot] committed Sep 14, 2024
1 parent e7e4665 commit d5372c1
Showing 1 changed file with 79 additions and 1 deletion.
80 changes: 79 additions & 1 deletion developer_manual/app_development/dependency_management.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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
<projectFiles>
<directory name="lib" />
<ignoreFiles>
<directory name="vendor" />
<directory name="vendor-bin" />
</ignoreFiles>
</projectFiles>
<extraFiles>
<directory name="vendor" />
<directory name="vendor-bin/psalm/vendor" />
</extraFiles>
- 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
****************

Expand Down

0 comments on commit d5372c1

Please sign in to comment.