Skip to content
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

yaf model 的问题 #573

Closed
yunx-lee opened this issue Apr 3, 2022 · 2 comments
Closed

yaf model 的问题 #573

yunx-lee opened this issue Apr 3, 2022 · 2 comments

Comments

@yunx-lee
Copy link

yunx-lee commented Apr 3, 2022

在yaf中,只要是Model结尾的类都会去application/models里去找,这样就会出现一些问题,如下:
在接paypal支付时,paypal SDK里有一些类名是以Model结尾的,如果只是直接在yaf中使用的那个类可以加上 use path/to/paypal/sdk/xxxModel as xxx 这样的显式的别名声明解决,但关键问题是paypal SDK中还有其他类是以Model结尾的,yaf也会去application/models中找,这时就会出现 Warning: Yaf\Loader::autoload(): Failed opening script /webroot/xxx/application/models/XXX/XXX.php: No such file or directory

@yunx-lee
Copy link
Author

yunx-lee commented Apr 3, 2022

尽管通过 yaf.name_suffix 可以配置把 Model 前置,但也是治标不治本,我们不能保证没有其他类名以Model开头的
同理,由于yaf默认 controller action model plugin 这些后缀的类名都会到application下去找,所以,这几个应该也是有同样问题的

@Sgenmi
Copy link

Sgenmi commented Apr 15, 2022

原始model 是 namespace Model;
前提是你开启了命名空间

/xxx/xxxModel.php 把这个加个命名空间,然后使用 registerNamespace 注册你的命名空间,registerNamespace('\XXX', /path/to/paypal/sdk);
在调用就可以了,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants