teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

3

codeの追加

2018/04/02 03:37

投稿

Casablanca_mtg
Casablanca_mtg

スコア209

title CHANGED
File without changes
body CHANGED
@@ -5,7 +5,7 @@
5
5
  mysql:5.6.37 PHP:7.1.10
6
6
  ************************************************************
7
7
 
8
- ''''
8
+ ```Error内容
9
9
  [Mon Apr 2 09:15:55 2018] PHP Fatal error: Uncaught Error: Class 'MyApp\Controller\Index' not found in /home/vagrant/sns_php/public_html/index.php:9
10
10
  Stack trace:
11
11
  #0 {main}
@@ -14,10 +14,12 @@
14
14
  Stack trace:
15
15
  #0 {main}
16
16
  thrown in /home/vagrant/sns_php/public_html/index.php on line 9
17
- ''''
17
+ ```
18
18
 
19
- ```index。php
20
19
 
20
+
21
+ ```public_html/index。php
22
+
21
23
  <?php
22
24
 
23
25
  // ユーザーの一覧
@@ -75,6 +77,27 @@
75
77
  session_start();
76
78
 
77
79
  ```
80
+ ```Controller/index.php
81
+ <?php
82
+
83
+ namespace MyApp\Controller;
84
+
85
+ class Index extends \MyApp\Controller {
86
+
87
+ public function run() {
88
+ if (!$this->isLoggedIn()) {
89
+ // login
90
+ header('Location: ' . SITE_URL . '/login.php');
91
+ exit;
92
+ }
93
+
94
+ // get users info
95
+ $userModel = new \MyApp\Model\User();
96
+ $this->setValues('users', $userModel->findAll());
97
+ }
98
+
99
+ }
100
+ ```
78
101
  ![イメージ説明](ef2ee18d1948a4f22d3554d3618e2ccc.png)
79
102
 
80
103
  ![イメージ説明](ffbf4a6ed2f7dd0fcb43922f0b083690.png)

2

画像を追加しました

2018/04/02 03:36

投稿

Casablanca_mtg
Casablanca_mtg

スコア209

title CHANGED
File without changes
body CHANGED
@@ -77,4 +77,6 @@
77
77
  ```
78
78
  ![イメージ説明](ef2ee18d1948a4f22d3554d3618e2ccc.png)
79
79
 
80
+ ![イメージ説明](ffbf4a6ed2f7dd0fcb43922f0b083690.png)
81
+
80
82
  よろしくご指導下さい

1

コードの追加をする

2018/04/02 01:17

投稿

Casablanca_mtg
Casablanca_mtg

スコア209

title CHANGED
File without changes
body CHANGED
@@ -3,8 +3,9 @@
3
3
  PHPでログイン機能を実装しよう  https://dotinstall.com/lessons/sns_php_v3/35826
4
4
  これの23章目ぐらいからUncaught Errorが出てしまい正しくブラウザ表示がしないです
5
5
  mysql:5.6.37 PHP:7.1.10
6
- **************************************************************
6
+ ************************************************************
7
+
7
- phpでのError内容
8
+ ''''
8
9
  [Mon Apr 2 09:15:55 2018] PHP Fatal error: Uncaught Error: Class 'MyApp\Controller\Index' not found in /home/vagrant/sns_php/public_html/index.php:9
9
10
  Stack trace:
10
11
  #0 {main}
@@ -13,9 +14,10 @@
13
14
  Stack trace:
14
15
  #0 {main}
15
16
  thrown in /home/vagrant/sns_php/public_html/index.php on line 9
16
- ************************************************************
17
+ ''''
18
+
17
- index.php
19
+ ```indexphp
18
- ```
20
+
19
21
  <?php
20
22
 
21
23
  // ユーザーの一覧
@@ -56,6 +58,23 @@
56
58
  </html>
57
59
 
58
60
  ```
61
+ ```config.php
62
+ <?php
63
+
64
+ ini_set('display_errors', 1);
65
+
66
+ define('DSN', 'mysql:dbhost=localhost;dbname=dotinstall_sns_php');
67
+ define('DB_USERNAME', 'dbuser');
68
+ define('DB_PASSWORD', 'muku1130');
69
+
70
+ define('SITE_URL', 'http://' . $_SERVER['HTTP_HOST']);
71
+
72
+ require_once(__DIR__ . '/../lib/functions.php');
73
+ require_once(__DIR__ . '/autoload.php');
74
+
75
+ session_start();
76
+
77
+ ```
59
78
  ![イメージ説明](ef2ee18d1948a4f22d3554d3618e2ccc.png)
60
79
 
61
80
  よろしくご指導下さい