How to rename a PHP package in Packagist - php

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?

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

Related

Why "composer.json" is not updated when updating packages?

Comparing to other package managers like npm, I find that composer has a strange behaviour when updating packages related to a given project.
According also to the documentation, update and upgrade options
Upgrades your dependencies to the latest version according to composer.json, and updates the composer.lock file.
And indeed, composer.lock is correctly updated with new packages version numbers. But composer.json instead is not modified, and lists packages with their old, outdated version numbers.
Why does this happen? Am I doing something wrong, or this is indeed how this is supposed to work? And if this is the case, what is the reasoning behind having one of thw two files up-to-date while the other is not?
That's the normal behavior.
Composer update looks for updates based on your composer.json file, so here it will look for 4.2 and above (^4.2)
If you want your composer.json to require 4.3 and above (^4.3), you can either modify it manually or call composer require once again.

Composer error on installing to phpBB

I want to start making my own mods for PHPBB however I am having trouble setting up composer.
I have installed composer to my windows server and I run this in my command line
composer require :
C:\Inetpub\vhosts\Servers\5\localuser\gorrors\httpdocs\community
and I get this error:
"`UnexpectedValueExpection`" cannot parse version.
When googling this error message everyone else seems to fix the error by running selfupdate however when I do this it says I have the latest version?
What am I doing wrong? Any help would be great
Seems that you are using the require command wrong here. It is used to add a specified package to the composer.json file as one that your project depends on.
As for the expected package name... From the manual:
The package name consists of a vendor name and the project's name. Often these will be identical - the vendor name just exists to prevent naming clashes. It allows two different people to create a library named json, which would then just be named igorw/json and seldaek/json.
After specifying dependencies you can perform composer install, which will search for the packages from the set up repositories. Note that:
By default only the Packagist repository is registered in Composer. You can add more repositories to your project by declaring them in composer.json.

How to manage github repository dependencies while and after contributing to them?

I'm using Symfony2 and for my projects I normally do composer require name/repository which will install the repository in the vendor folder and add a line in the composer.json including the package and the installed version.
Supposing that I fork a project because I want to add something to it or fix a bug and use it in my Symfony app, I'd have to run composer require myname/repository, modify it, test it and then submit a pull request. Afterwards, after the pull has been commit to the original repository, I'll have to delete my own and remove it from composer.json and reinstall the original repository.
Is there a better workflow to this that doesn't have to change the json file that much?

How Composer handles local changes

Suppose I install package for CKEditor through Composer and manually add new skins and plugins to it. How Composer will handle this, when next update to base package will be released?
Will it overwrite entire package directory (deleting local changes) or update only listed files?
Also, I'm having problems updating one package to newest version and made that update locally, manually. Yet, composer status shows No local changes. Does this mean, that Composer itself does not check contents of each package's folder for local changes, only operates on differences between composer.json and composer.lock?
Composer will updated to newest version matched to version what you've added in composer.json and yes - it will overwrite existing package (including all of yours changes) but it will omit files which not exist in packages.
Command: "composer status" shows all changes in files what belongs to specified package. If you will change some file then it will be shown in that list, but if you will add a new one then of course not.
Generally, your approach might work in some cases but I strongly DO NOT recommend it. Problem will be when you create some file, and then will be added into package (for example in newer version).
You should just use all packages "as is" directly in your application, and within it add new stuff, or another configuration, etc.
Will it overwrite entire package directory (deleting local changes) or update only listed files?
Yes. When updating a package Composer removes the current version of the package and installs the new one.
Also, I'm having problems updating one package to newest version and made that update locally, manually. Yet, composer status shows No local changes. Does this mean, that Composer itself does not check contents of each package's folder for local changes, only operates on differences between composer.json and composer.lock?
The 1.* part in your composer.json tells Composer to only update when there is a new release available in the 1.* version range. New commits are not a new release. A new update will be available when the package owner creates a new release with a higher version number. If you want to update after each new commit you should change "1.*" to "dev-master".

Download a repository in Github along with composer packages

Without using Composer, is it possible to download a repository in Github along with it's defined composer packages?
For example: FluxBB 2 requires Laravel 4.
I was hoping to download FluxBB and at the same time the packages of Laravel 4 without using Composer.
Usually projects that use composer will ignore 3rd party components. In .gitignore you will see /vendor. This is the place where Composer downloads its dependencies.
This will find the latest version of monolog/monolog that matches the supplied version constraint and download it into the vendor directory. It's a convention to put third party code into a directory named vendor. In case of monolog it will put it into vendor/monolog/monolog.
Tip: If you are using git for your project, you probably want to add vendor into your .gitignore. You really don't want to add all of that code to your repository.
http://getcomposer.org/doc/01-basic-usage.md#installing-dependencies
Doing it manually is a bit of a hassle. Composer uses packagist to get its files (if you look at a package it has a source added to it Laravel https://packagist.org/packages/laravel/framework).
Composer auto loads the needed files automatically so its a big time saver.
For libraries that specify autoload information, Composer generates a vendor/autoload.php file. You can simply include this file and you will get autoloading for free.
require 'vendor/autoload.php';
This makes it really easy to use third party code. For example: If
your project depends on monolog, you can just start using classes from
it, and they will be autoloaded.
http://getcomposer.org/doc/01-basic-usage.md#autoloading

Categories