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

Simple modules not working for me. #448

Open
undeadindustries opened this issue Aug 4, 2019 · 4 comments
Open

Simple modules not working for me. #448

undeadindustries opened this issue Aug 4, 2019 · 4 comments

Comments

@undeadindustries
Copy link

I'm not sure why my modules aren't working.
env: WSL linux, yaf(latest), php 7.2

routes in conf:

application.dispatcher.defaultModule = Default
application.dispatcher.defaultController = FirstRun
application.dispatcher.defaultAction = Index
routes.firstrun2.type="rewrite"
routes.firstrun2.match="/"
routes.firstrun2.route.module = Default
routes.firstrun2.route.controller=Firstrun
routes.firstrun2.route.action=Index

In chrome, I go to: http://localhost/

I var_dump the app and get this for routes

    [_request:protected] => Yaf_Request_Http Object
        (
            [module] => 
            [controller] => 
            [action] => 
            [method] => GET
            [params:protected] => Array
                (
                )

            [language:protected] => 
            [_exception:protected] => 
            [_base_uri:protected] => 
            [uri:protected] => 
            [dispatched:protected] => 
            [routed:protected] => 

and this for defaults:

[_auto_render:protected] => 1
    [_return_response:protected] => 
    [_instantly_flush:protected] => 
    [_default_module:protected] => Default
    [_default_controller:protected] => Firstrun
    [_default_action:protected] => index
)

This when I dump getRoutes

Array
(
    [0] => Default
    [1] => Admin
)

I would expect this:

 (
            [module] => Default
            [controller] => FirstRun
            [action] => Index
)

I have no idea what I could be doing wrong?

@undeadindustries
Copy link
Author

Even making the modules and routes more direct doesn't seem to work?

Config:

application.dispatcher.defaultModule = Default
application.dispatcher.defaultController = FirstRun
application.dispatcher.defaultAction = Index

routes.default.type="rewrite"
routes.default.match="/:module/:controller/:action"
routes.default.route.module = ":module"
routes.default.route.controller=":controller"
routes.default.route.action=":action"
routes.firstrun2.type="rewrite"
routes.firstrun2.match="/"
routes.firstrun2.route.module = Default
routes.firstrun2.route.controller=Firstrun
routes.firstrun2.route.action=Index

When I go to: localhost/Default/FirstRun/Index

I get:

Yaf_Dispatcher Object
(
    [_router:protected] => Yaf_Router Object
        (
            [_routes:protected] => Array
                (
                    [_default] => Yaf_Route_Static Object
                        (
                        )

                )

            [_current:protected] => 
        )

    [_view:protected] => 
    [_request:protected] => Yaf_Request_Http Object
        (
            [module] => 
            [controller] => 
            [action] => 
            [method] => GET
            [params:protected] => Array
                (
                )

            [language:protected] => 
            [_exception:protected] => 
            [_base_uri:protected] => 
            [uri:protected] => 
            [dispatched:protected] => 
            [routed:protected] => 
        )

    [_plugins:protected] => Array
        (
        )

    [_auto_render:protected] => 1
    [_return_response:protected] => 
    [_instantly_flush:protected] => 
    [_default_module:protected] => Default
    [_default_controller:protected] => Firstrun
    [_default_action:protected] => index
)

Failed opening controller script /mnt/c/Users/......../application/controllers/Firstrun.php: No such file or directory

Any help would be greatly appreciated.

I'm expecting it to try to go to: /mnt/c/Users/......../application/modules/Default/controllers/Firstrun.php
Is there something I'm not understanding?

@yulonghu
Copy link
Contributor

The first question, I can't reproduce. Please add some more information.
env: yaf(latest) > v3.0.9, PHP 7.2.26, CentOS 6.x

@phpseven
Copy link

phpseven commented Mar 16, 2020

I also found this problem, but I used another method to solve it, and I hope @laruence can fix it
(求 @laruence 大佬能解决一下)

@undeadindustries
add plugin:

application/plugins/Tc.php

class TcPlugin extends Plugin_Abstract {
        public function routerShutdown(Request_Abstract $request, Response_Abstract $response) {
                $app_config = Application::app()->getConfig();
                //module bind to defaultModule static
                if(!empty($app_config['application']['dispatcher']['defaultModule'])){
                $request->setModuleName($app_config['application']['dispatcher']['defaultModule']);
                }
                //  "/index.php" =>  /index/index  
                if($request->controller == 'Index.php'){
                $request->controller = 'Index';
                }
       }
}   

@letwang
Copy link

letwang commented Apr 24, 2020

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

4 participants