Package Repository Website for Composer, see the about page on packagist.org for more.
This project is not meant for re-use.
It is open source to make it easy to contribute. We provide no support if you want to run your own, and will do breaking changes without notice.
Check out Private Packagist if you want to host your own packages.
These steps are provided for development purposes only.
- PHP for the web app
- NPM (or Docker) for the frontend build
- Symfony CLI to run the web server
- MySQL (or Docker) for the main data store
- Redis (or Docker) for some functionality (favorites, download statistics)
- git to crawl package repositories
-
Clone the repository
-
Install dependencies:
composer install npm install
Ensure env vars are set up correctly, you probably need to set
APP_MAILER_FROM_EMAIL,APP_MAILER_FROM_NAMEandAPP_DEV_EMAIL_RECIPIENTin.env.local. Set alsoMAILER_DSNif you'd like to receive email. -
Start the web server:
symfony serve -d
-
Start MySQL & Redis:
docker compose up -d # or somehow run MySQL & Redis on localhost without DockerThis mounts the current working directory into the node container and runs npm install and npm run build automatically.
-
Create 2 databases:
packagist- for the web apppackagist_test- for running the tests
bin/console doctrine:database:create bin/console doctrine:database:create --env=test
-
Setup the database schema:
bin/console doctrine:schema:create
-
Run a CRON job
bin/console packagist:run-workersto make sure packages update. -
Run a CRON job
bin/console packagist:project-transparency-log(e.g. every minute) to project audit log entries into the public package transparency log. See Transparency log backfill before enabling this on an existing database. -
Run
npm run buildornpm run devto build (or build&watch) css/js files. When using Docker rundocker compose run node npm run devto watch css/js files.
You should now be able to access the site, create a user, etc.
package_transparency_log is projected from audit_log by packagist:project-transparency-log, which
only publishes what is in the package_transparency_log_queue outbox. A queue row is written at the
same time as the audit record itself, so nothing that predates the queue is ever published on its own
and the cron is safe to enable on a database with existing audit history.
To backfill the transparency log, use the following commands. On a database that already has audit history, run:
bin/console packagist:seed-transparency-log-queue --dry-run
bin/console packagist:seed-transparency-log-queueThen drain it before enabling the cron:
bin/console packagist:project-transparency-log --suppress-out-of-order-loggingSeeded records are older than whatever is already in the log, so each one would otherwise warn about being appended out of order. On a first backfill the log is empty and the option changes nothing, but any drain run is where that warning is expected: a re-seed after making another audit type projectable, or resuming an interrupted drain, logs one per record without it.
The seed command only ever enqueues package, version and ownership events, which carry their own package and so backfill exactly as they happened. Account events (2FA, password, email, GitHub link) carry no package and fan out to whoever maintains the package at projection time, so backfilling them would publish old events against today's maintainer set, and a published entry cannot be retracted.
Seeding is safe to re-run: it skips anything that already has a package_transparency_log entry or a
queue row. Seeded records are appended at the end of package_transparency_log, since an append-only
log cannot take insertions, so they appear as recent entries carrying old timestamps.
The User and Actor filters and the link on a user's profile read package_transparency_log_search. It
has one row for each person and role that an entry names. package_transparency_log.userId is not
enough, because it holds only the subject, and most entries have none.
The table stores the username and the account id. The filters search by username, so the result can include more than one account if a username changed owner. The profile link searches by account id, so it also finds entries from before a rename.
The projector writes the rows in the same transaction as the entries. Entries projected before the table existed need a one-time backfill:
bin/console packagist:backfill-transparency-log-search --dry-run
bin/console packagist:backfill-transparency-log-searchYou can run it more than once, and while the projection cron runs. Until it is done, older entries are missing only from filtered results.
You can get test data by running the fixtures:
bin/console doctrine:fixtures:load --group base
bin/console doctrine:fixtures:load --group downloads --appendThis will create some packages, update them from GitHub, populate them
with fake download stats, and assign a user named dev (with password: dev)
as their maintainer.
There is also a user user (with password: user) that has no access if you
need to check readonly views.
Finally there is a user admin (with password: admin) that has super admin
permissions.
Search is optional locally: with no Algolia config the rest of the site works
normally, /search.json returns an error response and the search page renders
without results. To use the search, setup an
Algolia Account and configure following keys
in your .env.local:
ALGOLIA_APP_ID=
ALGOLIA_ADMIN_KEY=
ALGOLIA_SEARCH_KEY=
ALGOLIA_INDEX_NAME=To setup the search index, run:
bin/console algolia:configure
bin/console packagist:indexUse a trusted HTTPS certificate for https://packagist.wip. For a different local
host, set WEBAUTHN_RP_ID to the hostname and WEBAUTHN_ORIGIN to the exact
origin, including any port.
Before testing verified hardware-key enrollment, import the official FIDO metadata:
bin/console packagist:webauthn:refresh-metadataRun a daily CRON job bin/console packagist:webauthn:refresh-metadata to keep the metadata current.