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_Loader can not resolve *_Controller classes #7

Closed
suin opened this issue Aug 29, 2012 · 1 comment
Closed

Yaf_Loader can not resolve *_Controller classes #7

suin opened this issue Aug 29, 2012 · 1 comment

Comments

@suin
Copy link

suin commented Aug 29, 2012

Yaf_Loader seems to be not able to resolve classes which are end with Controller.
It tries to look up /MyBase/.php for MyBase_Controller in controllers directory.
I expect that it tries to look up /MyBase/Controller.php in library directory.

This is the test code:

<?php

$app = new Yaf_Application([
        "application" => [
                "directory" => __DIR__,
        ],
]);

$loader = Yaf_Loader::getInstance(__DIR__);
$loader->registerLocalNameSpace(['MyBase', 'Foo']);
$loader->autoload('MyBase_Controller'); // NG
$loader->autoload('Foo_Bar_Controller'); // NG
$loader->autoload('Foo\\Bar\\Controller'); // NG
$loader->autoload('MyBase_Controller2'); // OK

And that result is:

$ php test.php 

Warning: Yaf_Loader::autoload(): Could not find script /private/tmp/controllers/MyBase/.php in /private/tmp/test.php on line 11

Call Stack:
    0.0002     228864   1. {main}() /private/tmp/test.php:0
    0.0005     233728   2. Yaf_Loader->autoload() /private/tmp/test.php:11


Warning: Yaf_Loader::autoload(): Could not find script /private/tmp/controllers/Foo/Bar/.php in /private/tmp/test.php on line 12

Call Stack:
    0.0002     228864   1. {main}() /private/tmp/test.php:0
    0.0029     233776   2. Yaf_Loader->autoload() /private/tmp/test.php:12


Warning: Yaf_Loader::autoload(): Could not find script /private/tmp/controllers/Foo/Bar/.php in /private/tmp/test.php on line 13

Call Stack:
    0.0002     228864   1. {main}() /private/tmp/test.php:0
    0.0033     233776   2. Yaf_Loader->autoload() /private/tmp/test.php:13


Warning: Yaf_Loader::autoload(): Could not find script /private/tmp/MyBase/Controller2.php in /private/tmp/test.php on line 14

Call Stack:
    0.0002     228864   1. {main}() /private/tmp/test.php:0
    0.0038     233776   2. Yaf_Loader->autoload() /private/tmp/test.php:14

Thank you.

@laruence
Copy link
Owner

a class suffix with "controller" is considered as a controller class, thus Yaf will try to locate it in controllers folder.

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

2 participants