Simple way to manage database schema for existing php application using laravel illuminate database

Today we are going to learn how to manage your application database scheme and command line tool for existing php application.


  • Easy to handle database table schema
  • Easy to large number of table for large application
  • Provide command-line interface to migrate the database table schema

When comes to this concept, I used laravel illuminate database and it has pretty good with database schema migration.

Consider the following two tables :

  • Users
  • Roles

Each table consist it own columns which are


  • id
  • username
  • password
  • role_id


  • id
  • name

Before go to the implementation we need to setup it packages by using composer [ If you are not aware about composer then you should look on its documentation ]

create composer.json file at your project directory (Ex: migration is my project directory)

Add illuminate/database at composer.json file. So it  look like this 

Run the composer install by using

 Now project directory look like this

That’s all setup.

Migration implementation

First we need to create a folder to keep migration files

Then create database configuration file to connect the database and keep it to project directory (config.php)

create migration file for Users as well as Roles and keep it to migration/database/migration/



Before goto the execution we need to setup migration to create schema into the database. For this case we used small executable php file name is “db”.



Once finish all those things then  run the following command in CLI to migrate the database tables

for more about migration look the laravel documentation

Thank you. Also i have given option to download this script.
Demo and Download