Overview
- Create database in phpmyadmin
- Open .env file. NOTE: if .env file is with name, .env.sample, then rename it to .env
- Change following parameter in file
- DB_DATABASE=lumen
- DB_USERNAME=root
- DB_PASSWORD=
- Also check for following parameters if they are different than default setting
- DB_HOST=127.0.0.1
- DB_PORT=3306
- Next, as we are going to use Eloquent ORM, we need to un-comment some lines from
bootstrap/app.php
$app→withEloquent()
$app→withFacades();
- open command prompt, go to project location and run following command
php artisan make:migration create_users_table
- It will create new file for migration in
Database/migration
folder, by name “DateTime_create_user_table.php
” - If we need to add custom columns, then add as below.
public function up() { Schema::create('users', function (Blueprint $table) { $table->bigIncrements('id'); //create custom fields, we are going to add username, email and api_token $table->string('username'); $table->string ('email'); $table->text('api_token'); $table->timestamps(); }); }
- Then run command
php artisan migrate
to migrate this table to database.
Reference and detailed documentation