Publish Composer Packages
Unlike other repositoriy types, there are no tools that let you publish packages to a Composer repository directly. Instead, a Composer repositoriy gets packages from a VCS repository. This could be a:
Alternatively, you can upload packages as .zip files.
- How to update Composer packages
Typically, when you push a change to the Git repository with the package source code, a Composer repository automatically updates the corresponding package. If the change was made in a new branch, a new package version will be created.
The package versioning works with the help of Git tags: You should mark a corresponding commit with a tag and push the commit including the tag to the Git repository. The Composer repository will create a new package version matching the tag.
Publishing Composer packages from a Space Git repository
Make sure your PHP library is prepared for distribution – your PHP project has a valid
composer.json
file. The project is stored in a Space Git repository.In Space, open the repository page and click Submit Composer Packages.
Choose Space Repository.
Choose the project and the Git repository that will be the package source.
In Branch specification, specify filters for branches and tags. Each filter must start with a
+
character. For example,+:refs/heads/*
.The Composer repository will watch for branches and tags that match the filters:
If a user pushes a commit to a new branch that matches the filter (or the commit is marked with a new tag that mathes the filter), the Composer repository will create a new package version.
If a user pushes a commit to an existing branch that matches the filter (or the commit is marked with an existing tag), the Composer repository will update the existing package (Immutable package versions must be disabled for the repository).
Click Create. Space will connect to the Git repository and get package data.
Publishing Composer packages from an external Git repository
Make sure your PHP library is prepared for distribution – your PHP project has a valid
composer.json
file. The project is stored in a Git repository.In Space, open the repository page and click Submit Composer Packages.
Choose External Mirror.
In Repository name, specify a name for the remote repository (this name will be shown in the list of Composer repository connections).
In Remote repository URL, specify the URL of the external Git repository.
Choose how the Composer repository should get updates from the external Git repository:
Check remote repository periodically: the Composer repository will sync with the Git repository approximately once an hour. Actual update frequency may vary as it depends on server load.
Check remote repository on fetch: the Composer repository will sync with the Git repository every time someone runs
git fetch
for a Git repository mirror.
In Git refspec, specify filters for branches and tags. Each filter must start with a
+
character. For example,+:refs/heads/*
.The Composer repository will watch for branches and tags that match the filters:
If a user pushes a commit to a new branch that matches the filter (or the commit is marked with a new tag that mathes the filter), the Composer repository will create a new package version.
If a user pushes a commit to an existing branch that matches the filter (or the commit is marked with an existing tag), the Composer repository will update the existing package (Immutable package versions must be disabled for the repository).
In Authentication, specify the credentials required to access the remote repository. Depending on remote repository access rules, you might need to provide either an SSH key or your username/password. Choose Anonymous if no credentials are required.
Click Create. Space will connect to the Git repository and get package data.
Note that this not only creates connection to the Git repository, but also creates a Git repo mirror in Space. This mirror is added to the list of project Repositories.
Publishing Composer packages from a GitHub repository
Make sure your PHP library is prepared for distribution – your PHP project has a valid
composer.json
file. The project is stored in a GitHub repository.In Space, open the repository page and click Submit Composer Packages.
Choose GitHub Mirror.
In Repository name, specify a name for the GitHub repository (this name will be shown in the list of Composer repository connections).
In GitHub repository URL, specify the repository URL.
Choose how the Composer repository should get updates from the GitHub repository:
Check remote repository periodically: the Composer repository will sync with the Git repository approximately once an hour. Actual update frequency may vary as it depends on server load.
Check remote repository on fetch: the Composer repository will sync with the Git repository every time someone runs
git fetch
for a GitHub repository mirror.
In Git refspec, specify filters for branches and tags. Each filter must start with a
+
character. For example,+:refs/heads/*
.The Composer repository will watch for branches and tags that match the filters:
If a user pushes a commit to a new branch that matches the filter (or the commit is marked with a new tag that mathes the filter), the Composer repository will create a new package version.
If a user pushes a commit to an existing branch that matches the filter (or the commit is marked with an existing tag), the Composer repository will update the existing package (Immutable package versions must be disabled for the repository).
In Authentication, specify the credentials required to access the remote GitHub repository. Depending on your GitHub repository access rules, You can provide either your GitHub tocken or your username/password.
Click Create. Space will connect to the Git repository and get package data.
Note that this not only creates connection to the GitHub repository, but also creates a GitHub repo mirror in Space. This mirror is added to the list of project Repositories.
Uploading a Composer package as a .zip file
In Space, open the repository page and click Submit Composer Packages.
Choose Upload Files and specify the path to the
.zip
file with the package on your local machine.