質問編集履歴
2
新たなコードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -151,3 +151,47 @@
|
|
151
151
|
|
152
152
|
|
153
153
|
よろしくお願い致します。
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
追記:
|
158
|
+
|
159
|
+
ご提示いただいたコードを参考にコードを作成しましたが、ブラウザよりアクセスすると「Controller actions can only return Cake\Network\Response or null.」というメッセージが表示され、
|
160
|
+
|
161
|
+
ajax経由でアクセスすると「500 (Internal Server Error)」というメッセージが帰ってきます。
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
ご教授お願い致します。
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
```php
|
170
|
+
|
171
|
+
<?php
|
172
|
+
|
173
|
+
namespace App\Controller;
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
use App\Controller\AppController;
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
class TestsController extends AppController
|
182
|
+
|
183
|
+
{
|
184
|
+
|
185
|
+
public function index() {
|
186
|
+
|
187
|
+
$this->autoRender = false;
|
188
|
+
|
189
|
+
$returnData = array('test'=>'test');
|
190
|
+
|
191
|
+
return json_encode($returnData);
|
192
|
+
|
193
|
+
}
|
194
|
+
|
195
|
+
}
|
196
|
+
|
197
|
+
```
|
1
詳細情報の追記
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
CakePHP3の$this->autoRender = false;
|
1
|
+
CakePHP3の$this->autoRender = false; を指定すると何も表示されない
|
test
CHANGED
@@ -1,25 +1,153 @@
|
|
1
1
|
###CakePHP3にて
|
2
2
|
|
3
|
-
|
3
|
+
該当コントローラーのアクション内にて$this->autoRender = false; を指定すると、viewファイルによる描画だけでなくecho "test"の内容も表示されません。
|
4
|
+
|
5
|
+
どなたかご教授お願い致します。
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
問題解決のためにできる限りシンプルな内容で作成しました。
|
10
|
+
|
11
|
+
以下、行ったことの一覧です。
|
12
|
+
|
13
|
+
1. 「php composer.phar create-project --prefer-dist cakephp/app testapp」コマンドにて新しいプロジェクトを作成。
|
14
|
+
|
15
|
+
2. mysql上に'testapp'データベースを作成。
|
16
|
+
|
17
|
+
3. app.confのDatasources部を修正。
|
18
|
+
|
19
|
+
4. 手書きにてTestsController.phpを作成。
|
20
|
+
|
21
|
+
5. 表示を確認。
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
以下該当コードです。
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
```php
|
30
|
+
|
31
|
+
<?php
|
32
|
+
|
33
|
+
'Datasources' => [
|
34
|
+
|
35
|
+
'default' => [
|
36
|
+
|
37
|
+
'className' => 'Cake\Database\Connection',
|
38
|
+
|
39
|
+
'driver' => 'Cake\Database\Driver\Mysql',
|
40
|
+
|
41
|
+
'persistent' => false,
|
42
|
+
|
43
|
+
'host' => 'localhost',
|
44
|
+
|
45
|
+
/**
|
46
|
+
|
47
|
+
* CakePHP will use the default DB port based on the driver selected
|
48
|
+
|
49
|
+
* MySQL on MAMP uses port 8889, MAMP users will want to uncomment
|
50
|
+
|
51
|
+
* the following line and set the port accordingly
|
52
|
+
|
53
|
+
*/
|
54
|
+
|
55
|
+
//'port' => 'non_standard_port_number',
|
56
|
+
|
57
|
+
'username' => 'testapp',
|
58
|
+
|
59
|
+
'password' => 'testapp',
|
60
|
+
|
61
|
+
'database' => 'testapp',
|
62
|
+
|
63
|
+
'encoding' => 'utf8',
|
64
|
+
|
65
|
+
'timezone' => 'UTC',
|
66
|
+
|
67
|
+
'flags' => [],
|
68
|
+
|
69
|
+
'cacheMetadata' => true,
|
70
|
+
|
71
|
+
'log' => false,
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
/**
|
76
|
+
|
77
|
+
* Set identifier quoting to true if you are using reserved words or
|
78
|
+
|
79
|
+
* special characters in your table or column names. Enabling this
|
80
|
+
|
81
|
+
* setting will result in queries built using the Query Builder having
|
82
|
+
|
83
|
+
* identifiers quoted when creating SQL. It should be noted that this
|
84
|
+
|
85
|
+
* decreases performance because each query needs to be traversed and
|
86
|
+
|
87
|
+
* manipulated before being executed.
|
88
|
+
|
89
|
+
*/
|
90
|
+
|
91
|
+
'quoteIdentifiers' => false,
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
/**
|
96
|
+
|
97
|
+
* During development, if using MySQL < 5.6, uncommenting the
|
98
|
+
|
99
|
+
* following line could boost the speed at which schema metadata is
|
100
|
+
|
101
|
+
* fetched from the database. It can also be set directly with the
|
102
|
+
|
103
|
+
* mysql configuration directive 'innodb_stats_on_metadata = 0'
|
104
|
+
|
105
|
+
* which is the recommended value in production environments
|
106
|
+
|
107
|
+
*/
|
108
|
+
|
109
|
+
//'init' => ['SET GLOBAL innodb_stats_on_metadata = 0'],
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
'url' => env('DATABASE_URL', null),
|
114
|
+
|
115
|
+
],
|
116
|
+
|
117
|
+
```
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
```php
|
122
|
+
|
123
|
+
<?php
|
124
|
+
|
125
|
+
namespace App\Controller;
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
use App\Controller\AppController;
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
class TestsController extends AppController
|
134
|
+
|
135
|
+
{
|
136
|
+
|
137
|
+
public function index() {
|
138
|
+
|
139
|
+
$this->autoRender = false;
|
140
|
+
|
141
|
+
echo "test";
|
142
|
+
|
143
|
+
}
|
144
|
+
|
145
|
+
}
|
4
146
|
|
5
147
|
|
6
148
|
|
7
149
|
```
|
8
150
|
|
9
|
-
public function index() {
|
10
|
-
|
11
|
-
$this->autoRender = false;
|
12
|
-
|
13
|
-
echo "test";
|
14
|
-
|
15
|
-
}
|
16
|
-
|
17
|
-
```
|
18
151
|
|
19
152
|
|
20
|
-
|
21
|
-
なお、$this->autoRender = false; をコメントアウトすると通常通りMissing Templateのエラーページが表示されます。
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
153
|
+
よろしくお願い致します。
|