php-maven / maven-php-plugin

A maven plugin for dependency management and quality assurance for PHP projects.
http://www.php-maven.org/
Apache License 2.0
37 stars 29 forks source link

Project directory structure #11

Closed achingbrain closed 12 years ago

achingbrain commented 12 years ago

This is not a bug, more of a query about the directory structure generated by the archetype.

I notice that you've placed the webapp folder under the php folder like so:

/src/main/php/lib/org... /src/main/php/webapp

Maybe it's because I've used maven to build Java webapps a lot, but I would have expected to see:

/src/main/php/org... /src/main/webapp

Similarly, the placement of CSS and JavaScript files under /src/main/resources seems a little odd as the contents of /src/main/resources would usually get put somewhere the app could reach them but a web browser could not (and optionally with maven variable substitution performed on them) whereas you (probably) want the browser to be able to download jQuery and (probably) don't want to be monkeying around with the contents of the file as it's a library.

Anyway, like I say - not a bug; I just found it a little surprising.

mepeisen commented 12 years ago

Most php applications at least contain php scripts as part of the webapp folder. For example many frameworks at least require a small bootstrap "index.php" all requests are mapped to. Putting that small bootstrap as part of the resources folder will break validation (lint check and others).

We will review this topic in version 2.1 It is becoming more complex to tell maven and therefor php-maven what a project is made of. Java web apps mostly match the JSR standards and expected to build a WAR. This WAR is very clear meaning: Do not put java code into webapps, only do put html files, resources and jsp pages into webapps folder. In PHP we do not have such a standard. At least PHP is always some kind of mixture of various test and binary files. Many frameworks introduce their own directory structure solving this issue. But this may lead to incombatibilities since php-maven should not prefer f.e. zend frameworks directory structure. That would break other frameworks support, f.e. flow3 is very different from zend framework.

achingbrain commented 12 years ago

Hmm, problematic. I guess by placing any PHP at all under /src/main/webapp it would be a tacit admission that it's not going to get tested.

You're right - Java webapps do have it easy in that respect as the law was laid down in a JSR. It would be nice if there was some sort of convention but I suppose that's the price you pay for flexibility.

You could always take the directory structure portion of the code and put it in a dependency of the plugin declared "provided", then require that an implementation of the classes in the dependency is declared as a dependency of the plugin in end users' projects, if you see what I mean. That way you could have an implementation for Zend, one for Flow3, etc without mandating the use of any particular one in the plugin. Kind of like how you tell SLF4J which logging framework to use.

mepeisen commented 12 years ago

You may have a look at pear and zpk (zend package). They are introducing some description on the packages. These descriptions are saying "this is a php script, this needs to be filtered" etc. For 2.1 I wrote an analysis draft. I am still not focused on this work but maybe you can comment it and maybe we will find a good solution. https://groups.google.com/forum/?fromgroups&hl=de#!topic/maven-for-php/wKzpnAiDT1U

closing, please comment on the google groups :)