block34 Posted June 22, 2022 Share Posted June 22, 2022 $ cat .composer/config.json { "repositories": { "a": { "type": "path", "url": "repo/a" }, "b": { "type": "path", "url": "repo/b" }, "c": { "type": "path", "url": "repo/c" } } } $ cat repo/a/composer.json { "name": "my/a", "require": { "my/b": "dev-master" } } $ cat repo/b/composer.json { "name": "my/b", "require": { "my/c": "dev-master" } } $ cat repo/c/composer.json { "name": "my/c" } How do you see my/a requires my/b my/b requires my/c But I wanted to know if there is a way to view *quickly* the whole structure of dependences. Above all, I would like to know the *dependents*. I tried like this $ COMPOSER_HOME=.composer composer show -a my/b No composer.json found in the current directory, showing available packages from a, b, c, packagist.org name : my/b descrip. : keywords : versions : dev-master type : library homepage : source : [] dist : [path] repo/b 6de0f9e677dcab7051f94dbbf05893d0165bb826 names : my/b requires my/c dev-master In summary $ COMPOSER_HOME=.composer composer show -a my/b \ | grep my/ No composer.json found in the current directory, showing available packages from a, b, c, packagist.org name : my/b names : my/b my/c dev-master It tell me that my/b requires my/c but it doesn't tell me that my/b is required from my/a (this is the thing that interests me most). For example, if I have to remove a package (obsolete package), how can I verify that it does not have dependents? Quote Link to comment https://forums.phpfreaks.com/topic/314954-composer-dependences-and-dependents/ Share on other sites More sharing options...
kicken Posted June 22, 2022 Share Posted June 22, 2022 Use the -t option to get a tree view of your packages. $ composer show -t my/a dev-master └──my/b dev-master └──my/c dev-master Quote Link to comment https://forums.phpfreaks.com/topic/314954-composer-dependences-and-dependents/#findComment-1597554 Share on other sites More sharing options...
block34 Posted June 23, 2022 Author Share Posted June 23, 2022 $ COMPOSER_HOME=.composer composer show -t Composer could not find a composer.json file To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section compose Quote Link to comment https://forums.phpfreaks.com/topic/314954-composer-dependences-and-dependents/#findComment-1597567 Share on other sites More sharing options...
kicken Posted June 23, 2022 Share Posted June 23, 2022 As it says in the error, you need to create a composer.json file that contains the details for your project, including what it requires. For example: { "require": { "my/a": "dev-master" } } I suggest you read through that Getting Started section as was advised. Quote Link to comment https://forums.phpfreaks.com/topic/314954-composer-dependences-and-dependents/#findComment-1597586 Share on other sites More sharing options...
block34 Posted June 24, 2022 Author Share Posted June 24, 2022 Why should require my/a package? I don't want to request/download/install anything. Let's pretend I don't know anything. Let's pretend I only know that the my/b package exists (I don't want to request/download/install). Let's pretend I just want to know which packages use the my/b package. Can it be? Quote Link to comment https://forums.phpfreaks.com/topic/314954-composer-dependences-and-dependents/#findComment-1597602 Share on other sites More sharing options...
kicken Posted June 24, 2022 Share Posted June 24, 2022 You need to download dependencies to analyze them, since what dependencies you get can depend on the environment you're project is installed into. So you need to start with a project that requires packages that you want. Trying to analyze dependencies without a project doesn't really make sense. If for some reason you don't want to make a project but want to know what packages my/b depends on, you can download my/b and run composer show -t within it's directory. Every package is a composer project with it's own composer.json that defines it's details. There's no way at all to get a list of which packages are dependent on my/b since doing so would require scanning every project ever created by every person on the planet. Quote Link to comment https://forums.phpfreaks.com/topic/314954-composer-dependences-and-dependents/#findComment-1597603 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.