PHPackages                             nicxonsolutions/nicxon-seo - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. nicxonsolutions/nicxon-seo

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

nicxonsolutions/nicxon-seo
==========================

Professional SEO toolkit for Laravel by Robert Nicjoo

v1.0.17(1mo ago)013MITPHPPHP ^8.1

Since Apr 15Pushed 1mo agoCompare

[ Source](https://github.com/robertnicjoo/nicxon-seo)[ Packagist](https://packagist.org/packages/nicxonsolutions/nicxon-seo)[ Docs](https://nicxonsolutions.com)[ RSS](/packages/nicxonsolutions-nicxon-seo/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (1)Versions (19)Used By (0)

Nicxon SEO
==========

[](#nicxon-seo)

**A professional, Yoast-like SEO toolkit for Laravel.**

Developed by **Robert Nicjoo** () at [PT. Nicxon International Solutions](https://nicxonsolutions.com)

---

🚀 Installation
--------------

[](#-installation)

### 1. Require the Package

[](#1-require-the-package)

Run the following commands in your terminal from the root of your Laravel project:

```
composer require nicxonsolutions/nicxon-seo
php artisan migrate
php artisan storage:link
```

### 2. Publish Configuration (Optional)

[](#2-publish-configuration-optional)

To customize the route middlewares (e.g., adding admin-only access), publish the config file:

```
php artisan vendor:publish --tag=nicxon-config
```

Then, edit `config/nicxon-seo.php` to add your own middlewares (e.g., `admin`, `permission:manage-seo`).

🛠 Usage
-------

[](#-usage)

### 1. Prepare your Models

[](#1-prepare-your-models)

Add the `HasNicxonSeo` trait to any model you want to have SEO capabilities (e.g., Post, Page, Product).

```
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Nicxon\Seo\Traits\HasNicxonSeo;

class Post extends Model
{
    use HasNicxonSeo;
}
```

### 2. Global SEO Settings

[](#2-global-seo-settings)

Nicxon SEO comes with a built-in management panel for your website's main SEO (Home page fallback and site-wide defaults). You can access it at:

`YOUR_URL/admin/seo`

This is where you set the default meta title, description, and social sharing image that will be used when no specific model data is available.

### 3. Display the Form Fields

[](#3-display-the-form-fields)

Include the Nicxon SEO component inside your admin create/edit forms. **Note:** Ensure your form has `enctype="multipart/form-data"` to support image uploads.

```

    @csrf

    @include('nicxon-seo::form-fields', ['model' => $post ?? null])

    Save Post

```

### 4. Handle the Controller Logic

[](#4-handle-the-controller-logic)

Save the SEO metadata using the provided `updateSeo` helper method.

```
public function store(Request $request)
{
    // 1. Create/Update your primary model
    $post = Post::create($request->all());

    // 2. Handle Social Image Upload
    $imgPath = null;
    if ($request->hasFile('nicxon_og_image')) {
        $imgPath = $request->file('nicxon_og_image')->store('seo', 'public');
    }

    // 3. Save SEO Metadata via the Nicxon Trait
    $post->updateSeo([
        'nicxon_seo_title'       => $request->nicxon_seo_title,
        'nicxon_seo_description' => $request->nicxon_seo_description,
        'nicxon_og_image'        => $imgPath
    ]);

    return redirect()->back()->with('success', 'Post and SEO data saved!');
}
```

### 5. Frontend Integration (Zero-Config)

[](#5-frontend-integration-zero-config)

Add the `@nicxonSeo` directive to the `` of your `app.blade.php` layout. It automatically detects if a model (like `$post`, `$page`, or `$product`) is present in the current view. If no model is found, it intelligently falls back to your Global SEO settings.

```
>

        @nicxonSeo

        @yield('content')

```

**Note on Title Suffix:** You can customize how your brand appears across all sub-pages (e.g., `Post Title | YourBrand`) by modifying the `title_suffix` in your `config/nicxon-seo.php`.

### 💻 Console Commands

[](#-console-commands)

Monitor your SEO health directly from the terminal with the built-in stats command:

```
php artisan nicxon:seo-stats
```

This command provides a summary of how many models are optimized and whether your Global SEO settings are configured correctly.

---

✨ Features
----------

[](#-features)

- **Zero-Configuration:** Simply drop @nicxonSeo in your head. It intelligently detects content models or uses Global defaults.
- **Global SEO Panel:** Dedicated interface at /admin/seo to manage site-wide titles, descriptions, and share images.
- **Polymorphic Storage:** One centralized table handles SEO for all models without modifying your existing database schema.
- **Real-time Preview:** Live Google search snippet preview with dynamic "Traffic Light" feedback.
- **SEO Scoring:** Visual indicators (Green/Yellow/Red) based on industry-standard character lengths.
- **Social Ready:** Automatic generation of OpenGraph (OG) tags and Twitter Cards.
- **Pro-Grade Rendering Engine:**
    - **XSS Protection:** All metadata is automatically escaped using Laravel's `e()` helper to prevent Cross-Site Scripting.
    - **HTML Integrity:** Special characters (like `"`, `&`, and `
