0

Edit: This question has gotten quite old and is no longer useful. Prestissimo isn't really useful any more now that Composer 2 is out. The way to use composer 2 in DDEV-Local v1.16 is ddev config --composer-version=2. In DDEV-Local v1.17 Composer 2 will be the default.

Original question:

I'd like to use hirak/prestissimo to speed up the downloads for my DDEV-Local composer builds on all my projects, but I don't know how to install it globally. How can I install it?

rfay
  • 9,963
  • 1
  • 47
  • 89

3 Answers3

3

In DDEV-Local v1.15+ you can globally put anything you want in the web container home directory using the homeadditions feature, and in the web container the composer global configuration is in ~/.composer. So the simple way to create the files you need (and hirak/prestissimo is just an example) is to

ddev composer global require hirak/prestissimo # This installs prestissimo into global composer (home directory)
docker cp ddev-<your-project-name>-web:/home/$(id -un)/.composer ~/.ddev/homeadditions/
ddev start

Of course, you can also do this on the project level instead of the global level using your project's .ddev/homeadditions directory instead of the ~/.ddev/homeadditions directory.

rfay
  • 9,963
  • 1
  • 47
  • 89
0

In addition to what rfay said, and based on his solution here is another approach.

In your .ddev/web-build/Dockerfile add RUN composer global require hirak/prestissimo. This will install hirak/prestissimo in the /root/.composer directory.

Then, in the .ddev/homeadditions/.bash_aliases add the following:

sync_global_composer() {
    sudo rsync -a /root/.composer/ /home/$(id -un)/.composer
    sudo chown -R 1000:1000 /home/$(id -un)/.composer
}

sync_global_composer

The first time you execute ddev ssh will take a bit longer because of the rsync, but the followings are quick.

The reason of this approach is not having prestissimo (and in my case some others global libraries) in git, and the idea is to have this transparent for the rest of the dev team.

PD: I'm still thinking in how to improve it.

Ignacio Sánchez
  • 409
  • 4
  • 14
  • Nice. How about just `sudo chmod ugo+w /root/.composer` and then put `export COMPOSER_HOME=/root/.composer` into the environment of the user? Or use another location for COMPOSER_HOME. Just seems easier than the sync_global_composer function. – rfay Aug 23 '20 at 13:31
  • Yeah, that looks clever. Thanks! – Ignacio Sánchez Aug 24 '20 at 07:51
-1

You can also update to composer 2 since it is fast enough to not need hirak. Update using composer self-update --2 and then remove hirak/prestissimo with composer global remove hirak/prestissimo

resources:

Leo Fisher
  • 310
  • 6
  • 12
  • On ddev, the way to do this is `ddev config --composer-version=2` - the way you suggest here gets overwritten every time the project starts up. BUT... using Composer 2 is the right thing, and prestissimo isn't useful any more IMO. – rfay Mar 04 '21 at 04:36
  • 1
    I edited the main question to hopefully direct people the right direction. – rfay Mar 04 '21 at 04:40