-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
如果使自己的文件也使用namespace #159
Comments
1、修改yaf的配置项
2、在你的Bootstrap文件中引入composer的autoload.php就可以。 <?php
use \Yaf\Bootstrap_Abstract;
use \Yaf\Dispatcher;
use \Yaf\Loader;
/**
* Class Bootstrap
*/
class Bootstrap extends Bootstrap_Abstract
{
/**
* @param Dispatcher $dispatcher
*/
function _initComposerAutoload(Dispatcher $dispatcher)
{
$autoload = APPLICATION_PATH . '/vendor/autoload.php';
if (file_exists($autoload)) {
Loader::import($autoload);
}
}
} |
开启了spl_autoload效率会受影响。希望Yaf本身能支持项目引入命名空间。 |
鸟哥好像对命名空间没什么感觉,还停留在pecl时代 |
@JianfuLi 感谢你提供的方法。 |
@JianfuLi 多谢你提供的方法。 |
使用了这个方法后报错: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
yaf自己的类可以开启namespace调用,请问我自己的程序文件也希望使用namespace来规划,如:
getAppDirectory(); echo $this->_request->getActionName(); $this->_view->assign('word', 'Hello World'); } } 现在是运行不了的,请问怎么做比较好呢The text was updated successfully, but these errors were encountered: