# How to add a package dependency to a shopware 6 plugin?

**URL:** <https://forum.shopware.com/t/how-to-add-a-package-dependency-to-a-shopware-6-plugin/86326>\
**Category:** Programming (EN)\
**Tags:** programming\
**Created:** [19. März 2021 um 15:05 UTC](https://forum.shopware.com/t/how-to-add-a-package-dependency-to-a-shopware-6-plugin/86326 "2021-03-19T15:05:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![murthoprovides](https://avatars.discourse-cdn.com/v4/letter/m/c77e96/32.png) [@murthoprovides](https://forum.shopware.com/u/murthoprovides)\
**Post date:** [19. März 2021 um 15:05 UTC](https://forum.shopware.com/t/how-to-add-a-package-dependency-to-a-shopware-6-plugin/86326/1 "2021-03-19T15:05:40Z")

</div>

How do I add a package to my shopware 6 plugin?  
I want to create an extension to the current behaviour of uploading media files. That’s why I want to install this composer package in my plugin: [GitHub - runelaenen/sw6-media-optimizer: Image Optimizer for Shopware 6 💙](https://github.com/runelaenen/sw6-media-optimizer)

I can do this by running `composer require runelaenen/sw6-media-optimizer` off course. but this will just install the package in the vendor dir in my plugin. during development I don’t have any access to package classes etc.

Also, when this dependency is listed in the requirements of the composer.json file, it is not possible to install my plugin. As the requirements for this package are not met.

I also tried running composer update in the root directory of my shopware 6 installation. to no effect, the dependency is not installed, or listed during the composer update.

How does this work? how do I get a dependency into shopware that is just a regular github package?

---

<div class="post-metadata">

**Author:** ![palading](https://avatars.discourse-cdn.com/v4/letter/p/65b543/32.png) [@palading](https://forum.shopware.com/u/palading)\
**Post date:** [10. August 2023 um 05:43 UTC](https://forum.shopware.com/t/how-to-add-a-package-dependency-to-a-shopware-6-plugin/86326/2 "2023-08-10T05:43:20Z")

</div>

IF you don’t have any „require“ package in your composer.json file, you can run `composer require runelaenen/sw6-media-optimizer` directly where your composer.json file is.  
.  
IF you have some dependencies into „require“ key in composer.json:  
You need to run `composer require runelaenen/sw6-media-optimizer` anywhere you want in a folder OUTSIDE your plugin (choose „n“ on prompt).  
After that, you’ll see a „vendor“ folder created.  
Copy the „vendor“ to your CompanyModule plugin folder.  
Enjoy!  
.  
Only in this mode your dependency will be accesible when you’ll install the plugin.  
.  
I think that another option can be a shell „exec“ from PHP in install method to make sure your dependency is installed via composer, but not tested this.  
.  
Also please refer to: [shopware - How to require a composer package inside a plugin? - Stack Overflow](https://stackoverflow.com/questions/66132997/how-to-require-a-composer-package-inside-a-plugin)
