Skip to content

Instantly share code, notes, and snippets.

@aslamdoctor
Last active May 24, 2019 07:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aslamdoctor/125b53e1b9726101071422cac00c1fa7 to your computer and use it in GitHub Desktop.
Save aslamdoctor/125b53e1b9726101071422cac00c1fa7 to your computer and use it in GitHub Desktop.
Laravel New Project Boilerplate Steps

Laravel New Project Steps

  1. create new project

laravel new PROJECTNAME

  1. update .ENV file for db connection

  2. create default migration tables

php artisan migrate

  1. create required tables

php artisan make:migration create_TABLENAME_table --create=TABLENAME

  1. Update migration files to add more field

Path: database/migrations

  1. Generate all tables from migration file

php artisan migrate

  1. Create Eloquent model.

Path: /app/Task.php

php artisan make:model MODELNAME

(note: always use singular name. e.g. Task, Project etc)

  1. Create necessary routes inside /routes/web.php file and point them to controller files

  2. Create controller file.

Path: /app/TasksController.php

php artisan make:controller TasksController --resource

(note: always use plural name. e.g. Tasks, Projects etc)

  1. Import Eloquent Module inside controller file (which was generated in step 7).

e.g. use \App\Task;

  1. Create View files inside resources/views folder.

  2. Use controller to load data inside view files

e.g. Route::get('/', 'TasksController@index');

  1. And finally run the server

php artisan serve


Fix for migration error: Open file : App\Providers\AppServiceProvider.php Add below line on top

use Illuminate\Support\Facades\Schema;

Replace boot() method with below

public function boot() { Schema::defaultStringLength(191); }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment