Composer-Eclipse-Plugin icon indicating copy to clipboard operation
Composer-Eclipse-Plugin copied to clipboard

Provide preferences for default project layout

Open pulse00 opened this issue 12 years ago • 2 comments

e..g what should be the source folder, what the test folder etc.

pulse00 avatar Mar 24 '13 19:03 pulse00

Had an idea last night. Made a mockup:

composer_eclipse_plugin_new_project_wizard_mockup

The idea is to create a group for each folder that might get created and a checkbox to enable it. Each group contains more options about that folder.

Source and Test Folder

For them you enter the path in which they will created and the associated namespace. Additionally select an option how the mapping of the namespace will happen, since psr4 enables shorter paths here but not everybody likes them.

Option 1: Namespace in Path

That's truly the psr4 way. Given path is src/ and namespace is my\name\spacethis will create the following folders: src/ and this autoload:

{
  "autoload": {
    "psr-4": {
      "my\name\space\": "src/"
    }
  }
}

Option 2: Namespace as folders

Create a folder for each namespace segment. Given path is src/ and the namespace is my\name\space this will create the following folders: src/my/name/space/ and this autoload:

{
  "autoload": {
    "psr-4": {
      "my\name\space\": "src/my/name/space/"
    }
  }
}

Option 3: Custom Folder:

Creates the namespace in the given folder. Given path is src/ and the namespace is my\name\space and the given custom folder is custom/ this will create the following folders: src/custom/ and this autoload:

{
  "autoload": {
    "psr-4": {
      "my\name\space\": "src/custom/"
    }
  }
}

Public Folder

The public folder is reserved for frontend files, namely css, javascript, images, etc. What might be of interest is the option to create these folders, too. I imagine the following look:

composer_eclipse_plugin_new_project_wizard_public_folder_mockup

Preprocessors

Since preprocessors (less/sass/coffeescript/...) are more and more common, might also be interessting to integrate them as well. See my new plugin in development: gossi/eclipse-transpiler-plugin That's far future for sure.

Template Folder

Not regarded in the mockup above, however a folder where template files are stored (twig/smarty/etc.).

Configuration

In the configuration the default options can be set and are automatically checked/selected in the wizard. These options are:

  • Default src folder (src/ will be prefilled)
  • Default test folder (tests/ will be prefilled)
  • Source folder creation (Option 1 or Option 2)
  • Test folder creation (Option 1 or Option 2)
  • (The above options may be munged)
  • Default public folder
  • Default styles/scripts/images folder
  • Default template folder

Open Questions

What should be the default namespace. At the moment it is {vendor}\{project-name} but I'm not happy with that. Especially since there may be dashes in the project name, which is interessting how to transform them.

Option 1: Convert dashes to namespace seperator

Given vendor is acme and project name is foo-bar this will result in namespace acme\foo\bar

Option 2: Dashes to StudlyCaps

Given vendor is acme and project name is foo-bar this will result in namespace Acme\FooBar

StudlyCaps the namespace

This is written in psr-1 as a good practice, however not forced. So keeping everything all in lowercase is fine, too and still psr-1 compatbile (and basically my favorite way of doing it). I think a configuration option to define which behavior to use is fine here. However, how do not StudlyCapsing the namespace and Option 2 (Dashes to StudlyCaps) play well together. Here are some scenarios:

Scenario 1: StudlyCaps namespace is on, Option 1 (from above is selected) vendor is transformed using StudlyCaps, dashes are converted to namespace separator, segments are transformed using StudlyCaps

Scenario 2: StudlyCaps namespace is off, Option 1 (from above is selected) vendor is kept as is, dashes are converted to namespace separator

Scenario 3 and 4 are self-explanatory right now (I really do not want to type them now).

This can end up in a configuration hell. Shrink this down to (1) prefer StudlyCaps and (2) prefer lowercase, which contains the all ideas from above should be suitable and enough.

PS. I hate this. Took me 30 seconds to think about, almost 30 minutes now for the mockups and writing this text and another 30 hours to implement :smiley:

gossi

gossi avatar Feb 05 '14 16:02 gossi

PS. I hate this. Took me 30 seconds to think about, almost 30 minutes now for the mockups and writing this text and another 30 hours to implement

don't forget the time to deploy and test on various eclipse versions ;)

pulse00 avatar Feb 05 '14 16:02 pulse00