Contents

Laravel Often Used Artisan Commands

Create Controller

1
2
3
4
5
# Create Controller
php artisan make:controller Auth/LoginController

# Created a File
vi app/Http/Controllers/Auth/LoginController.php

Create Model with Create Table Migration

1
2
3
4
5
6
# Create Model with Migration File by Model
php artisan make:model Board -m

# Created Files
vi app/Models/Board.php
vi database/migrations/YYYY_MM_DD_000000_create_boards_table.php

Create Modify Table Migration

1
2
3
4
5
# Create Migration File for Modify [users] table
php artisan make:migration add_username_to_users --table users

# Created a File
vi database/migrations/YYYY_MM_DD_000000_add_username_to_users.php

Create Model with Factory, Migration, Seeder, and Controller

1
2
3
4
5
6
7
8
9
# Create Model, Factory, Migration, Seeder, and Controller for Profile
php artisan make:model Cozy/Profile -a

# Created Files
vi app/Models/Cozy/Profile.php
vi database/factories/Cozy/ProfileFactory.php
vi database/migrations/YYYY_MM_DD_000000_create_profiles_table.php
vi database/seeders/ProfileSeeder.php
vi app/Http/Controllers/ProfileController.php

Apply to the Database from Migration File

1
php artisan migrate

Run Development Web Server

1
php artisan serve

Run Test

1
php artisan test