Task #7243

let's use UpperCamelCase filenames for templates as well

Added by Felix Oertel over 5 years ago. Updated almost 5 years ago.

Status:Resolved Start date:2010-04-13
Priority:Must have Due date:2010-06-18
Assigned To:Bastian Waidelich % Done:

100%

Category:Core
Target version:1.0.0 alpha 9
Has patch:

Description

hey guys,

please let us stick to lowerCamelCase filenames for templats as we do for all the other files as well.

at the moment you have to use lowercasefilenames which look kind of ugly. on some systems (like my osx) you will never experience this "problem", because filesystem is case-intensitive ... things look different if your on BSD e. g.

regards, foertel

fluid_lowerCamelCase_patch.diff Magnifier - remove strtolower() from templateView class (498 Bytes) Felix Oertel, 2010-04-13 23:00


Related issues

duplicated by TYPO3.Fluid - Bug #6298: action gets converted to lowercase Resolved 2010-02-01

Associated revisions

Revision 32ff28be
Added by Robert Lemke about 5 years ago

[+BUGFIX] FLOW3 (Configuration): The ConfigurationManager now checks if the option "uriPattern" has been set. Fixes #7820
[~TASK] FLOW3 (Error): The var_dump debugger now displays more information about objects implementing ArrayAccess
[+BUGFIX] FLOW3 (MVC): The Router now uses strong comparison for checking the match results of routes. Fixes #7831
[~TASK][!!!] Fluid (View): The TemplateView now expects all template files to be UpperCamelCase as this is the general convention for filenames in FLOW3. Make sure to update the case of your template filenames! Resolves #7243

History

#1 Updated by Robert Lemke about 5 years ago

  • Status changed from New to Accepted
  • Assigned To set to Robert Lemke
  • Target version set to 1.0.0 alpha 9

In FLOW3 the convention is: Filenames are UpperCamelCase. Although it might feel more natural to use lowerCamelCase for HTML files (because action method names are lower camel case), it is easier and more consistent to have one rule for all.

#2 Updated by Robert Lemke about 5 years ago

  • Tracker changed from Bug to Task

#3 Updated by Robert Lemke about 5 years ago

  • Status changed from Accepted to Resolved
  • % Done changed from 0 to 100

Applied in changeset r4321.

#4 Updated by Sebastian Kurfuerst about 5 years ago

  • Status changed from Resolved to Needs Feedback
  • % Done changed from 100 to 80

Hi Robert,

I just looked at the current solution, and unfortunately I think this does not resolve the problem.

Issue: let's say the action is called "myFoo", but the user calls the action "myfoo" (with different spelling). Then, inside the ActionController, inside resolveAction(), it is correctly figured out which action to call. However, the correctly spelled Action name is only stored inside $this->actionMethodName, not inside the request object.
This means, that Fluid will use the submitted action name (in the above case "myfoo") to resolve the Template -- which of course results in an error.
So, to fix this, we'd need to store the real action name back into the request.

Additionally, you are now using UpperCamelCase for the filenames -- which I think is totally inconsistent and counter-intuitive. I'd opt in to spell templates in the file system exactly like the action method is called, so lowerCamelCase.

Do you agree with my suggestions?

Greets,
Sebastian

#5 Updated by Bastian Waidelich about 5 years ago

Sebastian Kurfuerst wrote:

So, to fix this, we'd need to store the real action name back into the request.

Maybe the router should already check, whether the specified action really exists (and use the next route if it doesn't). Then we could already put the correctly camelcased action name into the request object.
I just don't know if a) we need this, b) this isn't a potential bottleneck

Additionally, you are now using UpperCamelCase for the filenames -- which I think is totally inconsistent and counter-intuitive.

I agree to use lowerCamelCase here

#6 Updated by Sebastian Kurfuerst about 5 years ago

Hey,

Maybe the router should already check, whether the specified action really exists (and use the next route if it doesn't). Then we could already put the correctly camelcased action name into the request object.

Mhm, but the router does not know which action really exists...

I just don't know if a) we need this, b) this isn't a potential bottleneck

Yep. So I'd suggest right now, to do it pragmatically, and update the action name in the request.

Greets,
Sebastian

#7 Updated by Robert Lemke about 5 years ago

  • Status changed from Needs Feedback to Accepted

Hi folks,

yes you're right, I completely messed it up - the unit test works but that's, as you've seen - only half of the story.

I guess we'll go for Bastian's proposal and let the Router already check if an action exists. Currently a route which refers to a specific action would even match if such an action method does not exist - another bad behavior we could solve with this. So in the end the Request will contain a correctly cased action name.

As for the file naming conventions - I know that's a tough decision (well, most people don't think so, of course;-). After thinking about it again and again I think that 1 rule for all is more attractive and intuitive. So, let's go for that - all filenames and directory names are upper camel case.

For sure we'll fix all this before the next alpha release which is currently scheduled for Wednesday next week.

#8 Updated by Sebastian Kurfuerst about 5 years ago

Robert Lemke wrote:

Hi folks,

yes you're right, I completely messed it up - the unit test works but that's, as you've seen - only half of the story.

I guess we'll go for Bastian's proposal and let the Router already check if an action exists. Currently a route which refers to a specific action would even match if such an action method does not exist - another bad behavior we could solve with this. So in the end the Request will contain a correctly cased action name.

Good idea!

As for the file naming conventions - I know that's a tough decision (well, most people don't think so, of course;-). After thinking about it again and again I think that 1 rule for all is more attractive and intuitive. So, let's go for that - all filenames and directory names are upper camel case.

