-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
About PHP 5.5 Trait #75
Comments
加载和 Trait没关系..只要你的加载规则没问题就行.. |
我是想把Trait按规则放到单独的文件里面. 不用include 神马的, 直接就可以use了. |
可以了, 没有registerLocalNameSpace ... Sorry, 没仔细研究就发问了. |
这个问题很好,哈哈 |
好多年过去了, 鸟哥最近频繁出没, 重新提一下这个需求,这样就能不用spl_autoload了。 <?php
spl_autoload_register(function($traitName) {
$fileName = APP_PATH.'traits/' . $traitName . '.php';
if (file_exists($fileName)) {
include_once $fileName;
}
});
final class Test_Controller extends Yaf_Controller{
use Mds;
...
} |
你可以通过registerNamespace(“类名前缀”, “路径“)来加载啊 |
3.2版本 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
鸟哥. 好.
我想在PHP5.5下使用 Trait, Yaf 能自动载入 包含Trait 的文件么? 就像 Model,或者 Lib 一样?
如果能, 请问怎么设置
如果不能, 请问是否会增加这样特性?
谢谢.
The text was updated successfully, but these errors were encountered: