Comments (7)
+1 for the namespace, although i dont know if this has any conflict with routes.
from yaf.
hmm, PHP implemented namespace in a very tricky way, that is, if you define a class Foo in a Namespace Bar, the really class name is 'Bar\Foo",
in the opinion of Yaf loader, it equal to class Bar_Foo, so if we supports namespace in module, how can the Yaf Loader tell controller A in module B (B_A) from the ctronller B_A?
from yaf.
I think in modules controller's name must be like Bar\Foo or Bar_Foo (if namespaces is off). Routes definitions can look this same, because we can get namespace from module name. Only problem is not backward-compatible, but in this form modules don't work correctly.
So to answer your question, Yaf loader know it is namespaces on or off (from php.ini), know what module it is from routes or default route like /module/controller/action so Loader can load good controller. But this is only a suggestion there may be a better solution.
from yaf.
hmm, php.ini is a way(bc), let me think about it. thanks
from yaf.
There is an issue in the current implementation of modules. Controllers in a module can have the same name with controllers in another module. So Yaf loader can not load the right controller, in some cases (forwarding, extending).
Defining a module as a namespace then may partial solve the problem.
Assuming the controllers IndexController
and Admin\indexController
. IndexController
can be found in default module (index) and Admin\IndexController
can be found in Admin module.
But maybe there is also an Admin\IndexController
in the default module (index). The right way should be
Index\IndexController
in Index module, Admin\IndexController
in Admin module and Index\Admin\indexController
in Index module. So even default module (index) should have a namespace.
This can work without namespaces by replacing \
with _
.
Right now, Yaf defines the current module from the Request right? That is why can handle controllers with the same name in different modules. But when there is a need to extend a controller between modules or forward a controller from a module to another, then appears the above problem.
from yaf.
Hey
Just encountered this issue.
Is there any decision about this issue?
Thanks, Ofer
from yaf.
同感
from yaf.
Related Issues (20)
- yaf_view 版本兼容问题 HOT 1
- macbookair2020款使用MAMP,按照网上的教程成功安装yaf扩展,但不生效,有mac用户可以指点迷津吗? HOT 1
- phpstan vs getInstance()
- yaf 3.3.3及以后版本,xdebug发现Bootstrap.php没有加载类内的_init方法 HOT 4
- Warning: Yaf\Application::run(): cannot call protected method Controller_Api_**::indexAction() in /www/**index.php on line 18 HOT 3
- yaf 项目一直报 class not found
- v3.3.4 中 Application::getInstance() 不可调用 HOT 1
- 关于 route_static 解析问题 HOT 2
- Request::setControllerName 第二个参数format==false时 设置失败 HOT 1
- Yaf_Registry::set 的第二个参数为什么注释为 string 类型 HOT 1
- yaf model 的问题 HOT 2
- 开启公用类库后,无法使用composer HOT 2
- 偶发性问题Uncaught Error: Call to a member function run() on bool in ....../public/index.php HOT 1
- 希望鸟哥能增加一个配置用于控制是否开启默认路由.
- yaf routing with namespace is on option HOT 4
- Fatal error: Class 'Yaf' not found HOT 2
- PHP8.2下 安装yaf-3.3.5报错 HOT 5
- Yaf_Config_Ini 造成 Too many open files 问题 HOT 3
- 使用了__get魔术方法后,当action不存在的时候,php进程会被直接终止,无法捕获错误。 HOT 4
- 支持phpstorm的代码查找
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yaf.