Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

161
Visualizações
How to include overlapping composer dependencies in a Shopware 6 plugin ZIP?

When distributing Shopware Plugins as a ZIP file, it must include the vendor directory, but without the shopware/core, shopware/administration, etc. dependencies defined in the composer.json. That one I got to work.

But how to include dependencies, which themselves have dependencies, that overlap with the shopware/core dependencies?

Explicitly, I try to add a package, that depends (like Shopware itself) on psr/cache. But when I include it, I receive the following error message, when activating the plugin:

Fatal error: Cannot declare interface Psr\Cache\CacheItemPoolInterface, because the name is already in use in /var/www/html/vendor/psr/cache/src/CacheItemPoolInterface.php on line 14

Is there any known workflow to solve these kinds of issues? The documentation, that Shopware provides, do not explain how to solve these kinds of conflicts.

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

If you distribute plugins for Shopware and use Composer libraries, you can find scope and namespace conflicts like Fatal error: Cannot declare interface.... The same problem is found on WordPress, Joomla, PrestaShop, or any other CMS where you don't have complete control of what is installed.

As you described, the initial problem is a conflict between the core libraries and your plugin dependencies. Additionally, you can find trouble between every package installed on the system that copies Composer packages to Shopware using the same libraries or different versions of the same libraries.

In practice, the only real and most flexible solution is prefixing the PHP code that you bundle in the ZIP file. In this way, you are entirely sure that it works independently of what is installed alongside it.

In the PHP ecosystem, there are a few solutions to prefix namespaces and customize the project scope. For instance: php-scoper, namespacer, mozart or PHP-Prefixer.

Disclaimer: I'm the lead PHP-Prefixer developer.

over 4 years ago · Santiago Trujillo Relatório

0

If it is your plugin, then there are three options.

  1. Require the same package
  2. Use a tool like https://github.com/humbug/php-scoper to fix the naming problems.
  3. Install it via composer

If it is not yours, you should create an issue for the plugin provider.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda