Hello everyone,

lately, the PHP community goes crazy because of the upcoming deprecation and discontinuation of PHP7.4. Many vendors aren't ready to upgrade to PHP8.1 and some work most be done in order to be able to upgrade without an issue. So did one of our clients.

We had to upgrade from a composer setup that was working with PHP7.4 to PHP8.1, but it wasn't so easy to do. The system is a relatively large legacy system that weren't so easy to bring to PHP7.4 back in the days. Now, PHP8.x and PHP7.4 aren't so much different. After some upgrades for more famous packages such as PHPStan oder PHPUnit, we still had the issue that one major component that was unfortunately relevant for the whole pipeline process wasn't ready for PHP8.1 and Composer V1.

So, we've decided to take a closer look at the failing module and upgrade it accordingly. The failing module was Fancyguys Webroot installer. A package needed to install a specific composer package into a different directory. This comes in handy when you have one core package that you fetch from an external source or a custom VCS but want to have it in a dedicated folder. Lets assume you have your core code of your shop in one repository, but the customizations in another. This is where this approach would be useful. 

After some back and forth we were able to install the package, but it still showed us an ugly deprecation warning that we wanted to get rid of. Since the module of Fancyguy is straight forward, there was not so much code to deep-dive into. However, we forked and adapted the plugin and published it to Github.

If you have used Fancyguy Webroot-Installer in the past and now you have the same problem like our client did, you can use our module, too. Feel free to open an issue if you find any problems with it. However, it will require you to do some custom setup in your composer.json in order to correctly fetch the plugin. Since the original webroot installer package is submitted to packagist, we didn't wanted to override it, since our version is explicitly not working with anything below PHP 8.0. 

Adapt your composer.json as so:

// ...
"repositories": [
        "type": "vcs",
        "url": "git@github.com:nopenopenope/webroot-installer.git",
        "only": ["nopenopenope/webroot-installer"]
// ...

Afterwards, you can simply run:

$ composer require nopenopenope/webroot-installer

Now, you can specify your to-be-moved package properly. Adapt the packages composer.json that should be moved:

"type": "webroot",

.. and composer will install the package for you as you know it. Its important to note that this won't work for 3rd party packages unless you specify them as package in the repository package, you can see an example on how to do it in the Readme of the Githubs repository. With this approach you can even use any 3rd party package properly.

You can also check out the Github repository directly to learn better how to utilize it for new projects: https://github.com/nopenopenope/webroot-installer

There are some use-cases, but certainly a state-of-the-art process would look different. However, for specific applications this will be a perfect way to bring vendor packages directly in a more top-level directory.