Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
General
Where to place traits?
sagikazarmark
November 2013
If I want to make it loaded by the autoloader, then I would say the classes directory, but traits are not classes, right?
Harro
November 2013
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');
sagikazarmark
November 2013
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.
Harro
November 2013
If it works, what do you want to be part of the core?
sagikazarmark
November 2013
:)
Well, you said that it is not expected to work. So this could be investigated, and maybe traits could be handled individually in autoloader.
Harro
November 2013
That is what I expected. But if you say it works, then no further action is needed?
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,088
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
260
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
Harro
November 2013
sagikazarmark
November 2013