A package works in the project: why that is not enough for a separate release

Expose a hidden runtime dependency using synthetic ZIP artifacts, minimal PHP/Composer consumers and reinstallation without development packages.

Moving to a separate table exposes a part that can be easy to overlook in the original workshop.

A capability works inside an application, its tests pass in the familiar environment, and its code has already moved into a separate directory. Assigning a version appears to be the last step. Yet the first independent consumer may install the package successfully and fail exactly when it calls the method it needs.

The cause can be mundane: the original project supplied a dependency that the package never declared as its own. A shared vendor/ tree, a supplementary autoloader, or a testing dependency concealed that agreement. A separate release needs a different check: are the published artifact and its declared requirements sufficient to run the capability in a clean consumer?

Keep one main Symfony project, article_demo. This narrow Composer check uses disposable minimal PHP dependency consumers, each with its own composer.json, lock and autoloader. They are not additional Symfony applications, have no Kernel and are not copied into Demo. The teaching ZIP packages remain artifacts of this exercise.

A small method with a hidden dependency

Consider a library that converts a supplied UUID into its string representation. The example has no database, application configuration, or business identifiers. It has one class in src/ReferenceCode.php:

<?php

declare(strict_types=1);

namespace DemoLab\ReferenceCode;

use Ramsey\Uuid\Uuid;

final class ReferenceCode
{
    public function normalize(string $value): string
    {
        return Uuid::fromString($value)->toString();
    }
}

The names demo-lab/reference-code and DemoLab were invented for this experiment. Uuid::fromString() creates an object from the input string; toString() returns its representation. These methods are described in the ramsey/uuid documentation. The demonstration uses a fixed synthetic UUID without generating personal or random data.

Now consider the incorrect composer.json in package-broken:

{
  "name": "demo-lab/reference-code",
  "description": "Independent teaching fixture for runtime dependency isolation",
  "type": "library",
  "license": "proprietary",
  "version": "1.0.0",
  "require": {
    "php": ">=8.4"
  },
  "require-dev": {
    "ramsey/uuid": "^4.7"
  },
  "autoload": {
    "psr-4": {
      "DemoLab\\ReferenceCode\\": "src/"
    }
  },
  "autoload-dev": {
    "psr-4": {
      "DemoLab\\ReferenceCode\\Tests\\": "tests/"
    }
  }
}

The library is needed at runtime but appears only among development dependencies. When the directory is the root Composer project and installation includes development dependencies, the call can work. When the same package becomes another project's dependency, its require-dev does not become a requirement for the consumer. autoload-dev also belongs to the root context. These are rules of the Composer schema, not a Symfony peculiarity.

One successful call in the original directory would show that the class was available there. It would not establish how the second project obtained that class. Even a complete unit test suite can repeat the same hidden assumption.

From a development directory to an artifact

Separate three locations for the experiment: the library source, the archive directory, and the new application. The consumer should receive an archive rather than a symbolic link to a working tree. Otherwise, editing a local file could silently change the installed dependency without a new release.

Composer supports an artifact repository: a directory of ZIP or TAR files containing composer.json at the archive root. This teaching arrangement delivers the package locally without publishing it to a registry or accessing private code. The PHP ZIP extension is required for this repository type.

Save the class and package description in package-broken, then create tests/DevelopmentMarker.php containing an empty DemoLab\ReferenceCode\Tests\DevelopmentMarker class. It exists solely for a separate dev-autoload check. The archive deliberately includes this test marker: the subject is the loading rule, not an accidentally absent file.

RELEASE_LAB="$(mktemp -d)"
mkdir "$RELEASE_LAB/artifacts" "$RELEASE_LAB/consumer-broken"
(
    cd package-broken
    zip -r "$RELEASE_LAB/artifacts/reference-code-1.0.0.zip" composer.json src tests
)
cat > "$RELEASE_LAB/consumer-broken/composer.json" <<'JSON'
{
    "type": "project",
    "license": "proprietary",
    "require": {"php": ">=8.4"}
}
JSON
cd "$RELEASE_LAB/consumer-broken"
composer config repositories.lab artifact "$RELEASE_LAB/artifacts"
composer require 'demo-lab/reference-code:1.0.0'

These commands need Bash, zip, PHP 8.4+, ext-zip and Composer 2. The minimal root manifest adds neither Symfony nor a UUID library on the consumer’s behalf. Retain actual versions and the lock; the package’s own require must declare its runtime dependency. The complete reproducible sequence is in example/run-lab.sh.

The complete example/run-lab.sh additionally needs Python 3, tar, cmp and sha256sum to build artifacts, transfer snapshots and compare retained files.

The artifact repository definition belongs in the consumer's composer.json. Adding that source only inside the library does not teach the application how to locate its neighbors: Composer reads repositories from the root package. In this example, the public dependency comes from the usual public source and the synthetic one comes from a local directory.

Make the failure unambiguous

Before interpreting the result, check that the minimal consumer did not obtain ramsey/uuid through another dependency. If the class is already available, this is not a valid negative scenario: an additional dependency has concealed the defect again. Stop, inspect the dependency tree, and change the teaching precondition.

