コントローラを作成するメモ。
コントローラ新規作成。
php artisan make:controller SampleAppController
./app/Http/Controllers/
SampleAppController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class SampleAppController extends Controller
{
//
}
サンプルコード追加
SampleAppController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class SampleAppController extends Controller
{
public function index()
{
// サンプルを追加
echo "サンプル";
}
}
アクションを割り当てる
./routes/
web.php
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('sample', 'SampleAppController@index');
localhost/sampleで表示確認。