Laravel - Getting Started
Installing
Packages
- Install & Config PHP
- Install Composer - https://getcomposer.org/download/
- Install Node (needed for NPM (Node Package Manager) - https://nodejs.org/en/download/
Install Laravel
composer global require laravel/installer
Create a new Project
laravel new <blog>
or
laravel new <blog> --auth
- to include authentication
Install Authentication
composer require laravel/ui php artisan ui vue --auth npm install npm run dev
If your application doesn’t need registration, you may disable it by removing the newly created RegisterController and modifying your route declaration:
For more info review authentication here
Auth::routes(['register' => false]);
PHP Setup
INI File
extension=fileinfo
Adding Tables to Database
Create tables in config (not the database yet!) by creating a model. e.g. Lets create the model Ivruser- which should create the table endusers
php artisan make:model Ivruser -mc
-m = migration -c = controller
This create the table in migration config - e.g. <projectname>\database\migrations\ Edit the migration file <timestamp>_create_ivrusers_table.php example:
<?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; class CreateIvrusersTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('ivrusers', function (Blueprint $table) { $table->id(); $table->string('email')->unique(); $table->string('staffid')->unique(); $table->string('name'); $table->string('pin'); $table->string('mobile')->unique(); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('ivrusers'); } }
Then create the database tables using:
php artisan migrate
Migration Commands
Rollback to drop your last migration table
php artisan migrate:rollback
The migrate:reset command will roll back all of your application's migrations:
php artisan migrate:reset
The migrate:fresh command will drop all tables from the database and then execute the migrate command:
php artisan migrate:fresh
The migrate:fresh command will drop all tables from the database and then execute the migrate command:
php artisan migrate:fresh --seed
File Locations
Config Files
/config/
Routes (URLs)
/routes/web.php
Migration Files
/database/migrations
Views (html)
/resources/views
Eloquent Models
/app
Controllers / Requests / Middleware
/app/Http
Log Files
/storage/logs/laravel.log