composer show --locked
php -r 'require "vendor/autoload.php"; if (class_exists("Ramsey\\Uuid\\Uuid")) { throw new RuntimeException("Dependency is already present."); }'
php -r 'require "vendor/autoload.php"; echo (new DemoLab\ReferenceCode\ReferenceCode())->normalize("550E8400-E29B-41D4-A716-446655440000"), PHP_EOL;'

The final call is expected to fail because Ramsey\Uuid\Uuid is missing. A failure to load ReferenceCode itself, a wrong path, or an extraction error cannot confirm this hypothesis. Those failures mean the experiment never reached the boundary being examined.

In the prepared lab example, the verifier first establishes that the dependency class is absent, then calls normalization and accepts only the specific missing-class error. Every other error remains a failure. That distinguishes “something broke” from a controlled negative test.

The same reasoning applies to autoload-dev: the test marker exists in the archive but must not automatically load in the consumer. Manually including its file would change the subject of the check. We are examining Composer autoloading, not PHP's general ability to execute a file.

Correct the owner of the requirement

The fix belongs in the library description. Adding ramsey/uuid directly to the application would restore the hidden agreement: every new consumer would need to know what the package was missing. The package uses the external class itself, so it must declare the corresponding runtime dependency itself.

The PHP class remains unchanged in package-fixed. The description and teaching version change:

{
  "name": "demo-lab/reference-code",
  "description": "Independent teaching fixture for runtime dependency isolation",
  "type": "library",
  "license": "proprietary",
  "version": "1.0.1",
  "require": {
    "php": ">=8.4",
    "ramsey/uuid": "^4.7"
  },
  "autoload": {
    "psr-4": {
      "DemoLab\\ReferenceCode\\": "src/"
    }
  },
  "autoload-dev": {
    "psr-4": {
      "DemoLab\\ReferenceCode\\Tests\\": "tests/"
    }
  }
}

Here, 1.0.0 and 1.0.1 identify two synthetic archives. They do not refer to actual platform releases. The explicit version field is used for locally assembled artifacts without VCS. For a conventional library with Git tags, Composer recommends deriving the version from VCS rather than duplicating it manually.

Build the second archive from package-fixed and create another minimal consumer. Declare the same artifact source and require demo-lab/reference-code:1.0.1. The application's own require should not additionally contain ramsey/uuid for this test. Composer is expected to install it through the package's declared dependency, and the call is expected to return 550e8400-e29b-41d4-a716-446655440000.

Environment Source of the UUID library Expected property
Package as the root project with development dependencies Incorrect require-dev Normalization may work while hiding the defect
Minimal consumer using version 1.0.0 No declared runtime requirement Installation does not guarantee that the method can execute
Another minimal consumer using version 1.0.1 The library's own require The method should work without manual help from the consumer
Clean reinstallation of the corrected consumer Its retained lock The same behavior without development dependencies

The table defines experiment criteria. It does not replace actual stdout, stderr, exit codes, or the installed dependency tree.

Demonstrate reinstallation

The corrected directory may still contain remnants of earlier attempts. The final step is therefore to transfer the consumer's source, configuration, and real lock files into a new empty directory, excluding vendor/ and var/, and install from those files.

composer install --no-dev --prefer-dist
composer check-platform-reqs --no-dev
php -r 'require "vendor/autoload.php"; echo (new DemoLab\ReferenceCode\ReferenceCode())->normalize("550E8400-E29B-41D4-A716-446655440000"), PHP_EOL;'

With a consistent lock, install reproduces the selected versions; --no-dev excludes the root project's development dependencies. This is documented behavior of the Composer commands. Do not replace this step with update, which would change dependency resolution as well.

A library lock and a consumer lock have different roles. The first fixes the library's development environment; it does not impose that dependency set on all clients. The second identifies the application's particular installed composition. The Composer library documentation explains this boundary explicitly.

Reproducibility requires actual lock files, archive checksums, exact commands, and results. If those do not exist yet, do not fill the report with expected versions. An artifact repository also requires the archives themselves to remain available: a local absolute path in a dependency source does not automatically become portable storage.

What decision can follow this experiment

A clean consumer supports a narrow but useful conclusion: the declared dependencies and the contents of a particular artifact are sufficient for the selected scenario in the tested environment. It does not establish compatibility with every PHP version, the lower bound of every allowed range, or another operating system. Those promises require their own matrix.

Behavioral contracts, configuration, resources, license metadata, Symfony service installation, and data changes remain separate concerns. This normalizer needs no Symfony service registration, external resources, or data migrations. Its behavioral contract and license metadata still matter; extending the result of this narrow check to a complex bundle would be an excessive generalization.

A release decision benefits from a change in the question. Alongside “does the feature work in our project?”, ask “what does an independent consumer need, and where is each prerequisite declared?”. A missing require then stops being the next site's accidental discovery and becomes a defect that can deliberately be detected before the package is delivered.

  1. PHP PHP and Composer: what to check beyond the version number
  2. Symfony Core Two profiles, one contract: testing the boundary of reuse
  3. Vendors & Packages Upgrading a shared capability in two sites one at a time