D'oh! I'm sorry to have caused more confusion than anything else, let's try
and sort things out.

* why are there similar but different PSRs concerning paths and namespaces?
>

PSR-4 is an addition to PSR-0, and allows flatter directory structures.




> * what sis a "vendor specific prefix"?  In my case I am writing the app, so
> there is no 3rd party vendor.
>

A vendor prefix is just a namespace. While it is enforced by the mentioned
PSR standards, it's not actually mandatory to make a ZF2 application or
module work;
E.g. a common approach found in ZendSkeletonApplication is to have a main
'Application' module without any vendor prefix. That can lead to develop
additional modules also without any prefix, which will become inconvenient
when you'll want to move those modules outside the original application and
reuse them across other ones.
So, I would strongly suggest to consistently use a vendor prefix namespace,
because your present self may become a 3rd party vendor of your future
self. :P




> * why is your 'Prefix' equals '/src'?  I thought a 'Prefix' is a
> descriptive
> name for a 3rd party module like '/vendor/ZfcUser/..'
>

Sorry, i made the example quite unclear.
By 'Prefix' => '/src' that I meant that, in the example, the autoloader is
configured to search classes with the 'Prefix' vendor namespace in the
'/src' path.
I.e. in composer.json you would have the following lines:

{
    "autoload" : {
        "psr-4": {
            "Prefix\\": "src/",
        }
    },
}



> * What is a Prefix?  Is that a namespace?  no... what's it for?
>

Yep, it is the vendor prefix namespace in the example.




> So far I am thinking that I will put my classes into `module/Device`
> folder,
> but I am so confused right now I don't know what to do..  I might just
> leave
> it in 'module/Device/src/Device/Entity' like I have now, because when it
> will come for porting to ZF2, I will have my structure already in place.
>
> I am not having a clear understanding on PSR-0, PSR-4 and which one to use
> and why.
>
>
take a look at this:
https://github.com/php-fig/fig-standards/blob/master/proposed/psr-4-autoloader/psr-4-autoloader-meta.md

tl;dr:
There is no reason not to use PSR-4 because it's backward compatible (not
counting the old php 5.2 underscore notation, which is not supported any
more).
If you want a 1:1 class-to-path map you'll want to use PSR-0 structure, if
you want flatter directory trees you'll want to use PSR-4 structure.
Both cases can be handled by a PSR-4 compliant autoloader.

Cheers.

Reply via email to