สร้างโปรเจ็ค laravel ด้วย composer
- C:\xampp\htdocs composer create project laravel/laravel project-name --perfer -dist
สร้าง Controller
- C:\xampp\htdocs\project-name php artisan make:controller NameController หรือ
C:\xampp\htdocs\project-name php artisan make:controller NameController --plain
ลง illuminate/html ด้วย composer (input form)
- composer require illuminate/html
เพิ่ม Service Providers ที่ config\app.php
Illuminate\Html\HtmlServiceProvider::class,
เพิ่ม Class Aliases
'Form' => Illuminate\Html\FormFacades::class,
'Html' => Illuminate\Html\HtmlFacades::class,
สร้าง Model
- C:\xampp\htdocs\project-name php artisan make:model Model/ModelName
Set Datasource
- ที่ Config\Database.php
ลบที่ .env ออกด้วย
สร้าง migration
- php artisan make:migration create_table-name_table
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('student', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('student');
}
- php artisan migrate
ไม่มีความคิดเห็น:
แสดงความคิดเห็น