Search code examples
phpcomposer-phppackagist

How to rename a PHP package in Packagist


I changed a PHP package name in composer file from "name": "author/author-php" to "name": "author/author" then did composer install & composer update, merged my changes with master then created a release.

But after updating the library on Packagist, the new name did not work and composer could not find it at composer require author/author and I could not even download this new release.

Note: the repo name is still author-php so is this the reason Packagist did not renamed it?


Solution

  • As of now, you cannot update a package name, I believe for security reasons (if renaming was allowed, harmful code could be put as the old name, and then dependent projects that haven't updated their composer.json would pull the harmful code). It has been discussed on Packagist's Github page, and the process in place for this kind of operation is this one (copypasted from the above link) :

    • Update the name in composer.json on the master branch or whatever the default branch is
    • Resubmitting the package to packagist using the new name
    • Mark the old package as "Abandoned" on packagist, and use the new name in the form so that people get pointed to it when they install with the old name
    • And no you can't keep your download stats