Skip to content

ETT-634 Use composer rather than downloading phar files#122

Merged
moseshll merged 14 commits intomainfrom
ETT-634_composer
Jan 29, 2026
Merged

ETT-634 Use composer rather than downloading phar files#122
moseshll merged 14 commits intomainfrom
ETT-634_composer

Conversation

@moseshll
Copy link
Copy Markdown
Contributor

@moseshll moseshll commented Jan 20, 2026

  • Remove PEAR from the Dockerfile
  • Install composer with other PHP dependencies
    • composer.json and composer.lock (it's a big one!) are our Gemfile analogues.
  • Use standard autoload line in place of PEAR requires: require_once 'vendor/autoload.php'
  • Add Playwright tests to make sure some of the less commonly used API endpoints are not broken by the composer transition
  • Installation of dependencies to vendor/ (à la bundle install) should not need to be done manually since I have added a lightweight composer service as a dependency for vufind and phpunit in the docker compose. This should work inside the babel project without modification, I hope?
    • There is weak evidence (a possibly hallucinatory Google AI summary) that composer install does not wipe-and-reinstall if vendor/ matches the data in composer.lock, making it a near-noop. If so then this approach should not be burdensome so long as it's reliable.
  • Remove apparently-unneeded PHP extensions installed by the Dockerfile.
  • Staged on dev-2 -- composer is now available
  • deploydeploy.sh script invoke composer and adds it to the git archive tarball it sends to production
  • TODO: test with beta-1
  • NOT TODO: we are using an old version of phpunit but it does not appear to be a zero-effort upgrade path, so out of scope.

Note: do not merge until we have composer available on the relevant VMs

…h need for messing around with the include path.

- We should have most of PEAR taken care of.
- `test/RecordUtilsTest.php` was having trouble with the `global $htstatus` that PHPUnit wants to set to null.
- PHPUnit vendored (and slightly version bumped, although it is still a couple major versions old).
- Fix two warnings/errors in HTID.php exposed by playwright tests.
…ry to only invoke it when needed.

- Will this get in the way by running too often?
Comment thread services/Record/HTID.php
header('Content-type: text/html; charset=UTF-8');
echo "<h1>Not found</h1>";
echo "'$id' is not a valid record identifier.";
echo "'$htid' is not a valid record identifier.";
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug exposed by playwright tests

Comment thread services/Record/HTID.php


header("Location: /Record/$id", true, '301 Moved Permanently');
header("Location: /Record/$id", true, 301);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug exposed by playwright tests

Comment thread services/Search/Home.php

require_once 'vendor/autoload.php';
require_once 'sys/LoggingPager.php';
require_once 'Pager/Pager.php';
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is Pager/Pager.php PEAR or a built-in? May be able to remove it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's PEAR plus our own subclass Pager_LoggingPager that is indeed used, but I don't know what it brings to the table vs the base PEAR class. It doesn't seem to actually do any logging.

Comment thread test/RecordUtilsTest.php


$HT_COLLECTIONS = eval(file_get_contents('__DIR__/../derived_data/ht_collections.php'));
global $htstatus;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

phpunit has a reputation for not playing nicely with globals. These tests apparently broke because we updated the version slightly with composer. This two-line declare/assign is needed to keep the variable from becoming null inside the individual tests.

Comment thread docker-compose.yml
profiles:
- playwright

composer:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run this before another of the PHP services (vufind, phpunit) to make sure the dependencies are there.

@moseshll moseshll marked this pull request as ready for review January 21, 2026 15:50
Copy link
Copy Markdown
Member

@aelkiss aelkiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't tried this out yet but just looking at what's here:

  • Doing the composer install in this way via docker compose looks pretty slick and could be an approach we take with the bundle install in ruby-land.
  • Generally with bundler in ruby we've used a separate volume in the docker compose rather than installing them in the working directory. There are pros and cons either way. If we add them in the working directory we need to make sure the vendor directory is ignored in .dockerignore.
  • As far as deployment, I would probably expect we'd do the composer install in test.catalog as part of staging, then deploy everything.

@aelkiss
Copy link
Copy Markdown
Member

aelkiss commented Jan 21, 2026

Another thought is that there are a bunch of Debian packages we're installing (php-curl, php-gd, etc) that might be better installed via composer, but so long as things work as expected like this, migrating those could be a second phase of work.

Copy link
Copy Markdown
Contributor

@liseli liseli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've started the Catalog application locally, and all the features are working smoothly. I'll go ahead and approve it.

@moseshll
Copy link
Copy Markdown
Contributor Author

I will see if composer is available on dev-2 and test there. I don't have any real familiarity with the deploy script so I want to study it.

@aelkiss
Copy link
Copy Markdown
Member

aelkiss commented Jan 27, 2026

@moseshll It should be. Let me know if you run into any issues.

@moseshll
Copy link
Copy Markdown
Contributor Author

I've downgraded some of the dependencies for PHP 7. We can bump them back up after we're fully on board with PHP 8 everywhere. Still TODO: deploy script needs vendor added to the tarball that's being SSHed to the webservers.

…before sending to production servers.

 - I don't know if this will actually work -- i.e., I have not tested `deploy()` just the other parts
@moseshll
Copy link
Copy Markdown
Contributor Author

@aelkiss I've downgraded some of the dependencies according to the environment on dev-2. The real question is whether we want to go with the modified deploy.sh I just pushed. I can't see any glaring flaws with it, but....

It does assume composer install has already been called, and that the vendor directory is there. I should probably add an explicit check for vendor/ as noted in the comments, and also call composer install even if it's a no-op.

@aelkiss aelkiss self-requested a review January 27, 2026 22:46
@aelkiss
Copy link
Copy Markdown
Member

aelkiss commented Jan 27, 2026

@moseshll I'll take a look at the revised deploy script. The changes you're suggesting shouldn't hurt.

Copy link
Copy Markdown
Member

@aelkiss aelkiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes in the deploy script look reasonable enough; as you said I think it doesn't hurt to run composer & to bail out if that fails and/or vendor doesn't exist. We should certainly test deploying to preview.catalog (which may have some other issues going on right now -- we may actually want to clear out beta-1.catalog and try deploying to that, for want of somewhere to test with) before deploying to production, though.

@moseshll
Copy link
Copy Markdown
Contributor Author

Deployed to beta-1. I'm going to pause to take a few breaths then plan to merge and deploy.

@moseshll moseshll merged commit d04778d into main Jan 29, 2026
2 checks passed
@moseshll moseshll deleted the ETT-634_composer branch January 29, 2026 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants