New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to create project in current (Existing) directory just like Django does #98

Closed
felipsmartins opened this Issue Jan 18, 2015 · 17 comments

Comments

Projects
None yet
7 participants
@felipsmartins

felipsmartins commented Jan 18, 2015

Currently, Symfony installer version 0.5.0 not allow to create project in a current directory.
It would be nice this feature, just like django-admin (from Django framwork) does:

~$ django-admin.py startproject  <projectname> [destination]

Where destination is a optional path to install in. Using ‘.’ denotes the current working directory.
It would be:

~$ symfony new  <projectname> [destination] [version]

It would be too useful, for instance, when creating project from openshift where repository directory is created first.

@Pierstoval

This comment has been minimized.

Show comment
Hide comment
@Pierstoval

Pierstoval Jan 18, 2015

Contributor

I think your proposal is quite good.

It then would need to change the actual behavior of the new command and make a difference between the project name and the destination, which will by default be the same as the project name, it may sound good then.

Contributor

Pierstoval commented Jan 18, 2015

I think your proposal is quite good.

It then would need to change the actual behavior of the new command and make a difference between the project name and the destination, which will by default be the same as the project name, it may sound good then.

@javiereguiluz

This comment has been minimized.

Show comment
Hide comment
@javiereguiluz

javiereguiluz Jan 18, 2015

Member

@felipsmartins you can already create the project in any directory, not only in the actual directory where you execute the installer:

$ symfony new my_project
$ symfony new /Users/javier/projects/my_project

The first command will create the project in the same directory as you are, but the second command will always create the project in the given directory.

Member

javiereguiluz commented Jan 18, 2015

@felipsmartins you can already create the project in any directory, not only in the actual directory where you execute the installer:

$ symfony new my_project
$ symfony new /Users/javier/projects/my_project

The first command will create the project in the same directory as you are, but the second command will always create the project in the given directory.

@Pierstoval

This comment has been minimized.

Show comment
Hide comment
@Pierstoval

Pierstoval Jan 18, 2015

Contributor

@javiereguiluz I think what @felipsmartins want is more a command to create project like this:

$ symfony new "my project" ./ 2.6

Which is impossible now. In fact, you must specify a "named" directory in order to create a new app.
In technical terms, developing this kind of feature would need to set a default "project name" , because the actual project name is defined with the directory.

Contributor

Pierstoval commented Jan 18, 2015

@javiereguiluz I think what @felipsmartins want is more a command to create project like this:

$ symfony new "my project" ./ 2.6

Which is impossible now. In fact, you must specify a "named" directory in order to create a new app.
In technical terms, developing this kind of feature would need to set a default "project name" , because the actual project name is defined with the directory.

@javiereguiluz

This comment has been minimized.

Show comment
Hide comment
@javiereguiluz

javiereguiluz Jan 18, 2015

Member

@Pierstoval I understand the problem now. We don't want to add any option to the installer, so what we could do is to check if the directory is actually empty. In that case, we would "overwrite" it because it's safe to do it. Is there any simple PHP function to know if a directory is completely empty of contents?

Member

javiereguiluz commented Jan 18, 2015

@Pierstoval I understand the problem now. We don't want to add any option to the installer, so what we could do is to check if the directory is actually empty. In that case, we would "overwrite" it because it's safe to do it. Is there any simple PHP function to know if a directory is completely empty of contents?

@Pierstoval

This comment has been minimized.

Show comment
Hide comment
@Pierstoval

Pierstoval Jan 18, 2015

Contributor

count(glob($dir.'/*')) === 0 ?
count(scandir($dir)) === 2 ?

Contributor

Pierstoval commented Jan 18, 2015

count(glob($dir.'/*')) === 0 ?
count(scandir($dir)) === 2 ?

@felipsmartins

This comment has been minimized.

Show comment
Hide comment
@felipsmartins

felipsmartins Jan 18, 2015

@Pierstoval Yes, you are right!
@javiereguiluz Would be nice!
But I think that symfony installer could to do somewhat like:

