Coder Social home page Coder Social logo

Comments (7)

akDeveloper avatar akDeveloper commented on May 3, 2024

+1 for the namespace, although i dont know if this has any conflict with routes.

from yaf.

laruence avatar laruence commented on May 3, 2024

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.

HarasimowiczKamil avatar HarasimowiczKamil commented on May 3, 2024

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.

laruence avatar laruence commented on May 3, 2024

hmm, php.ini is a way(bc), let me think about it. thanks

from yaf.

akDeveloper avatar akDeveloper commented on May 3, 2024

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.

oc666 avatar oc666 commented on May 3, 2024

Hey

Just encountered this issue.
Is there any decision about this issue?

Thanks, Ofer

from yaf.

xbugio avatar xbugio commented on May 3, 2024

同感

from yaf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.