[TYPO3-dev] A question about namespaces

Helmut Hummel helmut.hummel at typo3.org
Fri Mar 15 20:05:53 CET 2013


Hi François,

On 15.03.13 19:40, François Suter wrote:

> I'm not entirely sure how many "segments" there can be in the vendor name.

Currently for extensions there can only be one segment for the vendor name.

The rule is \<VendorName>\<ExtensionKey>\<Folder1>\<Folder2>\<ClassName>

While the extension key must be transformed from underscores to upper 
camel case and the folders must reside in a "Classes" folder on the top 
level inside the extension folder and lastly the class file must be 
named exatly like the class (case sensitive!) with a trailing ".php"

For core classes we built in excpetions in many places, so that we coud 
use "TYPO3" as the vendor and "CMS" as the product name, before the 
segment with the extension key starts. This has been done to not have 
conflicting namespaces e.g. for Fluid if we would have skipped the 
product name "CMS"

> Consider one of my extensions, "external_import", and let's say that I
> use my company's name (Cobweb) as a vendor name. Namespaced classes in
> my extension would then be something like:
>
> \Cobweb\ExternalImport\Foo\Bar
>
> Right?

Exactly.


> And we don't need to bother with "tx/Tx" anymore or is that still
> necessary for some parts of the Core?

Nope. Name your class how you like it, be it namespaced or not :)

> And if I have a group of extensions, like Tesseract, comprised of
> "tesseract", "dataquery", "datafilter", etc. Can I use namespaces like:
>
> \Cobweb\Tesseract\Tesseract\Foo\Bar
> \Cobweb\Tesseract\Dataquery\Foo\Bar
> \Cobweb\Tesseract\Datafiler\Foo\Bar
>
> Is that correct?

No. See above. What would work currently is
\Cobweb_Tesseract\Dataquery\Foo\Bar

The plan would be to go with what TYPO3 Flow did for packages.
In Flow package keys also include a namespace path which can be 
separated with a dot (TYPO3.Fluid) also being the folder name for that 
package. With that you could have a package/ extension key 
"Coweb.Tesseract.Dataquery" and the corresponding PHP namespace but 
there are quite some things to change to get that for TYPO3 CMS in the 
future.

Kind regards,
Helmut

-- 
Helmut Hummel
Release Manager TYPO3 6.0
TYPO3 Core Developer, TYPO3 Security Team Member

TYPO3 .... inspiring people to share!
Get involved: typo3.org



More information about the TYPO3-dev mailing list