adachsoft / release-validator-packagist-checks
Release-validator checks verifying a package's state in the Packagist registry (version presence, SemVer freshness) before publishing.
Package info
gitlab.com/a.adach/release-validator-packagist-checks
pkg:composer/adachsoft/release-validator-packagist-checks
Requires
- php: ^8.3
- adachsoft/collection: ^3.0
- adachsoft/packagist-api-client: ^1.0
- adachsoft/release-validator: ^0.5
Requires (Dev)
- adachsoft/php-code-style: ^0.7
- friendsofphp/php-cs-fixer: ^3.95
- phpstan/phpstan: ^2.2
- phpunit/phpunit: ^13.2
- rector/rector: ^2.5
- symplify/phpstan-rules: ^14.12
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Release Validator Packagist Checks provides release validators for Composer packages published on Packagist.
Features
- Verify that a release version does not already exist in the Packagist registry.
- Verify that a release version is newer than the latest semantic version registered on Packagist.
- Resolve the Composer package name automatically from
composer.json. - Configure a static package name when the repository path does not contain the package metadata.
- Integrate Packagist checks with the
adachsoft/release-validatorvalidation workflow before publishing a release.
Installation
composer require adachsoft/release-validator-packagist-checks
Usage
Create the standard Packagist validator collection with a Packagist API client:
use AdachSoft\ReleaseValidatorPackagistChecks\Factory\PackagistValidatorFactory;
$validators = PackagistValidatorFactory::createValidators($packagistApiClient);
By default, the factory uses ComposerJsonPackageNameResolver, which reads the package name from the composer.json file in the repository path provided by the release validation context.
When the package name should be configured explicitly, provide a StaticPackageNameResolver:
use AdachSoft\ReleaseValidatorPackagistChecks\Factory\PackagistValidatorFactory;
use AdachSoft\ReleaseValidatorPackagistChecks\Resolver\StaticPackageNameResolver;
$validators = PackagistValidatorFactory::createValidators(
$packagistApiClient,
new StaticPackageNameResolver('vendor/package'),
);
Custom resolvers can implement PackageNameResolverInterface and be passed as the second argument to the factory.
Validators
The package includes the following validators:
RegistryVersionDoesNotExistValidator— verifies that the release version is not already registered on Packagist.VersionIsNewerThanLatestValidator— verifies that the release version is newer than the latest registered semantic version.
Both validators use adachsoft/packagist-api-client and implement the standard ReleaseValidatorInterface contract from adachsoft/release-validator. They are intended to run before creating a Git tag and before publishing the package to Packagist.
The validators require a PackageNameResolverInterface implementation. Use PackagistValidatorFactory for the standard configuration, or instantiate the validators directly when custom wiring is required.
Package Name Resolvers
ComposerJsonPackageNameResolverreads and validates thenamefield fromcomposer.json.StaticPackageNameResolverreturns a configured package name invendor/packageformat.PackageNameResolverInterfacedefines the resolver contract for custom implementations.
Requirements
- PHP 8.3 or newer
- A valid Composer package name in
vendor/packageformat - Network access to the Packagist API when validations are executed
License
This package is released under the MIT License. See the LICENSE file for details.