composer-phpsatis

Why should have I to use Satis if i can specify private repos in composer.json?


I'm developing some libraries i frequently use across more than one project and i use GIT to version them.

Now, i'd like to use them through Composer.

Here comes my question: Composer makes me able to specify some private repositories from which i can pull source code to include in my apps (https://getcomposer.org/doc/05-repositories.md#using-private-repositories).

Then, i found Satis: https://getcomposer.org/doc/articles/handling-private-packages-with-satis.md#satis

Now, i don't well understand the differences between the two and which advantages i can have using Satis instead of using the private repositories through the Composer capabilities.

Should i really have to setup a Setis server? Which advantages does it bring to me?


Solution

  • By default, Composer looks for dependencies from your composer.json on special public package repository named Packagist. Packagist stores each added repository location and its dependencies. When you run composer install, Composer asks Packagist for dependencies and their locations and then downloads them.

    But when you have a really big project with a lot of dependencies or(and) you are building your project rather frequently, then you can soon run into two problems.

    The first and the main problem is speed. If you don't have wide internet connection, building your app simultaneously by all the members of your team can take plenty of time.

    The second problem is that public repository hosting services like Github usually have limits for api requests.

    You can solve both these problems setting up a mirror of Packagist with Satis in your local infrastructure. In this case Composer won't go to Packagist for your dependencies, but ask your Satis server for them.

    Packagist is a public service, but sometimes you want to add your another private repository as a dependency. You can add a special entry to your composer.json to make Composer download this package from another location. And if you want, you can also make Satis to mirror your private repositories as it does with public ones.