if (is_dir($destination)) {
    if (count(glob("$destination/*"))) {
        echo sprintf('%s is a non empty directory, you sure about to install in?',
             $destination);
    } else {
        //cancel
    }
}

Thus, I can to install symfony inside existing repo, for instance. Okay, thats seems like insane but happens!
It give us better flexibility.

Thanks!

felipsmartins commented Jan 18, 2015

@Pierstoval Yes, you are right!
@javiereguiluz Would be nice!
But I think that symfony installer could to do somewhat like:

if (is_dir($destination)) {
    if (count(glob("$destination/*"))) {
        echo sprintf('%s is a non empty directory, you sure about to install in?',
             $destination);
    } else {
        //cancel
    }
}

Thus, I can to install symfony inside existing repo, for instance. Okay, thats seems like insane but happens!
It give us better flexibility.

Thanks!

@javiereguiluz

This comment has been minimized.

Show comment
Hide comment
@javiereguiluz

javiereguiluz Jan 23, 2015

Member

This has been fixed in #99. I've used the code proposed by @Pierstoval.

@felipsmartins sadly, your proposal about installing Symfony even when the project is not empty couldn't be implemented. This behavior doesn't follow the usual Symfony practices of doing things and, in my opinion, it's extremely dangerous.

Member

javiereguiluz commented Jan 23, 2015

This has been fixed in #99. I've used the code proposed by @Pierstoval.

@felipsmartins sadly, your proposal about installing Symfony even when the project is not empty couldn't be implemented. This behavior doesn't follow the usual Symfony practices of doing things and, in my opinion, it's extremely dangerous.

javiereguiluz added a commit that referenced this issue Jan 28, 2015

feature #99 Allow to install Symfony when the directory exists but it…
…'s empty (javiereguiluz)

