Closed Leprechaunz closed 6 years ago
Actually, in looking at the PSR-2 spec a little more closely, it looks like we're not perfectly following it yet with this PR -- mostly with the brackets for functions/classes. That's OK -- go ahead and leave the changes you did make towards PSR-2 compliance in, and I can file a code improvement issue for full PSR-2 compliance when this PR is merged. 😄
Oh. I just realized why you would suggest capitalizing the yamf/**models**
folder. Then you don't have to add more to the composer.json
autoload, and moreso for subfolders if the user adds them to the Controllers
or Models
folders. I misunderstood.
However, it looks like a use
statement is not case sensitive. use Yamf\Models\ErrorMessage;
works just as well as use Yamf\models\ErrorMessage;
. So, in theory, couldn't we just capitalize Yamf/Models
without actually changing the folder name? Am I doing something else wrong? (It's arguably a bit late and I may not be thinking clearly.)
I see that the way a Laravel app handles it is to keep all the main dir's folders lowercase, and then subfolders can be uppercase. I suppose I would not be opposed to doing it the same way...I was trying to avoid putting controllers/models in an app
folder, though, just so this wasn't like a stripped-down Laravel or somethin'.
It's getting late here (10 PM) so I'll respond with changes you make tomorrow my-time.
OK, yes, clearly I am not thinking clearly. 😓 PSR-4 states:
The subdirectory name MUST match the case of the sub-namespace names.
So, let's capitalize the yamf/Models
directory. I'm sorry, that misunderstanding was my fault. Now for bed so that I CAN think clearly tomorrow 😅.
Thanks @Leprechaunz! I'll work on updating README.md
and a few other things. :)
Description of the pull request
Implemented PSR-4 autoloading #1
Description of tricky code
I tried to make changes related only to PSR-4, but actually touched couple of issues. If it's needed I can revert them.
All classed are now using namespaces and use to import other classes. All autoloading logic is done using composer. If new autoloading rules are needed we can add them to
composer.json
(not forget to regenerate autoloading dump withcomposer dump-autoload
command.Besides this:
.idea
folder to.gitignore
Request $request
for controller methods.ErrorMessage
: $msg was never assigned value