Laravel 5.3

# Create a new project
composer create-project --prefer-dist laravel/laravel <project-name>

# Check existing version
php artisan -V

# Make controllers
php artisan make:controller ProductController

# Make models
php artisan make:model <modal name>

# Make views

# Database

Using migration script:
- Migration scripts will be stored at 'database/migrations' folder
- Can create a blueprint of migration script using,
  php artisan make:migration <name of script to identify> --create=<table name>
  eg. php artisan make:migration create_table_customer --create=customer
- Can get the help using,
   php artisan help make:migration
- Can run all the migration scripts using,
  php artisan migrate
- Can rollback current change using,
  php artisan migrate:rollback

# Seeder - seeding database with test data using seed classes

- Create seeding script
  php artisan make:seeder <seeder name>
  eg. php artisan make:seeder CustomerTableSeeder

- How run all seeds
  php artisan db:seed
- Run individual seed
  php artisan db:seed --class= CustomerTableSeeder
- When need remove all tables, create all again and seed from the beginning,
  php artisan migrate:refresh --seed

# General utility functions

- To catch http request - $request->input('name', '<default value>');

# Tinker
- php artisan tinker
- When we need to print sql statement on tinker,
  DB::listen(function($query) { var_dump($query->sql); });

# Debugging techniques
- Write out executed SQLs
DB::listen(function ($query){
   var_dump($query->sql, $query->bindings);
});
- Log info
Log::info('some info'); // use Illuminate\Support\Facades\Log;

# General
- Clean up package: php artisan clear-compiled

- How add composer added packages to laravel:

- How create dummy records on tables
composer require fzaninotto/faker --dev : seems this is now ships with laravel package itself
article: https://scotch.io/tutorials/generate-dummy-laravel-data-with-model-factories


# Get help any time:

- php artisan list
- php artisan help <any command>
  eg. php artisan help make:controller


# REST Application demo: https://github.com/dilumdarshana/laravelREST

Popular posts from this blog

Kubernetes for Micro Services

Node-RED