floy's recent timeline updates
floy

floy

V2EX member #68564, joined on 2014-07-21 16:59:51 +08:00
floy's recent replies
我现在是这么做的:
在composer.json中配置
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/controllers/admin",
"app/controllers/member",
"app/controllers/group",

............

然后 composer dump-autoload
在app/controllers/member下添加class文件,添加命名空间
namespace App\Controllers\Member;

路由上更改配置如下
//用户
Route::group(array('prefix' => 'member', 'namespace' => 'App\Controllers\Member'), function() {
Route::get('/', 'IndexController@index');
........
});


现在好了,能正常访问到控制器了,但出现了新问题,DB方法等无法使用,报class not found
@Yuansir
这种方式我更喜欢了,要去composer.json里配置?配置完了以后呢,那还需要再install一次吗,能自动生成烦恼app下的目录吗
在ThinkPHP中,生成一个新的module,直接bind一个appname就可以把核心目录给build,比较方便
@bearcat001
如果真是这样,那就省心多了,我去测试 下,非常感谢!
@cooper

也就是说在controller类中,如果加入了命名空间,就不用关心这个controller具体在哪个目录下,只要保证该命名唯一性即可?
@cooper
路由上怎么分配呢,这么做可以吗?
Route::get('profile', 'member/ProfileController@index');
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   913 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 16ms · UTC 22:27 · PVG 06:27 · LAX 15:27 · JFK 18:27
♥ Do have faith in what you're doing.