How do I avoid having multiple copies of the Carbon Fields package if I want to use it in multiple plugins?

[ad_1]

I am quite new to Composer. But I see the point in it.

So, for my plugins I do:

composer require htmlburger/carbon-fields

The problem is… since I am including the “Carbon Fields” package into multiple plugins… composer isn’t doing what it’s best at, which is: handle dependencies to only load it once.

So… how should I structure a WordPress project, to depend on Carbon Fields, but only include it once?

Thanks.

[ad_2]
1 Comment
  1. You don’t. Each plugin should have everything it needs on it’s own, because they’re technically separate projects.

    When you run your “composer require” command, it downloads everything into the vendor directory and links it to your project, so everything is included if you want to distribute the plugin.

    Yes that means that you may have multiple copies of the same files, just in different plugin directories, but that’s not something to worry about.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer