Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Where to place traits?
  • If I want to make it loaded by the autoloader, then I would say the classes directory, but traits are not classes, right?
  • Correct.

    And with the current autoloader it's not going to work, because it will do a class_exist() check, which fails on a trait.

    It's probably better to store them somewhere else, like APPPATH.'traits', and use

    \Fuel::load(APPPATH.'traits'.DS.'mytrait.php');
  • Actually it is working for me. The Autoloader finds my trait, and loads it correctly. It is in a module, so I did not add it manually.

    Can't this be part of the core? Of course with PHP version checking.
  • If it works, what do you want to be part of the core?
  • :)

    Well, you said that it is not expected to work. So this could be investigated, and maybe traits could be handled individually in autoloader.
  • That is what I expected. But if you say it works, then no further action is needed?

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion