Wednesday, July 12, 2023

Laravel Basics

 create a new Laravel project - composer create-project laravel/laravel example-app


globally installing the Laravel installer -  

composer global require laravel/installer

laravel new example-app


Laravel's local development server - 

cd example-app

 php artisan serve


Laravel Breeze is a minimal, simple implementation of all of Laravel's authentication features, including login, registration, password reset, email verification, and password confirmation

composer require laravel/breeze --dev


After Breeze's scaffolding is installed, you should also compile your application's frontend assets:

php artisan breeze:install blade

 

php artisan migrate

npm install

npm run dev


To Make Controller Laravel Command -  php artisan make:controller

To Make Model Laravel Command -  php artisan make:model


The Artisan test command has received a new --profile option that allows you to easily identify the slowest tests in your application - php artisan test --profile

Laravel to make rule - php artisan make:rule Rule-name


Password Helper - php artisan tinker then use \Str::password()

for 15 character use \Str::password(15)


STEP1 Create a route for any file and after it in resource folder create one file with view with like about.blade.php and return this file in using route and check how it works.

STEP2  Create above step for contact page.


For Blade template use double curly bracket -  {{$world}}

@if 

@endif  this is blade syntax


// Create a controller in Demo folder using command

php artisan make : controller Demo/DemoController

after that in Route in web.php use like this to add controller use

 App\Http\Controllers\Demo\DemoController;


after that use Route for controller like this -  Route::get('/about', [DemoController::class, 'Index']);


After that in controller create Index method using function- 


public function Index() {

}


Grouping Route by this -  

Route::controller(DemoController::class)->group(function() {

    Route::get('/about', 'Index')->name('about.page');

    Route::get('/contact', 'ContactMethod');

});


Creating Name Route by Above Method in View Page in Resources

We can also use Url route

// MiddleWare


command for creating middleware - php artisan make:middleware EnsureTokenIsValid

when u create middleware u should register it in kernal.php in protected area like - 

'check' => \App\Http\Middleware\CheckAge::class, for CheckAge Middleware


To check all route using laravel -> php artisan r:l to check all route in cmd


0 comments

Post a Comment