This PR was squashed before being merged into the 1.0-dev branch (closes #99).

Discussion
----------

Allow to install Symfony when the directory exists but it's empty

This fixes #98

Commits
-------

a8499ef Allow to install Symfony when the directory exists but it's empty
@ahurt2000

This comment has been minimized.

Show comment
Hide comment
@ahurt2000

ahurt2000 Oct 3, 2015

However, with all due respect, I think that we should not let the installer run out of options for this case.
A project need not start with the installation of the framework, making it possible want to install this in a non-empty folder, for example folder containing .git, docs, etc. Sure you can always install it in another folder, but -
Why not give an option like "--force" or something like that ?. Leaving in the user choose if desired or not overwrite files and folders.

ahurt2000 commented Oct 3, 2015

However, with all due respect, I think that we should not let the installer run out of options for this case.
A project need not start with the installation of the framework, making it possible want to install this in a non-empty folder, for example folder containing .git, docs, etc. Sure you can always install it in another folder, but -
Why not give an option like "--force" or something like that ?. Leaving in the user choose if desired or not overwrite files and folders.

@aaronmu

This comment has been minimized.

Show comment
Hide comment
@aaronmu

aaronmu Jan 18, 2016

Agree with @ahurt2000 that a project doesn't always start with the installation of a framework.

@javiereguiluz why do you consider this to be "extremely dangerous"? How exactly does this conflict with "the usual Symfony" practices?

aaronmu commented Jan 18, 2016

Agree with @ahurt2000 that a project doesn't always start with the installation of a framework.

@javiereguiluz why do you consider this to be "extremely dangerous"? How exactly does this conflict with "the usual Symfony" practices?

@Pierstoval

This comment has been minimized.

Show comment
Hide comment
@Pierstoval

Pierstoval Jan 18, 2016

Contributor

@aaronmu The reason I see is that using a --force option or similar behavior might induce overwriting files you might not want to overwrite. And implementing a "safety" behavior by proposing to overwrite current/all/no files is cumbersome (even if it's feasible).

Contributor

Pierstoval commented Jan 18, 2016

@aaronmu The reason I see is that using a --force option or similar behavior might induce overwriting files you might not want to overwrite. And implementing a "safety" behavior by proposing to overwrite current/all/no files is cumbersome (even if it's feasible).

@javiereguiluz

This comment has been minimized.

Show comment
Hide comment
@javiereguiluz

javiereguiluz Jan 18, 2016

Member

@aaronmu if we add this option and you execute this:

$ symfony new /Users/myname/projects --force

The Symfony Installer will delete all the files of all your projects. We won't add this option because most of the people don't need it and because it opens the door to catastrophic consequences.

Member

javiereguiluz commented Jan 18, 2016

@aaronmu if we add this option and you execute this:

$ symfony new /Users/myname/projects --force

The Symfony Installer will delete all the files of all your projects. We won't add this option because most of the people don't need it and because it opens the door to catastrophic consequences.

@kariae

This comment has been minimized.

Show comment
Hide comment
@kariae

kariae May 11, 2017

@javiereguiluz can the --force only creates the necessary files without deleting the old ones ?
A case where this will be helpful is if your development environment is based on Docker, so in general you'll already your app directory containing some files like Dockerfile ...

kariae commented May 11, 2017

@javiereguiluz can the --force only creates the necessary files without deleting the old ones ?
A case where this will be helpful is if your development environment is based on Docker, so in general you'll already your app directory containing some files like Dockerfile ...

@Pierstoval

This comment has been minimized.

Show comment
Hide comment
@Pierstoval

Pierstoval May 11, 2017

Contributor

@javiereguiluz can the --force only creates the necessary files without deleting the old ones ?

The problem with that is that you can still do symfony new /usr/ --force (or worse, symfony new / --force) and create files in really not wanted places.

For docker, then you just do symfony new sf_app && mv sf_app/* ./ (and don't forget to copy hidden/dot files not touched by mv)

Contributor

Pierstoval commented May 11, 2017

@javiereguiluz can the --force only creates the necessary files without deleting the old ones ?

The problem with that is that you can still do symfony new /usr/ --force (or worse, symfony new / --force) and create files in really not wanted places.

For docker, then you just do symfony new sf_app && mv sf_app/* ./ (and don't forget to copy hidden/dot files not touched by mv)

@kariae

This comment has been minimized.

Show comment
Hide comment
@kariae

kariae May 11, 2017

The problem with that is that you can still do symfony new /usr/ --force (or worse, symfony new / --force) and create files in really not wanted places.

I think that the user can be aware of that, and since the old files (of the application folder) will not be erased, as you said, the worst case he will have Symfony files in his folder.

The solution you proposed for Docker will work, it's actually the one I use today, but it's a little bit twisted.

kariae commented May 11, 2017

The problem with that is that you can still do symfony new /usr/ --force (or worse, symfony new / --force) and create files in really not wanted places.

I think that the user can be aware of that, and since the old files (of the application folder) will not be erased, as you said, the worst case he will have Symfony files in his folder.

The solution you proposed for Docker will work, it's actually the one I use today, but it's a little bit twisted.

@Pierstoval

This comment has been minimized.

Show comment
Hide comment
@Pierstoval

Pierstoval May 11, 2017

Contributor

The solution you proposed for Docker will work, it's actually the one I use today, but it's a little bit twisted.

Twisted maybe, but still the most secure way

Contributor

Pierstoval commented May 11, 2017

The solution you proposed for Docker will work, it's actually the one I use today, but it's a little bit twisted.

Twisted maybe, but still the most secure way

@MPLLC

This comment has been minimized.

Show comment
Hide comment
@MPLLC

MPLLC Jun 22, 2017

Can #99 be modified to allow for hidden directories, like .git?

MPLLC commented Jun 22, 2017

Can #99 be modified to allow for hidden directories, like .git?

@Pierstoval

This comment has been minimized.

Show comment
Hide comment
@Pierstoval

Pierstoval Jun 23, 2017

Contributor

@MPLLC I think it's a good idea to add .git to "allowed" dirs 😄 Want to make a PR? 😉

Contributor

Pierstoval commented Jun 23, 2017

@MPLLC I think it's a good idea to add .git to "allowed" dirs 😄 Want to make a PR? 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment