Best approach for loading php composer dependencies

I use maven in JAVA and started using PHP Maven, I recently switched to composer.

My project is with Zend Framework 2, and the team only checks the application code with nothing in the vendor directory. This is done in order to avoid conflicts and not have libraries under SVN.

Now every time a developer installs his new environment, we observe that the composer extracts dependencies from the Internet. It takes a lot of time.

Is there a better idea / approach to make it faster or process the project differently to avoid this problem?

maven uses a maven proxy that can cache downloads and can be used on the network again, but do we have any solutions to solve such problems?

+6
source share
2 answers

In PHP, there is an existing option to run compost as a repo locally, and it is called Satis (it is actually provided by Composer) here: https://github.com/composer/satis

So, you can run it locally on your server and indicate that your composer uses it as the default composer repository, and Satis guarantees that all installed packages and different versions will be cached on disk as ZIP files, so they could get faster than always downloading them from the internet.

You can do something like this:

{ "repositories": [ { "type": "composer", "url": "http://satis.example.org/" } ], "require": { "company/package": "1.2.0", "company/package2": "1.5.2", "company/package3": "dev-master" } } 

It also allows you to have private packages and libraries without exposing them to GitHub.

Another advantage of BIG is that GitHub comes for some reason that you can still use, since all your dependencies are encrypted locally. It is assumed that you did not add new non-existent packages to the release.

+1
source

The composer is a very young project, so things may be missing, for example, Maven can do without hassle.

You can configure your own Packagist server as described in the composer documentation . I believe packagist has some caching options that can be used to store packages on the packagist server.

What you can also do is fork out your dependencies and forward them to your company’s private repository. In your composer.json you will now only use these dependencies, which speeds up cloning. Of course, this will require you to support all the different dependencies (although this can be done with a script and cronjob by pulling data from the github repository and pushing it to your company).

I also believe that the composer has some proxy settings, but I don’t think they are intended for caching dependencies.

The final option would be to develop something similar, either as part of a composer / package, or as standalone.

+2
source

All Articles