Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

marbobo's avatar
Level 12

how to composer install on other directory not vendor?

Hi,

How can I install composer packages but not on vendor directory? i have a project that requires me to chagne the vendor folder into something else.

is there a command in which I can install it on vendor and also on ther other directory like prod_vendor or something else?

Edit: Im using composer version 1.10.13

I have tried this one.

php /usr/local/bin/composer install -d /var/www/html/prod_vendor/

but right after running the command I got this error.

Composer could not find a composer.json file in /home/www/project/dist
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
0 likes
14 replies
Snapey's avatar

Thats NOT a good idea

Why would you have such a requirement?

Anyway, your problem is nothing to do with the location of the vendor folder

1 like
marbobo's avatar
Level 12

yes but that is the requirement. i think its about the deployment tool they are using..

marbobo's avatar
Level 12

I also got confuse on this requirements. I never experience this before to change the vendor path :)

Snapey's avatar

it also won't work with a laravel app unless you change the index.php file

require __DIR__.'/../vendor/autoload.php';
1 like
marbobo's avatar
Level 12

yes.. most like that will gonna happen. i hope it works

Snapey's avatar

-d is for setting the working directory not the vendor folder

marbobo's avatar
Level 12

ohhhh thats why it didnt install because the dist directory is fresh and empty. I got the error now. but i wonder if theres a way to put all your files into different path..

martinbean's avatar

@kevdev That’s not how Composer works. Composer stores its dependencies in the vendor directory. End of story.

1 like
dakujem's avatar

@martinbean one can set the vendor-dir option in compoer.json to whatever he likes, even dist

martinbean's avatar

@dakujem Not sure why you’ve gone to the effort of replying to two separate 2-year-old threads with this.

Yes, you can change the vendor directory, but there’s no real reason to.

Snapey's avatar

Perhaps you could show us the exact wording of the requirements?

This is not about developing a package is it?

1 like
marbobo's avatar
Level 12

well the main requirement is to push the vendor directory into the git repo. and at first I dont really like that. i think it is required by the deployment tool and it is not allowed to run composer command on the server.

so i think what if i push a new ("dist") directory containing the composer packages ("without the dev deps") instead of the vendor directory so that I still have my vendor on my local machine being ignore with dev deps.

dakujem's avatar

I know i'm late to the party, but you are probably looking for vendor-dir option in composer.json: https:// getcomposer.org/doc/06-config.md#vendor-dir

jaseofspades88's avatar

In my experience, a 'cut price' hosting solution means you have to jump through these sorts of ridiculous hoops, unnecessarily I might add simply to run and deploy your site.

If you're committing your vendor directory, don't forget to commit your node_modules too, that's what all the really cheap clients do!

Please or to participate in this conversation.