Hmm, ok... I still see that somehow problematic / error-prone. I'm not sure yet how we can easily communicate that the Action names are normally lowerCamelCase, but in the file system, the corresponding templates are UpperCamelCase -- to me, this sounds a bit weird.
However, I could live with it, but as it's quite a severe change in terms of backwards compatibility, Fluid should throw an exception if it detects another capitalization in the directory than the UpperCamelCased version it expects (in Development mode).

For TYPO3 v4, I would not change this behavior right now, but I'd suggest to use a file no matter what the capitalization is -- We cannot introduce such a heavily breaking change without backwards compatibility anymore. (Yep, that's the price of all that backporting ;) )

Greets,
Sebastian

#9 Updated by Sebastian Kurfuerst about 5 years ago

Hey,

I've again thought about this issue, and I still feel that a not-so-strict rule for file names would be better. For the following reason:
A file is an artifact which in FLOW3 often relates to some more abstract concept. For example, a .php file in the Classes/ folder actually is a PHP Class, and that's why the naming conventions for these classes apply in this part of the directory structure.
For actions, I think it is the same. The primary artifact is the action name, and this one is lowerCamelCase (as it is the method name in the ActionController). That's why the file which represents this artifact should have the same casing --> lowerCamelCase.

Sorry to discuss so much about that -- but I'd be interested how you'd explain a new user that actions in the file system are differently written than actions in the ActionController? (i.e., how to explain this in terms of Consistency?)

Greets,
Sebastian

#10 Updated by Christian Müller about 5 years ago

Sebastian Kurfuerst wrote:

Hey,

I've again thought about this issue, and I still feel that a not-so-strict rule for file names would be better. For the following reason:
A file is an artifact which in FLOW3 often relates to some more abstract concept. For example, a .php file in the Classes/ folder actually is a PHP Class, and that's why the naming conventions for these classes apply in this part of the directory structure.
For actions, I think it is the same. The primary artifact is the action name, and this one is lowerCamelCase (as it is the method name in the ActionController). That's why the file which represents this artifact should have the same casing --> lowerCamelCase.

Sorry to discuss so much about that -- but I'd be interested how you'd explain a new user that actions in the file system are differently written than actions in the ActionController? (i.e., how to explain this in terms of Consistency?)

Greets,
Sebastian

Too me it seems both have their pros and cons, none is better. Both are Rules ("It's lowerCamelCase because of the method name in the ActionController" or "All dirs and files are UpperCamelCase") that have to be remembered, for some this is easier to remember for others that. And if I am a FLOW3/Fluid/Extbase dev I should know such rules anyway. Maybe the only point would be that "All dirs and files are UpperCamelCase" is a good naming scheme globally. For non devs both rules are not so intuitive (again a slight + for UpperCamelCase because it is not bound to know the PHP code) and template filenames should be configurable at some point anyway so that I can have a totally different (cased) name for my template (because it might make recognizing the template easier for my HTML guys...).

Christian

#11 Updated by Robert Lemke about 5 years ago

A file is an artifact which in FLOW3 often relates to some more abstract concept. For example, a .php file in the Classes/ folder actually is a PHP Class, and that's why the naming conventions for these classes apply in this part of the directory structure.
For actions, I think it is the same. The primary artifact is the action name, and this one is lowerCamelCase (as it is the method name in the ActionController). That's why the file which represents this artifact should have the same casing --> lowerCamelCase.

The problem with this rule is that you have to know how the case of the artifact is - what about locales? Or images? Stylesheets? You don't have to think about it if you have the one-rules-them-all-rule.

Too me it seems both have their pros and cons, none is better. Both are Rules ("It's lowerCamelCase because of the method name in the ActionController" or "All dirs and files are UpperCamelCase") that have to be remembered, for some this is easier to remember for others that. And if I am a FLOW3/Fluid/Extbase dev I should know such rules anyway. Maybe the only point would be that "All dirs and files are UpperCamelCase" is a good naming scheme globally. For non devs both rules are not so intuitive (again a slight + for UpperCamelCase because it is not bound to know the PHP code) and template filenames should be configurable at some point anyway so that I can have a totally different (cased) name for my template (because it might make recognizing the template easier for my HTML guys...).

Yes, and you can already do that by specifying your own custom template path and filename.

#12 Updated by Robert Lemke about 5 years ago

  • % Done changed from 80 to 90

#13 Updated by Sebastian Kurfuerst about 5 years ago

  • Subject changed from let's use lowerCamelCase filenames for templates as well to let's use UpperCamelCase filenames for templates as well
  • Due date set to 2010-06-18
  • Assigned To changed from Robert Lemke to Bastian Waidelich
  • Priority changed from Should have to Must have

must definitely

#14 Updated by Sebastian Kurfuerst about 5 years ago

  • Status changed from Accepted to Resolved
  • % Done changed from 90 to 100

fixed by Bastian, and committed into Fluid v4 in r2363 and r2364

Also available in: Atom PDF