I am confused by these alternatives. Composer is available as a package that can be installed with APT.
It surprises me when I look at instructions for installing Composer on Debian 10, usually the Composer installer is recommended instead of the package through the apt repo.
Can you possibly explain what is going on with this?
Once again - Debian stable uses older packages to ensure that your system is as stable and bug-free as possible. Security updates are back-ported to these older releases. So it would be expected for the Debian package for composer to be slightly older.
From a quick bit of duckduckgo-fu - Debian testing currently contains composer v2.09 and the latest version v2.11 is in the Debian unstable and experimental branches.
ref:
Eventually 2.11 will end up being moved from experimental and Unstable, before ending up in Debian testing.
So if you want to use apt to install composer - you either have to stick with the old version that is in stable, or enable one of the other repos (testing, unstable or experimental) in order to be able to use a slightly newer version.
That will allow you to install it using apt.
But it takes a long time for newer versions of packages to end up in apt in Debian Stable.
Software in stable usually only gets updated to a newer version when the "testing" branch is finally deemed ready for the next release - Then whatever is in testing ends up becoming the next release of Debian Stable.
So if you're using Debian stable, you're almost certainly
not going to see a newer version of composer until the next version of Debian Stable is released. Again, typically the software in Debian stable just gets back-ported bug-fixes and security updates.
So if you want to install a newer version via apt, you will have to enable one or more of the repo's from Debian's other branches (testing, unstable, experimental). But the trade-off in using software from testing, unstable, or experimental is that you may occasionally experience breakages, bugs and/or instability.
However, composer is written entirely in php - so you could just as easily use composers install script to install it manually, on top of your existing system (as per the link in my previous post).
So that is another perfectly valid way to install the latest version.
Sure using apt is cleaner, from a system standpoint. But if you're using Debian you need to decide what is more important to you.
If you absolutely NEED the very latest bleeding edge features etc. in the latest version of a piece of software, and you don't want to wait for a newer version to be available in stable - then your only choice is to either enable the other repos, or install it a different way - like installing from source and building/installing manually, or using an installer like the one that composer uses.
So with composer - you have the following choices.
You can:
1. Make do with the version of composer in Stable until the next version of stable is released.
2. Add repositories from other Debian branches (testing, unstable, experimental) - to install a newer version and potentially risk instability/breakage.
3. Install composer via another official installation medium - like it's install script.
The choice is yours - the only correct answer is whatever is correct for you!