質問編集履歴

2

タグ

2020/08/16 07:08

投稿

mizuneko_4345
mizuneko_4345

スコア4

test CHANGED
File without changes
test CHANGED
File without changes

1

ひとまず応急措置

2020/08/16 07:07

投稿

mizuneko_4345
mizuneko_4345

スコア4

test CHANGED
@@ -1 +1 @@
1
- php artisan test_commandターミナル上に不可解エラーが出る
1
+ Laravelのバッチ作成が
test CHANGED
@@ -1,14 +1,144 @@
1
- ### 前提・実現したいこと
1
+ ### 実現したいこと
2
2
 
3
3
  Laravelでバッチ作成
4
4
 
5
5
 
6
6
 
7
+ ### 前提
8
+
9
+ AWSのEC2上で無料枠のCentOS7を選択し(ストレージを30GiB)インスタンスを作成しました。
10
+
11
+ 次に、MySQL,Nginx,PHP,Laravelをそれぞれインストールしました。バージョンは以下です。
12
+
13
+
14
+
15
+ mysqld Ver 5.7.31 for Linux on x86_64
16
+
17
+ nginx/1.18.0
18
+
7
- MySQLでDBを作成後、
19
+ PHP 7.3.20
20
+
8
-
21
+ Laravel7
22
+
23
+
24
+
25
+ その後VSCodeのRemoteSSH機能を使って、サーバ側にWindows経由でSSH接続しました。
26
+
27
+
28
+
29
+
30
+
9
- VSCodeでホストサーバにアクセスし、TestCommand.php内部を編集しました。
31
+ MySQLでDBを作成後、VSCodeでホストサーバにアクセスし、TestCommand.php内部を編集しました。
32
+
10
-
33
+ ```
34
+
35
+ 【TestCommand.php】
36
+
37
+
38
+
39
+ <?php
40
+
41
+
42
+
43
+ namespace App\Console\Commands;
44
+
45
+
46
+
47
+ use Illuminate\Console\Command;
48
+
49
+ use App\Models\Player;
50
+
51
+
52
+
53
+ class TestCommand extends Command
54
+
55
+ {
56
+
57
+ /**
58
+
59
+ * The name and signature of the console command.
60
+
61
+ *
62
+
63
+ * @var string
64
+
65
+ */
66
+
67
+ protected $signature = 'test_command';
68
+
69
+
70
+
71
+ /**
72
+
73
+ * The console command description.
74
+
75
+ *
76
+
77
+ * @var string
78
+
79
+ */
80
+
81
+ protected $description = 'Test Command';
82
+
83
+
84
+
85
+ /**
86
+
87
+ * Create a new command instance.
88
+
89
+ *
90
+
91
+ * @return void
92
+
93
+ */
94
+
95
+ public function __construct()
96
+
97
+ {
98
+
99
+ parent::__construct();
100
+
101
+ }
102
+
103
+
104
+
105
+ /**
106
+
107
+ * Execute the console command.
108
+
109
+ *
110
+
111
+ * @return int
112
+
113
+ */
114
+
115
+ public function handle()
116
+
117
+ {
118
+
119
+ $players = Player::get();
120
+
121
+ foreach($players as $player) {
122
+
123
+ echo $player->name."\n";
124
+
125
+ }
126
+
127
+ return 0;
128
+
129
+ }
130
+
131
+ }
132
+
133
+ ```
134
+
135
+
136
+
137
+
138
+
11
- php artisan test_commandでDBのサッカー選手名を表示させたいのすが
139
+ php artisan test_commandをターミナル上で打ち込み
140
+
141
+ DB上のサッカー選手名を表示させたいのですが、
12
142
 
13
143
  以下のエラーが表示されます。
14
144