Coder Social home page Coder Social logo

Not resolving modules about yaf HOT 9 CLOSED

laruence avatar laruence commented on July 17, 2024
Not resolving modules

from yaf.

Comments (9)

FightingMan avatar FightingMan commented on July 17, 2024

On 09/16/2012 06:00 AM, meth wrote:

I have a Yaf Application with modules, but it is not resolving modules
right, because when I try to access a module it always try to route to
default module and find the controller inside it:

Here you can see the application.ini file:

[product]

;layout
application.directory = APP_PATH
application.bootstrap = APP_PATH "Bootstrap.php"
application.library = APP_PATH "../library"
application.layoutFile = 'admin_layout.phtml';
application.layoutDir = APP_PATH "layout"
application.modules="index,admin"
application.baseUri=""
application.dispatcher.defaultRoute=""
application.dispatcher.throwException=1
application.dispatcher.catchException=1
application.dispatcher.defaultModule="admin"
application.dispatcher.defaultController="admin"
application.dispatcher.defaultAction="index"

When accessing the root URL of my app I get:

Could not find controller script /home/projects/yaf_app/web/../application/controllers/Admin.php

And here the folder structure:

  • application
  • controllers
  • config
  • modules
    - controllers
    - views
  • views

Maybe I am doing something wrong but it worked for me in another project.


Reply to this email directly or view it on GitHub
#14.

could you paste your request url?

from yaf.

javiyt avatar javiyt commented on July 17, 2024

Yes, here you have it

admin_index.type="rewrite"
admin_index.match="/(admin|admin/)$"
admin_index.route.module="admin"
admin_index.route.controller="admin"
admin_index.route.action="index"

ajax_index.type = "rewrite"
ajax_index.match = "/ajax$"
ajax_index.route.module="admin"
ajax_index.route.controller="ajax"
ajax_index.route.action="index"

And the bootstrap:

<?php

class Bootstrap extends Yaf_Bootstrap_Abstract
{
    private $_config;

    public function _initBootstrap()
    {
        $this->_config = Yaf_Application::app()->getConfig();
    }

    public function _initIncludePath()
    {
        set_include_path( get_include_path() . PATH_SEPARATOR . $this->_config->application->library );
    }

    public function _initErrors()
    {
        if ( $this->_config->application->showErrors )
        {
            error_reporting( -1 );
            ini_set( 'display_errors', 'On' );
        }
    }

    public function _initRoutes( Yaf_Dispatcher $dispatcher )
    {
        $config = new Yaf_Config_Ini( APP_PATH . 'conf/routes/routes.ini' );
        $dispatcher->getRouter()->addConfig( $config );
    }

    public function _initLayout( Yaf_Dispatcher $dispatcher )
    {
        $dispatcher->registerPlugin( new LayoutPlugin() );
    }

}

from yaf.

FightingMan avatar FightingMan commented on July 17, 2024

On 09/16/2012 06:00 AM, meth wrote:

I have a Yaf Application with modules, but it is not resolving modules
right, because when I try to access a module it always try to route to
default module and find the controller inside it:

Here you can see the application.ini file:

[product]

;layout
application.directory = APP_PATH
application.bootstrap = APP_PATH "Bootstrap.php"
application.library = APP_PATH "../library"
application.layoutFile = 'admin_layout.phtml';
application.layoutDir = APP_PATH "layout"
application.modules="index,admin"
application.baseUri=""
application.dispatcher.defaultRoute=""
application.dispatcher.throwException=1
application.dispatcher.catchException=1
application.dispatcher.defaultModule="admin"
application.dispatcher.defaultController="admin"
application.dispatcher.defaultAction="index"

When accessing the root URL of my app I get:

Could not find controller script /home/projects/yaf_app/web/../application/controllers/Admin.php

And here the folder structure:

  • application
  • controllers
  • config
  • modules
    - controllers
    - views
  • views

Maybe I am doing something wrong but it worked for me in another project.


Reply to this email directly or view it on GitHub
#14.

and plz show me your module and controller's name :),yaf has its strict
name rules.

from yaf.

javiyt avatar javiyt commented on July 17, 2024
<?php
class AdminController extends Yaf_Controller_Abstract
{

public function indexAction()
{}

}

And module folder is called Admin and controller Admin.php

from yaf.

FightingMan avatar FightingMan commented on July 17, 2024

On 09/16/2012 06:24 AM, meth wrote:

'''php

from yaf.

laruence avatar laruence commented on July 17, 2024

hey, please check the return value of:

<?php
    .....
    public function _initRoutes( Yaf_Dispatcher $dispatcher )
    {
        $config = new Yaf_Config_Ini( APP_PATH . 'conf/routes/routes.ini' );
        $dispatcher->getRouter()->addConfig( $config ); //check this, make sure it has register successfully
    }

from yaf.

laruence avatar laruence commented on July 17, 2024

and what's your Yaf version?

from yaf.

laruence avatar laruence commented on July 17, 2024

Hey, after I set up a test demo according your test script, I found the reason,

you set the :

 application.dispatcher.defaultModule="admin"

thus the module 'admin' become the default module, Yaf will look for controllers of default module in application/ folder

so, the fix is , remove that configure.

from yaf.

javiyt avatar javiyt commented on July 17, 2024

It works, thanks :)

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.