Why this matters
Most of the code in a modern PHP project is not written by its maintainers. It comes from dependencies, and those dependencies get security fixes on their own schedule. Someone has to notice each new release and bring it in. Doing that by hand means it happens rarely, and vulnerabilities sit in the project for months.
An update bot such as Dependabot or Renovate watches your dependencies and opens a pull request for each new version. Reviewing and merging a pull request is a small, regular task. Catching up on two years of missed updates is not.
What good looks like
- An update bot is configured in the repository.
- The bot covers every ecosystem the repository actually uses: Composer, GitHub Actions if you have workflows, and npm, yarn, pnpm, or bun if you have a JavaScript lockfile.
- Its pull requests are reviewed and merged in a reasonable time.
How to do it
Dependabot (GitHub)
Create .github/dependabot.yml with one entry per ecosystem:
version: 2
updates:
- package-ecosystem: composer
directory: /
schedule:
interval: weekly
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
# Only if you have a package-lock.json, yarn.lock, or pnpm-lock.yaml.
- package-ecosystem: npm
directory: /
schedule:
interval: weekly
Dependabot is built into GitHub. Committing this file is all it takes.
Renovate (GitHub, GitLab, and others)
Install the Renovate app on GitHub, or set up the Renovate runner on GitLab, then add a renovate.json to the repository root:
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:recommended"]
}
Renovate enables every manager it knows about by default, including Composer, GitHub Actions, and npm. If you restrict it with enabledManagers, make sure the list includes every ecosystem you use:
{
"extends": ["config:recommended"],
"enabledManagers": ["composer", "github-actions", "npm"]
}
Which one?
Both work well. Dependabot needs no installation on GitHub and has a small configuration surface. Renovate runs on more platforms, can group related updates into one pull request, and offers finer control. Pick one; running both creates duplicate pull requests.
Things to watch for
- Configuring only Composer. If the repository has workflow files, GitHub Actions is an ecosystem too, and action releases carry security fixes. The same goes for JavaScript lockfiles.
- A library with no lockfile. Libraries often do not commit
composer.lock, which is fine. In that case there is nothing for the bot to update for Composer, and only the other ecosystems need coverage. - Renovate's
enabledManagersmissing an ecosystem. This setting is an allow list. Anything not listed is silently ignored. - Turning the bot on and ignoring it. Open pull requests that nobody merges do not fix anything. Set a routine for reviewing them.