Laravel

Comment Promt : php artisan list

To view all the commant prompt comments in laravel

php artisan make:auth – Auto file generation, Generate the MVC files for authentication scaffolding

php artisan migrate – database related changes like create table, add, update, delete fields

php artisan make:model tours (create model file)

php artisan make:migration tours


 

Developer Guide For Laravel 5.2

Installation:

            System Requirement:

Before installation we need some system requirement. Laravel Homestead virtual machine will be use or if not using Homestead we will need to make sure the following requirement meets our server:

  • PHP >= 5.5.9 (For Laravel 5.3 PHP >= 5.6.4)
  • OpenSSL PHP Extension
  • PDO PHP Extension
  • Mbstring PHP Extension
  • Tokenizer PHP Extension

Above all we can check in phpinfo().

Installing:

  • Laravel can install via either laravel installer or composer. Composer is comfortable for to install laravel project. First, need to install Composer from Composer Setup for windows. Check composer installed in command prompt.

cmd :      composer

  • To install laravel project open command prompt. Place the folder path to create laravel project. Here I mentioned (Can use either wamp or xampp)

C:\xampp\htdocs\>

Then create project ,

Cmd:     composer create-project –prefer-dist laravel/laravel blog “5.2.*”

C:\xampp\htdocs\>composer create-project  –prefer-dist laravel/laravel myproject “5.2.*”·

  • It take few minutes to install or create a laravel project, here I mentioned project name is “myproject”. Once completed check in htdocs folder myproject will be created.·
  • After installation, should configure the application’s document / web root to the public directory.
  • ·         Next check in localhost as  http://localhost/myproject/public/   laravel welcome page will be displayed.(shortly .htaccess file get base url )

Configuration:·

  • Change the Timezone and locale in config/app.php·
  • Change DB name , username , password in config/database.php·
  • Change DB name , username , password in .env

Laravel project is created .

Folder Structure:                   

The folder structure of laravel contains many directories with different usage refer in detail  Root Directory .    

Routing:              

All Laravel routes are defined in app/Http/routes.php

Route::get(‘/’, function () {                                        

 return view(‘welcome’);                                       

});

It calls the view page resources/views/welcome.blade.php

View:

  • The view files are stored in resources/views/   directory.·
  • Save the view file  .blade.php

Controller:·

  • Controller files are stored in app/Http/Controllers/   directory.·
  • We can create controller file in command prompt

Cmd:         php artisan   list all available commands  for laravel project.

Cmd :         php artisan make:controller   HomeController

New controller is created in app/Http/Controllers/HomeController

Model:

  • Model files stored in app/ directory.·
  • Model also can be create using command prompt

Cmd :         php artisan make:model  HomeModel

New model stored in app/HomeModel

Authentication:·

  • We can create register and login page of our site with one single command.
    • Cmd :     php artisan make:auth
    • The changes are made in resources/views/ directory.·
  • Create table for authentication migrate and users table will be created.(Confirm DB created and configured it)
    • Cmd :   php artisan migrate·
  • Now easily register and login to the project.

Middleware:·

  • HTTP Middleware provides a convenient mechanism for filtering HTTP requests entering in applications. That is it act as middle man between request and response. It is used to verify whether user of the application is authenticated or not.·
  • Create Middleware using this command
    • Cmd:    php artisan make:middleware  middleware-name
    • The middleware is stored in app/Http/Middleware/  directory .·
  • Register the middleware in app/Http/kernel.php then use the middleware in route file.

Request and Response:·

  • To access request should mention Illuminate\Http\Request class on controller.·
  • Three method used for retrieve request:
    • The path method is used to retrieve the request’s URI.
      • $uri = $request->path();ü
    • The is method is used to verify that the incoming request URI matches a given pattern.
      • $pattern = $request->is(‘admin/*’);
    • The url or fullurl method used to get full url.
      • $url = $request->url();        
      • $url = $request->fullurl();·
  • Each request has a response. Response can be sent either from route or from controller.

QuickAdmin:        

Installation:

  •  Install the package of QuickAdmin via composer.
    •                Cmd:  composer require laraveldaily/quickadminü
  • Confirm installation complete then register our service provider. Open config/app.php and insert
    •               Laraveldaily\Quickadmin\QuickadminServiceProvider::class,in the $providers array.
  • Run quickadmin installation command (check in  .env db connection given)
    •               Cmd: php artisan quickadmin:installü
  • After installation complete register our route middleware in the system. Open app/Http/kernel.php and insert
    •           ‘role’ => \Laraveldaily\Quickadmin\Middleware\HasPermissions::class,in the $routeMiddleware array.
  • Open browser and check  http://localhost/myproject/public/admin the quickadmin page will be display. Using this admin panel create CRUD controller, custom controller and parent menu item.

Finally,  laravel project and admin panel is ready for development.