質問編集履歴
2
config/autoload.phpを追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -47,7 +47,31 @@
|
|
47
47
|
|
48
48
|
```
|
49
49
|
|
50
|
+
```PHP
|
51
|
+
//vagrant/sns_php/config/autoload.php
|
52
|
+
|
53
|
+
<?php
|
54
|
+
|
55
|
+
/*
|
56
|
+
MyApp
|
57
|
+
index.php controller
|
58
|
+
MyApp\Controller\Index
|
59
|
+
-> lib/Controller/Index.php
|
60
|
+
*/
|
61
|
+
|
62
|
+
spl_autoload_register(function($class) {
|
63
|
+
$prefix = 'MyApp\';
|
64
|
+
if (strpos($class, $prefix) === 0) {
|
65
|
+
$className = substr($class, strlen($prefix));
|
66
|
+
$classFilePath = __DIR__ . '/../lib/' . str_replace('\', '/', $className) . '.php';
|
67
|
+
if (file_exists($classFilePath)) {
|
68
|
+
require $classFilePath;
|
69
|
+
}
|
70
|
+
}
|
71
|
+
});
|
50
72
|
```
|
73
|
+
|
74
|
+
```
|
51
75
|
$ php -S 192.168.33.10:8000 -t public_html/
|
52
76
|
```
|
53
77
|
|
@@ -55,6 +79,4 @@
|
|
55
79
|
ドットインストールの通りに行っています。
|
56
80
|
|
57
81
|
### 補足情報(FW/ツールのバージョンなど)
|
58
|
-
CyberDock、Atomを利用
|
82
|
+
CyberDock、Atomを利用
|
59
|
-
|
60
|
-
ここにより詳細な情報を記載してください。
|
1
title
CHANGED
File without changes
|
body
CHANGED
@@ -31,11 +31,20 @@
|
|
31
31
|
|
32
32
|
<?php
|
33
33
|
|
34
|
-
|
34
|
+
namespace MyApp\Controller;
|
35
35
|
|
36
|
-
|
36
|
+
class Index extends \MyApp\Controller {
|
37
37
|
|
38
|
-
|
38
|
+
public function run() {
|
39
|
+
if (!$this->isLoggedIn()) {
|
40
|
+
// login
|
41
|
+
header('Location: ' . SITE_URL . '/login.php');
|
42
|
+
exit;
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
}
|
47
|
+
|
39
48
|
```
|
40
49
|
|
41
50
|
```
|