質問編集履歴

3

っd

2018/03/14 14:22

投稿

earnest_gay
earnest_gay

スコア615

test CHANGED
@@ -1 +1 @@
1
- FuelPHP php oil g modelで生成されるmodelの場所を任意場所に変更したい
1
+ FuelPHP php oil generateで生成されるファイルの場所を任意場所に変更したい
test CHANGED
File without changes

2

xwr

2018/03/14 14:22

投稿

earnest_gay
earnest_gay

スコア615

test CHANGED
File without changes
test CHANGED
@@ -88,6 +88,8 @@
88
88
 
89
89
  ```
90
90
 
91
+ 該当箇所を`$filepath = $base_path.'modules'.DS.$filename.'.php';`に修正してみるとmodel生成場所が変わりました。
92
+
91
93
 
92
94
 
93
95
  configフォルダ配下に何かしらのファイル持ってきてdb.phpみたいな感じで上書きするのかなぁーとか思ってたんですが

1

cえr

2018/03/11 16:10

投稿

earnest_gay
earnest_gay

スコア615

test CHANGED
File without changes
test CHANGED
@@ -11,3 +11,99 @@
11
11
  「fuelphp module oil model 場所 変更」
12
12
 
13
13
  で探してるのですがなかなか情報が見当たらず。。。
14
+
15
+
16
+
17
+
18
+
19
+ 追記
20
+
21
+ もしかして設定変更できない?
22
+
23
+ oilファイルから分析してみました。
24
+
25
+ ```
26
+
27
+ public static function model($args, $build = true)
28
+
29
+ {
30
+
31
+ $singular = \Inflector::singularize(\Str::lower(array_shift($args)));
32
+
33
+
34
+
35
+ if (empty($singular) or strpos($singular, ':'))
36
+
37
+ {
38
+
39
+ throw new Exception("Command is invalid.".PHP_EOL."\tphp oil g model <modelname> [<fieldname1>:<type1> |<fieldname2>:<type2> |..]");
40
+
41
+ }
42
+
43
+
44
+
45
+ if (empty($args))
46
+
47
+ {
48
+
49
+ throw new Exception('No fields have been provided, the model will not know how to build the table.');
50
+
51
+ }
52
+
53
+
54
+
55
+ $plural = \Cli::option('singular') ? $singular : \Inflector::pluralize($singular);
56
+
57
+
58
+
59
+ $filename = trim(str_replace(array('_', '-'), DS, $singular), DS);
60
+
61
+ $base_path = APPPATH;
62
+
63
+
64
+
65
+ if ($module = \Cli::option('module'))
66
+
67
+ {
68
+
69
+ if ( ! ($base_path = \Module::exists($module)) )
70
+
71
+ {
72
+
73
+ throw new Exception('Module '.$module.' was not found within any of the defined module paths');
74
+
75
+ }
76
+
77
+
78
+
79
+ $module_namespace = ucwords($module);
80
+
81
+ }
82
+
83
+
84
+
85
+ // こいつを発見。
86
+
87
+ $filepath = $base_path.'classes'.DS.'model'.DS.$filename.'.php';
88
+
89
+ ```
90
+
91
+
92
+
93
+ configフォルダ配下に何かしらのファイル持ってきてdb.phpみたいな感じで上書きするのかなぁーとか思ってたんですが
94
+
95
+ ハードコーディングされてるし、イメージと違うのか、、、
96
+
97
+
98
+
99
+ このファイルって`fuel/packages/oil/classes/generate.php`でパッケージに入ってるんで、ちょっと悩みます。
100
+
101
+ 僕はpackagesやvendorはgit管理していないので、model生成場所がハードコーディングされている以上、対応できないですね。。。
102
+
103
+
104
+
105
+ 未検証だけど、`fuel/packages/oil/classes/generate.php`でのmodel生成場所を修正してgit管理したところで多分、composer updateしたらgit管理している`fuel/packages/oil/classes/generate.php`が上書きされてしまう気がする。
106
+
107
+
108
+
109
+ なにか方法はないものか。