Email: info@zenconix.com

Steps by step procedure to connect the database to Lumen



Visit Site:

Overview

  1. Create database in phpmyadmin
  2. Open .env file. NOTE: if .env file is with name, .env.sample, then rename it to .env
  3. Change following parameter in file
    1. DB_DATABASE=lumen
    2. DB_USERNAME=root
    3. DB_PASSWORD=
  4. Also check for following parameters if they are different than default setting
    1. DB_HOST=127.0.0.1
    2. DB_PORT=3306
  5. Next, as we are going to use Eloquent ORM, we need to un-comment some lines from bootstrap/app.php
    1. $app→withEloquent()
    2. $app→withFacades();
  6. open command prompt, go to project location and run following command
    php artisan make:migration create_users_table
  7. It will create new file for migration in Database/migration folder, by name “DateTime_create_user_table.php
  8. 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();
        });
    }
  1. Then run command php artisan migrate to migrate this table to database.

Reference and detailed documentation

Features

Specifications

Preview