I have a class,class name called Get_user_info, this class has a lot of function, I should put this class where, in order to invoke the controller in this class function? For example, in the list controller.
In fact, there is only one problem, can you put it under the common folder ?
Reply content:
I have a class,class name called Get_user_info, this class has a lot of function, I should put this class where, in order to invoke the controller in this class function? For example, in the list controller.
In fact, there is only one problem, can you put it under the common folder ?
/thinkphp/library/org to build a directory of their own, throw the inside to write a good name space can be;
Well, I'll take an example of the project.
In the case of pagination;
Example Project: Http://git.oschina.net/shuaibai123/thinkbjy
Pagination class: Http://git.oschina.net/shuaibai123/thinkbjy/blob/master/ThinkPHP/Library/Org/Bjy/Page.class.php
Call the page 159th line of the paging class: http://git.oschina.net/shuaibai123/thinkbjy/blob/master/Application/Common/Model/ArticleModel.class.php
The first is to define the namespace of the paging class: namespace Orgbjy;
The paging class is then called: $page =new orgbjypage ($count, $limit);
You have to use the same way; You can define a directory, define a namespace, use it, and have a good namespace instantiation.
Or in the official String class:/thinkphp/library/org/util/string.class.php
There are some methods for handling strings, such as obtaining random numbers, string interception, etc.; you can view the official source code to understand;
The class name is a bit strange, look like a model, is the first model class, and then some thinkphp project?
If it's the same as I said, there are 3 ways
Refactor code once to conform to thinkphp model specification
Look at the official library extensions to see if you can integrate, because you might also be involved in database operations, depending on how you debug
The worst-case scenario is as Kingzchenung says include can
Get_user_info This is the name of the class or the name of the method, the current look like the name of the method, if it is a class can be distinguished from a namespace based on a utils such a namespace to hold this class, specifically to see your namespace root directory is how
You can create a new custom directory in the controller sibling directory, and the class changes to a namespace, which can then be referenced. In fact, in other places are casually you, not big own include, at most do not conform to the framework specifications.
Introduced as a third-party plugin.