- create new project
laravel new PROJECTNAME
-
update .ENV file for db connection
-
create default migration tables
php artisan migrate
- create required tables
php artisan make:migration create_TABLENAME_table --create=TABLENAME
- Update migration files to add more field
Path: database/migrations
- Generate all tables from migration file
php artisan migrate
- Create Eloquent model.
Path: /app/Task.php
php artisan make:model MODELNAME
(note: always use singular name. e.g. Task, Project etc)
-
Create necessary routes inside
/routes/web.php
file and point them to controller files -
Create controller file.
Path: /app/TasksController.php
php artisan make:controller TasksController --resource
(note: always use plural name. e.g. Tasks, Projects etc)
- Import Eloquent Module inside controller file (which was generated in step 7).
e.g. use \App\Task;
-
Create View files inside
resources/views
folder. -
Use controller to load data inside view files
e.g. Route::get('/', 'TasksController@index');
- 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); }