I am creating a custom local plugin and I have a plan to put all the common functions into a trait. And I am using php namespaces inside files. Whenever I create a trait and use it inside a classfile in my class folder it gives me a trait not found error.
The folder structure inside the plugin as below.
- classes
- classes/myclass.php
- db
- lang
- traits
- traits/mytrait.php
Below is how I created my trait.
namespace local_myplugin\traits;
trait mytrait {
public static function abcd() {
echo "HEYY";
}
}
Whenever I use that trait in a class file inside class folder it gives and error saying not found.