Laravel 10 - SEO Analyzer

Touseef Afridi
12 Sep 24

Laravel 10 - SEO Analyzer

In this tutorial, we will discuss how to retrieve SEO data from a remote site using the SEO Analyzer package in Laravel 10, which helps optimize websites for better search rankings.


If you're a video person, feel free to skip the post and check out the video instead!


Step # 1 : Create fresh Laravel project.

Two commands to create fresh Laravel project.
Global Command : laravel new seo-analyzer
Or use
Non Global Command : composer create-project laravel/laravel --prefer-dist seo-analyzer

Step # 2 : Access the project.

Open a terminal (e.g., Git Bash) and navigate to your Laravel project's root folder.
Git Bash : cd c:xampp/htdocs/seo-analyzer
Next, install the required dependencies and run the Laravel Vite development server for front-end assets:
Command : npm install && npm run dev
In a new terminal window or tab (while keeping the Vite server running), navigate to the same project directory to execute further Laravel command.

Step # 3 : Install Seo-Analyzer package.

Command : composer require madeitbelgium/seo-analyzer

Step # 4 : Create a controller.

Run the following command to generate the SeoController.
Command : php artisan make:controller SeoController
Once the controller is created, replace the content of SeoController.php with the following code.
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use MadeITBelgium\SeoAnalyzer\SeoFacade as SEO;
class SeoController extends Controller
{
    public function index()
    {
        // Pass the website URL or relevant domain to the SEO::analyze() method for analysis.
        $result = SEO::analyze('https://www.lipsum.com/');
        // Output the analysis result.
        dd($result);
    }
}

Step # 5 : Update route.

Import SeoController class.
use App\Http\Controllers\SeoController;
Update route.
Route::get('/', [SeoController::class, 'index']);

Step # 6 : It's time to test.

Start the Laravel development server.
Command : php artisan serve.
Access the URL below and you will see the details related to SEO.
127.0.0.1:8000



Share this with friends!


"Give this post some love and slap that 💖 button as if it owes you money! 💸😄"
0

0 Comments

To engage in commentary, kindly proceed by logging in or registering