3

Anybody knows how to composer install for all subfolders too? Does the composer support it? Now I need to execute this command in each subfolder or add all subfolder's vendor folder to git.

I found solution in Linux: https://www.bram.us/2014/02/16/installing-dependencies-in-all-subfolder-organised-projects/

But how to do the same in Windows?

Example.

I have a project in C:\grav with composer.json in it. But also I have plugins folder C:\grav\user\plugins with composer.json in some of subfolders:

enter image description here

I want to execute composer install in C:\grav to install all dependencies in each C:\grav\user\plugins\* too.

5
  • When you run composer install or composer require it will scan through your dependencies and install them all in vendor there is no need to run composer install in each directory. Commented Mar 1, 2016 at 2:14
  • 1
    If you do need to run a script (any script) in a sub folder you can make use of composer's script hook—manual Commented Mar 1, 2016 at 2:16
  • @Michael I mean I have composer.json in root and in each subfolder. Commented Mar 1, 2016 at 2:16
  • Please update your question with an example. You don't need to run composer install on vendor-folders Commented Mar 1, 2016 at 2:17
  • @Michael Example added. Commented Mar 1, 2016 at 2:30

1 Answer 1

2

Grav plugin or theme

In order to support the correct installation folders for Grav plugins and themes, you would need to add the composer/installers to the require section of your plugins.

Normally the plugins would land in the vendor folder, too - but, the Grav Installer tells Composer the correct position inside a Grav project, see see https://github.com/composer/installers/blob/master/src/Composer/Installers/GravInstaller.php#L6

So, when writing plugins or themes for grav each composer.json must indicate the type as grav-plugin or grav-theme, else Composer can't match the package to the installer.

{ "name": "your/some-grav-plugin", "type": "grav-plugin", "require": { "composer/installers": "^1.0.23" } } 

Grav main project

Now, in your main grav project's composer.json, just add the plugins.

Then run composer install. That means the package is fetched, the composer installer is fetched, based on the package type the matching installer is triggered and the grav installer drops the file into the correct folder....


But how to do the same in Windows?

Uhm... Composer works cross-platform. Not a problem.

Sign up to request clarification or add additional context in comments.

2 Comments

So I need to add type: grav-plugin and composer/installers to all my plugin's composer.json? Also can you add main project composer.json example? Thx!
Yes, when you add the type and composer/installers, then all grav plugins and themes will be automatically identified and installed in the right folders. | Adding an example for main composer.json? There isn't much to show.. you basically add the plugins to the require section. That's it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.