3

How to autoload "non drupal" classes like Carbon when required via the modules own composer.json without altering drupals core composer.json (like using the composer-merge-plugin)? Where do I have to include composers autoload.php to use the third party libraries within MyModuleController?

My module structure (simplified)

src/
  MyModuleController.php
vendor/
  autoload.php
  ...
composer.json
composer.lock
my_module.info.yml
my_module.module

1 Answer 1

3

You will have to include the path to the custom module in the repositories section of the composer.json in your root

"repositories": [
    {
        "type": "composer",
        "url": "https://packages.drupal.org/8"
    },
    {
        "type": "path",
        "url": "docroot/modules/custom/example"
    }
]

https://www.drupal.org/docs/develop/using-composer/managing-dependencies-for-a-custom-project

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.