• Stars
    star
    106
  • Rank 317,124 (Top 7 %)
  • Language
    PHP
  • Created about 4 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Magento Composer Replacement Tool

This repository offers a composer plugin to help you manage composer replacements in your root composer.json. Once this package is installed, the composer plugin is installed, which allows you to manage replacements via specific commands (composer replace:?). To make sure replacements don't conflict, this plugin adds its own section extra.replace to your composer.json as well.

Installation of this plugin

composer require yireo/magento2-replace-tools

General usage

Through a series commands, this composer plugin aims to help you manage your replace section more efficiently. Instead of individually adding packages, packages are added in bulk through an additional composer section extra.replace:

{
    "replace": {
        "klarna/module-kp-graph-ql": "*",
        "magento/module-async-order-graph-ql": "*",
        "magento/module-authorizenet-graph-ql": "*",
        "magento/module-braintree-graph-ql": "*",
        "magento/module-bundle-graph-ql": "*",
        "magento/module-catalog-graph-ql": "*",
        ...
        "yireo/example-graph-ql"
    },
    "extra": {
        "replace": {
            "bulk": {
                "yireo/magento2-replace-graph-ql": true
            },
            "exclude": {
                "magento/module-graph-ql": true
            },
            "include": {
                "yireo/example-graph-ql": true
            }
        }
    }
}

Replacing packages (any composer project)

List all current composer replacements:

composer replace:list

Replace a specific package:

composer replace:add foo/bar '2.0'

Remove a specific replacement:

composer replace:remove foo/bar

Remove a specific package (by using a version set to *):

composer replace:add foo/bar

Replacing packages by bulk (Magento-specific)

Replace all Magento Multi Source Inventory packages:

composer replace:bulk:add yireo/magento2-replace-inventory

This adds all replacements from this meta-package yireo/magento2-replace-inventory to your own replace section. And it also adds an additional section like the following:

    "extra": {
        "replace": {
            "bulk": {
                "yireo/magento2-replace-inventory": true
            }
        }
    },

Replace all Magento GraphQL packages, but not the magento/module-graph-ql package itself, but again also replacing a package yireo/example-graph-ql:

composer replace:bulk:add yireo/magento2-replace-graphql
composer replace:bulk:exclude magento/module-graph-ql
composer replace:bulk:include yireo/example-graph-ql
composer replace:validate
composer replace:build

This adds all replacements from this meta-package yireo/magento2-replace-graphql (except the package magento/module-graph-ql but including the package yireo/example-graph-ql) to your own replace section. And it also adds an additional section like the following:

{
  "replace": {
      "klarna/module-kp-graph-ql": "*",
      "magento/module-async-order-graph-ql": "*",
      "magento/module-authorizenet-graph-ql": "*",
      "magento/module-braintree-graph-ql": "*",
      "magento/module-bundle-graph-ql": "*",
      "magento/module-catalog-graph-ql": "*",
      ...
      "yireo/example-graph-ql"
  },  
  "extra": {
    "replace": {
      "bulk": {
        "yireo/magento2-replace-graph-ql": true
      },
      "exclude": {
        "magento/module-graph-ql": true
      },
      "include": {
        "yireo/example-graph-ql": true
      }
    }
  }
}

Available bulk packages

Please note that the replace feature of composer as being used in these repositories is not well documented and probably abused a bit. If you are not willing to invest time to troubleshoot this yourself, please forget about this approach entirely so that we don't waste anyones time.

Building composer replacements

Use the following command to configure your composer.json for using bulk replacements:

composer replace:bulk add yireo/magento2-replace-bundled
composer replace:bulk add yireo/magento2-replace-inventory
composer replace:bulk add yireo/magento2-replace-graphql
composer replace:bulk add yireo/magento2-replace-sample-data
composer replace:validate
composer replace:build

Using composer replacements

Once you have a replace section in your composer.json file

rm -r vendor/
composer update

Do not just use composer install. Do not use regular composer commands, but please follow this procedure literally and to the point.

After having replaced Magento composer packages

After you have installed a composer replacement, make sure to wipe out the generated/ folder first and next, run bin/magento setup:di:compile and bin/magento setup:upgrade to see if Magento still works. Please note that these steps are generic developer steps, not related to this repository.

rm -r generated/
bin/magento setup:di:compile
bin/magento setup:upgrade

FAQ

I try to install this with composer require a/b but get errors

Please note that this kind of question is not going to be answered anymore, except here: Do not use a simple composer require a/b command. It is not documented above, it is not part of the procedure and it does not work. Do not reason that if you know composer, you know that a simple composer require a/b must work. If you think composer replacements are installed the way as composer packages, you do not know composer replacements.

If you want to receive support, follow along with all of the commands outlined above. And stick to it. Don't argue, don't reason, but stick with it. Next, if all of the workarounds with composer commands fail, only then report an issue on GitHub.

Your extension does not work

You are damn right it does not! The reason is that it is not an extension. This is not about installing Magento modules. This is about replacing composer packages with nothing. The extension is not there, it is not a Magento module. It is rather a carefully crafted composer configuration that could be copied manually or installed with the right procedure. It is a composer meta-package with an undocumented trick. If you don't like it, don't use it.

