Feature request : Ability to create project in current (Existing) directory. #1135

Closed
purplefish32 opened this Issue Sep 21, 2012 · 27 comments

Projects

None yet

I would really like to be able to override the create-project test that disallows installation if the destination directory exits.

What I am trying to achieve :

php composer.phar create-project symfony/framework-standard-edition . 2.1.1

I am aware that in the documentation it states : "The directory is not allowed to exist, it will be created during installation."

My feature request is to be able to override the test (Something like --force) so that I can install in the current directory where the only other file is composer.phar anyway

Contributor
stof commented Sep 21, 2012

Well, what should it do in such case ? delete the folder first to be able to install the package properly ? Merging existing content with the content of the package is not a safe install.

I don't really think the amount of work for this is worth it.

Btw, git or svn don't allow you to clone to in an existing folder either (which would make the work even harder for us by having to implement some workaround for the GitDownloader and the ZipDownloader btw)

Contributor
cs278 commented Sep 21, 2012

Both git and svn allow you to clone into an existing directory, but it must be empty.

Contributor

I think this might be handy, if allowed only for empty directories.

Contributor
smasty commented Sep 22, 2012

I vote for ability to create a new project in an existing empty directory, the same way as git allows you to.

I would just add : If the only file in the directory is composer.phar then treat the directory as empty

Contributor
stof commented Sep 22, 2012

@purplefish32 why ? It would make it still have the same issue: git and svn don't allow to clone in a non-empty directory, thus requiring to implement some workaround.

@stof Just for the sake of simplicity, I am scripting a custom installer for Symfony and a few bundles via ServerTools (https://github.com/JoshuaEstes/ServerTools), seems logic to me to create a new project folder then the script will pull in composer, set up symfony etc...
Plan B is to set up Symfony in a temp (blank) folder then move everything back

Contributor
stof commented Sep 23, 2012

@purplefish32 but why would you need to put composer in the folder in which the project will be setup ? Couldn't you put it in the parent folder ?

@stof I guess I can live with that

Contributor

And why can't you have composer in system-wide directory? Like /usr/local/bin/composer ?

@HosipLan Allthough this may at first seem to be the ideal solution (It is the one I use when not trying to script installs), I see a few drawbacks when
using this solution from within the app installer.

  1. I don’t want to rely on what the user has already installed or not (composer)
  2. The user may have changed the symlink (comp ...)
  3. Impossible to tell whether the installed version of composer is the latest (App would crash saying composer needs self update)
  4. I much prefer the method used by Capifony/Capistrano for deploying symfony apps : curl the latest version of composer into the current directory

I do understand that Capistrano clones the repo before installing composer via curl and that there must be some issues with
git/svn needing a workaround. I'm just suggesting that if there is a quick and easy hack/workaround to this problem it would be a cool feature to add.

As I said before if this is really too difficult I will stick with my plan B and install via a temp directory.

Contributor

@purplefish32: Imho that's responsibility of system administrator - not programmer.

But I agree this would be neat if allowed for emty directories, ignoring composer.phar file.

Owner
Seldaek commented Sep 26, 2012

It sounds to me like it's not worth the trouble (at least the composer.phar thing, because most likely to allow this we need to rm the dir, chdir to the parent and then run the code), but if someone gets it to work without too much insanity I'm not against it.

@cordoval cordoval added a commit to cordoval/composer that referenced this issue Oct 12, 2012
@bzitzow @cordoval bzitzow + cordoval WIP: [Feature #1135] Util\Filesystem additional methods, unit tests, …
…and update to Composer/Downloader/VcsDownloader.
3735ff8
@cordoval cordoval added a commit to cordoval/composer that referenced this issue Oct 12, 2012
@bzitzow @cordoval bzitzow + cordoval WIP: [Feature #1135] address some comments 392aaea
@cordoval cordoval added a commit to cordoval/composer that referenced this issue Oct 12, 2012
@cordoval cordoval WIP: [Feature #1135] as per stof comment be538ae
jovobe commented Nov 8, 2012

+1

+1

Contributor

thanks guys, eve though authors are not commenting i am positive on this one too, let's work on this on the weekend @bzitzow see you then

Owner
Seldaek commented Nov 14, 2012

As I said before (not sure if it was in person at SfLive SF or here, but whatever) I will accept this as creating a project in an existing empty directory. If it has content, you can't do anything. That's how git & friends work and I think it makes a lot of sense, rm -rf should be able to reverse whatever you did in an easy way, and if we start mixing stuff with existing files that goes against this.

@Seldaek Seldaek closed this in 2a23f8c Mar 1, 2013
@digitalkaoz digitalkaoz pushed a commit to digitalkaoz/composer that referenced this issue Nov 22, 2013
@Seldaek Seldaek Allow create-project to be called in an empty dir that exists, fixes #…
…1135, replaces #1206
3b72076
ph-il commented Jan 14, 2014

@Seldaek I do have a case where it might be very helpfull : I did a composer "project", that will help us to do migration from legacy application. So all old code are moved in a directory call legacy, then we can now call Composer. But for now, I need to create a new project, then copy all files in the old project.

Owner
Seldaek commented Jan 15, 2014

@ph-il that sounds like a pretty temporary use case for a one-time conversion. Not really something I would consider valid in the bigger picture, and anyway this is just not feasible easily due to git constraints etc, so it's very unlikely it will happen.

I found this thread when looking for such a feature.

My case is that I'm starting a new project and I'm using Vagrant. I need a place to put the vagrant files, which i've put in the project root (typical practice, I believe). But after starting Vagrant, which automatically mounts the project folder, I can't create a Symfony project because the folder is already populated with vagrant files.

So I have to install Symfony into it's own folder within the project, which is redundant. It's obviously not the worst thing in the world. It's just extra trouble to achieve the folder structure I had in mind.

MickL commented Oct 12, 2014

Also i create an emtpy project with PHPStorm. I want to install Symfony2 within PHPStorm terminal but it says directory already exists. So i have to create it into a new folder and copy the content into the root.

I would be cool to have a --force command.

+1

Contributor

👍

Chiliec commented Nov 19, 2014

+1

I was searching for this feature as well. Although using git clone to current directory works, it would by nice if composer itself supported it.

👍

@Seldaek Seldaek locked and limited conversation to collaborators Dec 1, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.