Home > Enterprise >  create-project in root directory without the project's directory
create-project in root directory without the project's directory

Time:06-03

Say you have this file structure:

/myapp/
/myapp/composer.phar

If you run create-project in the root of /myapp/ e.g., php composer.phar create-project foo/bar

This will create files like this:

/myapp/
/myapp/bar/x.txt
/myapp/bar/y.txt
/myapp/composer.phar

Is it possible to omit the bar directory so that it will look like this?

/myapp/
/myapp/x.txt
/myapp/y.txt
/myapp/composer.phar

I understand that I could simply move up one directory before running the command, however I am using Vagrant/Docker and it will be simpler if the above is possible.

CodePudding user response:

As they say "When everything else fail, RTFM" :), so:

$ composer create-project --help

and you see that we got something interested here:

Usage:
create-project [options] [--] [<package>] [<directory>] [<version>]

Arguments are optional (which you exercise) but not useless therefore for all non explicitly provided arguments, Composer will provide some defaults/fallback on its own. This also includes <directory> which will be then "derived" from <package> name. To solve your problem you just need to tell Composer what directory your want it to use which, and if that's should be your current working directory, simply pass . (dot), which in U*ix world means "current directory":

$ composer create-project some/package .

and you should be good.

  • Related