Installing a package leads to many errors

Intruiging, isn't it? Yes, this could happen. Perhaps some modules that you are replacing are in use with your own custom code. Or perhaps you are relying on other third party extensions that have yet an undocumented dependency that conflicts with this replace trick. If you are not willing to troubleshoot this, simply skip this trick and move on. If you are willing to troubleshoot this, copy the replace lines to your own composer.json and remove lines one-by-one until you have found the culprit.

Is a certain package compatible with Magento 2.x.y?

Theoretically, yes. Make sure to understand that these packages are not modules, not libraries, not Magento extensions. It is a gathering of hacks. So, if you understand the benefit of the replace trick in composer, you can use these repository to ease the pain of upgrading.

One conceptual idea in these repositories is to try to keep track of the main Magento version by creating a branch 2.x.y with a corresponding release x.y.z. So, Magento 2.3.5 matches with the replace branch 3.5.*. Magento 2.4.1 matches with the replace branch 4.1. By adding a dependency with ^4.0 in your composer.json, this will automatically upgrade to any 4.X version, but exclude a major bump to 5.X.

Sometimes the actual work falls behind, which by no means indicates that the current bundling of tricks no longer works. Simply, install this package using composer and see if this works for you (see below).

How do I upgrade the replacements to Magento 2.4.X?

Please note the above on the versioning strategy. Once that's understood, the actual implementation is simple: composer require yireo/magento2-replace-core:^4.0 --no-update.

How to test if this is working?

Take your test environment. Install the relevant packages. If this works, run bin/magento setup:di:compile (in both Developer Mode and Production Mode) to see if there are any errors. If this fails, feel free to report an issue here. If this works, you could assume that this works ok.

