Posts

Showing posts with the label Laravel

Building and Publishing Laravel Packages: A Comprehensive Guide

Image
Building and Publishing Laravel Packages: A Comprehensive Guide Welcome to my blog, where we'll dive into the fascinating world of Laravel packages! Laravel, one of the most popular PHP frameworks, empowers developers to build robust and scalable web applications with ease. While Laravel itself offers a vast array of features and functionalities, there may come a time when you want to extend its capabilities or reuse certain components across multiple projects. That's where Laravel packages come in. In this comprehensive guide, I'll walk you through the step-by-step process of creating your own Laravel package and publishing it for others to use. Whether you're a seasoned Laravel developer looking to share your expertise or a beginner eager to explore the realm of package development, this blog is the perfect starting point. Here's a sneak peek at what we'll cover: U nderstanding Laravel Packages: What are Laravel packages and why do we need them? The advantages...

Send Email through Laravel

Image
  Send Email through Laravel First create a Laravel project           composer create-project laravel/laravel send-email Make configurations in the .env file Create Mail           php artisan make:mail MyTestMail The mail file will create in the app/Mail/MyTestMail.php Update the mail file as below Create a blade file and add the content which you need to send through the email Call the mail inside a controller Create a controller and import following           use App\Mail\MyTestMail;           use Mail; Call the mail and send it to the relevant user Run the project

PayPal Integration with Laravel

Image
  PayPal Integration with Laravel First create a Laravel project           composer create-project laravel/laravel paypal Create a database and connect it with the project Run below command to create payment table           php artisan make:migration create_payments_table Go to migration file and add following fields Run again php artisan migrate Run php artisan make:model Payment Run php artisan make:controller PaymentController Go to web.php and add following routes Go to https://developer.paypal.com/home Create a PayPal developer account. Add the client id and secret key to the .env file Run below code in terminal           composer require league/omnipay omnipay/paypal Add the following code to the PaymentController Create a blade file as payment.blade.php Create a simple form Run the project

Google authentication with Laravel

Image
Google authentication with Laravel First create a Laravel project           composer create-project --prefer-dist laravel/laravel googleLogin Now we have to install Jetstream           composer require laravel/jetstream Now we have to create the authentication. For this you can create basic login, registration and email verification           php artisan jetstream:install livewire Now install the node.js package          npm install Then run          npm run dev Create a database and migrate the tables          php artisan migrate Now, we will install Socialite Package that provide api to connect with google account           composer require laravel/socialite Now you have to create Google App in Google Developer Console First create an app in OAuth Consent Screen Then go to Credentials and clic...

Laravel Socialite Authentication with Facebook using Laravel 8

Image
  Laravel Socialite Authentication with Facebook using Laravel 8 Let us develop a sample web project to integrate Facebook login. First of all create a sample Laravel project using below command. If you want to know how to config Laravel in your PC please refer my blog about "First step to Laravel".          composer create-project laravel/laravel <your project name> Next we should install the Laravel Socialite Package using the composer. Note that you have to include Package in Providers if you are using below version than Laravel 8           composer require laravel/socialite Add below code to config\app.php in providers section           Laravel\Socialite\SocialiteServiceProvider::class, Add below code to in aliases section           'Socialite' => Laravel\Socialite\Facades\Socialite::class, To config\services.php include Facebook service    ...

Laravel API With Sanctum

Image
  Laravel API With Sanctum Install a Laravel project           composer create-project laravel/laravel [my-project-name] Install the package           Composer require laravel/sanctum Do the migration           php artisan vendor:publish --provider=”Laravel\Sanctum\SanctumServiceProvider”  php artisan migrate Replace the kernel.php -> middlewareGroups -> api 'api' => [     \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,     'throttle:api',     \Illuminate\Routing\Middleware\SubstituteBindings::class, ], Add this to User model           use Laravel\Sanctum\HasApiTokens; class User extends Authenticatable { use HasApiTokens, HasFactory, Notifiable;} Add this to api.php routes           Route::group(['middleware' => ['auth:sanctum']], function () { Route::get('/emp...

Laravel API With JWT Authentication

Image
Laravel API With JWT Authentication   Create a new Laravel project        composer create-project laravel/laravel [my-project-name] Install JWT auth          composer require tymon/jwt-auth Go to the app->Models->User.php and update that user model         <?php           namespace App ;           use Tymon \ JWTAuth \ Contracts \ JWTSubject ;           use Illuminate \ Notifications \ Notifiable ;           use Illuminate \ Foundation \ Auth \ User as Authenticatable ;             class User extends Authenticatable implements JWTSubject           {               use Notifiable ;               // Res...