Giter VIP home page Giter VIP logo

Comments (7)

zxcvdavid avatar zxcvdavid commented on May 30, 2024

加载和 Trait没关系..只要你的加载规则没问题就行..

from yaf.

lilj avatar lilj commented on May 30, 2024

我是想把Trait按规则放到单独的文件里面. 不用include 神马的, 直接就可以use了.
现在的 lib 不正是这样的么?

from yaf.

lilj avatar lilj commented on May 30, 2024

可以了, 没有registerLocalNameSpace ...
找到一点资料.
http://stackoverflow.com/questions/10641824/php5-4-autoloading-traits

Sorry, 没仔细研究就发问了.

from yaf.

wenjun1055 avatar wenjun1055 commented on May 30, 2024

这个问题很好,哈哈

from yaf.

lilj avatar lilj commented on May 30, 2024

好多年过去了, 鸟哥最近频繁出没, 重新提一下这个需求,这样就能不用spl_autoload了。

<?php

spl_autoload_register(function($traitName) {
	$fileName = APP_PATH.'traits/' . $traitName . '.php';
	if (file_exists($fileName)) {
		include_once $fileName;
	}
});

final class Test_Controller extends Yaf_Controller{
	use Mds;
	...
	
}

from yaf.

laruence avatar laruence commented on May 30, 2024

你可以通过registerNamespace(“类名前缀”, “路径“)来加载啊

from yaf.

laruence avatar laruence commented on May 30, 2024

3.2版本

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.