I AM LISTENING TO
|

WHAT I LIKE

Clean up your toolbox with PHP traits … portalZINE.TV cleanup started
Development     PHP    

Register classes and traits for autoloading



16. March 2015

When projects are getting bigger, its always nice to split things up and prepare parts of your code for general reuse.

PHP Traits (PHP 5.4+) are a nice way to do this. Adding multiple Traits or classes, requires you to make sure all are being included.

Here is a nice way to register both with the __autoload function

Traits are loaded when you specify their use in a class.

 

 




Leave a Reply

Be the First to Comment!

Notify of
avatar
wpDiscuz