Laravel 12 - Smart Seo Analyzer Tool

Touseef Afridi
25 Jul 25

Laravel 12 - Smart Seo Analyzer Tool

In this tutorial, we will learn how to integrate an SEO analyzer in Laravel 12 using a package. Easily check meta tags, titles, keywords, and improve your website’s SEO without building the tool from scratch.


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


Quick Overview

This guide demonstrates how to integrate SEO analysis into a Laravel 12 project using the SEO-Analyzer package. To begin, you’ll create a fresh Laravel application and install the package via Composer. After setup, a SeoController is generated to make use of the SeoFacade for analyzing SEO data from any given website. The index method within this controller is responsible for retrieving key SEO metrics such as headers, links, images, and keywords. By registering the appropriate route in the routes/web.php file and launching the Laravel development server, you can instantly view the SEO analysis results in your browser. This integration offers a practical way to incorporate SEO insights directly into your Laravel application making it easier to evaluate on-page elements and optimize for search visibility. It’s especially useful for building reporting tools or enhancing SEO-driven features in Laravel-based solutions.

Step # 1 : Start a New Laravel 12 Project.

To get started, ensure the Laravel installer is available globally on your machine. If it’s not already installed, run.
composer global require laravel/installer
This gives you the ability to create Laravel projects quickly with a simple terminal command. If it’s already installed, you can skip this step. Now let’s create a fresh Laravel 12 project. Run the following command to generate a new project named seo-analyzer.
laravel new seo-analyzer
As the installer walks you through setup, choose the following options when prompted.
  • Starter Kit: None.
  • Testing Framework: Pest.
  • Database: MySQL.
  • Run default migrations: Yes.
  • Run npm install and npm run build: Yes.

Once the process completes, you’ll have a clean Laravel 12 app ready, with Pest set up for testing, MySQL as your database, and the frontend assets compiled. You're now ready to move on to development.

Step # 2 : Move Into Your Project Folder.

Once your Laravel 12 project has been created, open your terminal or Git Bash and navigate to the root directory of the project. This is where you'll be running most of your development commands. If you installed Laravel in c:/xampp/htdocs/seo-analyzer, you can move into it by running.
cd c:xampp/htdocs/seo-analyzer
Make sure you’re inside this folder before continuing with any Laravel-specific commands or development tasks.

Step # 3 : Install the SEO Analyzer Package.

Now that your Laravel project is set up, it’s time to bring in the SEO analysis functionality. The seo-analyzer package offers a convenient way to inspect various SEO elements of any website, including metadata, headings, links, images, and keywords. To install the package, run the following command in your terminal from the root of your Laravel project.
composer require madeitbelgium/seo-analyzer
This will download and configure the package along with any required dependencies. Once installed, you'll be ready to start pulling SEO insights directly from your Laravel application without writing complex scraping logic yourself.

Step # 4: Create a SeoController.

To put the SEO Analyzer package to work, let’s create a dedicated controller that will handle the logic for analyzing a website’s SEO data. This controller will use the package’s functionality to fetch and display insights based on a provided URL. Start by running the following Artisan command to generate the controller.
php artisan make:controller SeoController
Once the controller is generated, navigate to app/Http/Controllers/SeoController.php and replace its contents with the code below.
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use MadeITBelgium\SeoAnalyzer\SeoFacade as SEO;
class SeoController extends Controller
{
    public function index()
    {
        // Analyze the given website URL and retrieve the SEO analysis result.
        $result = SEO::analyze('https://getbootstrap.com/');
        // Display the analysis result using Laravel's dd() helper.
        dd($result);
    }
}
This method uses the SeoFacade provided by the package to analyze a test website and dumps the results using Laravel’s dd() helper. This gives you a quick look at the SEO data structure before moving forward with displaying or processing it further.

Step # 5 : Define a Route for SEO Analysis.

Now that your SeoController is ready, it’s time to wire it up to a route so the SEO analysis can be triggered from the browser. Open your routes/web.php file and start by importing the controller at the top.
use App\Http\Controllers\SeoController;
Then, add the following route definition.
Route::get('/', [SeoController::class, 'index']);
With this in place, visiting your app's root URL (like http://localhost:8000) will automatically call the index method in the SeoController. This executes the SEO analysis for the given site and displays the results directly in the browser. It’s a quick and easy way to confirm that everything’s working as expected.

Step # 6 : Run and Test the SEO Analyzer.

Now that everything is set up, it’s time to test your integration. Start the Laravel development server by running the following command in your terminal.
php artisan serve
Once the server is running, open your browser and go to: http://127.0.0.1:8000. This will trigger the SEO analysis for the URL you configured in your controller (https://getbootstrap.com/). The results such as headers, links, images, and keywords, will be displayed using Laravel's dd() helper. This confirms that the SEO analyzer package is working correctly and gathering valuable SEO data from the target website.

To narrow down your analysis and focus on particular aspects like keywords, headers, links, and images, you can update the index method in your SeoController. Instead of dumping the entire analysis result, you’ll extract and display only the specific sections you're interested in. Update your controller method like this.
public function index()
{
    // Analyze the given website URL for SEO details.
    $result = SEO::analyze('https://getbootstrap.com/');
    // Display specific analysis results for headers, links, images, and keywords.
    dd(
        $result['full_page']['headers'],
        $result['full_page']['links'],
        $result['full_page']['images'],
        $result['full_page']['keywords']
    );
}
Now when you refresh the page in your browser, you’ll see structured insights for each of these elements. This gives you a clearer view of the site’s SEO structure and helps you pinpoint areas that need optimization.

Conclusion

By following this guide, you've successfully added SEO analysis capabilities to your Laravel 12 application using the seo-analyzer package. From setting up a fresh Laravel project to installing the package, creating a controller, and retrieving targeted insights like headers, links, images, and keywords, you now have a solid base for evaluating SEO performance within your app. This setup is ideal for developers building tools like CMS platforms, marketing dashboards, or internal analytics systems where SEO data plays a key role. And since the structure is clean and modular, it's easy to extend. You can add features like custom URL inputs, save analysis results to the database, or even schedule regular SEO scans using Laravel's scheduler.
For deeper customization or advanced use cases, be sure to explore the official seo-analyzer documentation.
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