Remember this repository offers a smart hack, not a supported solution. You can also live with a slower Magento installation that fully complies with the Magento standards (and ships with modules you don't use and/or like).

How do I know if something is replaced?

Unfortunately, composer does not offer a CLI for this and because the replacements are stored in these packages, they are not mentioned in your own projects composer.json (unless you put them there). However, by opening up the composer.lock file and searching for the keyword replace you can see which packages are replaced by all packages in your installation. A simple composer show yireo/magento2-replace-bundled shows which replacements are included in a specific package.

More Repositories

1

Yireo_Webp2

Magento 2 module to add WebP support to Magento 2
PHP
190
star
2

Yireo_GoogleTagManager2

PHP
136
star
3

magento2-replace-all

Meta-package to replace all optional Magento 2 modules
128
star
4

Magento_EU_Tax_Rates

Magento CSV taxrates for usage within the EU
Shell
108
star
5

Yireo_Whoops

Magento 2 module integrating Whoops error handling
PHP
93
star
6

Yireo_ExtensionChecker

Magento 2 module to check upon the code of Magento 2 modules from the CLI
PHP
84
star
7

Yireo_CheckoutTester2

Checkout test for Magento 2
PHP
80
star
8

Yireo_LinkPreload

Magento 2 extension to set HTTP Link headers for primary resources to allow for HTTP/2 Server Push
PHP
74
star
9

magento2-replace-inventory

Magento 2 meta-package to replace all optional MSI modules
49
star
10

magento2-replace-bundled

Magento 2 meta-package to replace all optional third-party modules bundled with the core
44
star
11

Yireo_NextGenImages

PHP
44
star
12

Yireo_DisableLog2

Magento 2 module to disable customer logging
PHP
30
star
13

magento2-replace-core

Magento 2 meta-package to replace all optional core modules
28
star
14

Yireo_EmailTester2

PHP
25
star
15

Yireo_AutoFlushCache

Magento 2 module to automatically flush the cache whenever you save something in the System Configuration
PHP
25
star
16

magento-ce-languagefiles

Magento CE language-files
PHP
24
star
17

Yireo_DumpCmsContent

A Magento 2 module that adds a CLI bin/magento cms:dump to dump all CMS pages and CMS blocks to a folder var/cms-output.
PHP
16
star
18

magento2-replace-graphql

Magento 2 meta-package to replace all optional GraphQL modules
16
star
19

Yireo_NewRelic2

Magento 2 extension to integrate New Relic
PHP
15
star
20

Yireo_ThemeOverrideChecker

PHP
15
star
21

Yireo_RemoveSearch

PHP
13
star
22

Yireo_ThemeCommands

PHP
12
star
23

magento2-corshack

PHP
12
star
24

Yireo_IntegrationTestHelper

PHP
12
star
25

Yireo_AdditionalEndpointsGraphQl

PHP
10
star
26

Yireo_GraphQlRateLimiting

Magento 2 module to add rate limiting to GraphQL resources
PHP
10
star
27

Yireo_BackendReindexer

Magento 2 module to add reindexing to the Admin Panel
PHP
10
star
28

vsf-config-validator

A simple PHP CLI tool to check whether your Vue Storefront PWA configuration matches the structure of your Magento 1 or 2 site
PHP
9
star
29

Yireo_SyncGraphQlSessionWithFrontend

Magento 2 module to sync a GraphQL session with the regular session
PHP
8
star
30

Yireo_TranslatableTitle

Magento 2 extension to make XML layout titles translatable
PHP
8
star
31

magento2-codeception-utilities

Yireo Codeception utilities for Magento 2
PHP
8
star
32

mageunconference-nl-2023-notes

Notes of MageUnconference NL 2023
8
star
33

Yireo_AdditionalBlockTemplate

PHP
8
star
34

Yireo_HyvaCheckoutPostcodeValidator

PHP
7
star
35

Yireo_DevHacks

Magento 2 module with various hacks and solutions for custom development
PHP
6
star
36

Yireo_CommonViewModels

Common ViewModels for usage in Magento 2.2.1+ frontends
PHP
6
star
37

magento2-replace-composer-plugin

Manage your composer replacements in your Magento project
6
star
38

Yireo_SalesBlock2

PHP
5
star
39

magento2-replace-content-staging

Magento 2 meta-package to remove Content Staging modules
4
star
40

Yireo_DeleteAnyOrder2

PHP
4
star
41

Yireo_CatalogUtils

Library of Magento 2 catalog utitlities, for inclusion in other Magento 2 modules
PHP
4
star
42

Yireo_DisableServiceWorkerInAdmin

Simple Magento 2 module to unregister any ServiceWorkers when entering the backend
HTML
4
star
43

Yireo_CustomStepUi

Magento 2 module to add an example step to the checkout.
JavaScript
4
star
44

Yireo_EasierExtensionAttributes

PHP
4
star
45

Yireo_LiveTestRunner

PHP
4
star
46

Yireo_ByAttributeGraphQl

PHP
3
star
47

Yireo_Satis

Satis for composer repositories of Yireo extensions for Magento
HTML
3
star
48

Yireo_ExtensionCheckerCli

Add-on to Yireo_ExtensionChecker for standalone usage
PHP
3
star
49

Yireo_Bootstrap3

Magento 2 module inserting Twitter Bootstrap 3 via CDN
JavaScript
3
star
50

Yireo_Avif

Magento 2 extensions to use AVIF images in your shop
PHP
3
star
51

vsf2-webpack-inheritance-plugin

Webpack plugin for Vue Storefront 2 theme inheritance
JavaScript
3
star
52

Yireo_AdditionalLanguageFile

PHP
3
star
53

Yireo_AdminCheckMaxInputVars

Magento 2 module to check for PHP limits when POSTing from the Magento Admin Panel
PHP
3
star
54

MagentoEuVatRatesLibrary

PHP library to load VAT rates from Github repo into Magento
PHP
3
star
55

Yireo_HyvaCheckoutVatIdIfCompany

PHP
3
star
56

magento2-replace-pagebuilder

Replace all PageBuilder packages
2
star
57

Yireo_ExampleJsComponent

Example module to show functionality of JS component in Magento 2
PHP
2
star
58

Yireo_Webp2ForAmastyShopby

Webp2 add-on to make Yireo_Webp2 work for Amasty_Shopby
PHP
2
star
59

yireo-slides

Yireo Slides
JavaScript
2
star
60

Yireo_Webp2ForHyva

PHP
2
star
61

Yireo_SalesBlock2ByIp

Helper-module for the Magento 2 extension Yireo_SalesBlock2
PHP
2
star
62

Yireo_CustomGraphQlQueryLimiter

Magento 2 module to customize settings for the GraphQL Query Limiter to enhance performance and security of your headless Magento.
PHP
2
star
63

Yireo_DirectoryDataCache

PHP
2
star
64

vsf1-webpack-inheritance-plugin

JavaScript
2
star
65

Yireo_HyvaCheckoutProgressBar

PHP
2
star
66

Yireo_OrderCreator

PHP
1
star
67

Yireo_FasterScriptLoader

PHP
1
star
68

Yireo_SalesBlock2ByGeo

Helper-module for the Magento 2 extension Yireo_SalesBlock2
PHP
1
star
69

Yireo_Core

Core library for assistance in various Magento modules
PHP
1
star
70

Yireo_ExtensionValidationTools

PHP
1
star
71

magento2-replace-sample-data

1
star
72

Yireo_SalesBlock2ByEmail

Helper-module for the Magento 2 extension Yireo_SalesBlock2
PHP
1
star
73

Yireo_AdminReactComponents

PHP
1
star
74

producteev-client

PHP client for Producteev
PHP
1
star
75

Yireo_TaxRatesManager2

PHP
1
star
76

magento-autoform

Chrome extension to automatically fill in Magento forms
JavaScript
1
star
77

Magewirephp_MagewireBackendGridExample

PHP
1
star
78

Magewirephp_MagewireBackendGrid

PHP
1
star
79

Magento2-Extensions-Ready-List

A CSV list of Magento extensions that are available or not for Magento 2
1
star
80

Yireo_CustomerValidatorPool

PHP
1
star
81

Yireo_HyvaCheckoutCoc

PHP
1
star
82

Yireo_MageWireBackendConfigSearch

PHP
1
star