(guest@joequery.me)~ $ |

PSR-4 Autoloading example with Composer

So when learning about namespaces, psr-0, psr-4, composer, etc, I honestly didn't really care about anything other than "How can I incorporate namespaces into my code and just start coding?"

I knew why namespaces are useful and important. I didn't care about implementation details. I really just wanted to learn how to use namespaces and start coding!

Apparently that's too much to ask, so after about 5-6 hours of bashing my head against the screen, I got a basic example working.

I'm sharing this example with you so you do not suffer the way I suffered. (I'm kind of dramatic).

Working template

Check out this repo on github:

This repo has a working example of using namespaces with Composer+PSR-4. Now you can stop googling "autoloading" and "psr-4 namespaces" and get back to work.

Tagged as php

Date published - October 27, 2015