Seo Manager Package for Laravel ( with Localization )

Overview

Seo Manager Package for Laravel ( with Localization )

MadeWithLaravel.com shield

lionix/seo-manager package will provide you an interface from where you can manage all your pages metadata separately and get dynamically changing content. Let's see how.

Update:

After updating to version > v1.2.* you have to run:

php artisan vendor:publish --provider="Lionix\SeoManager\SeoManagerServiceProvider" --tag=config --force
php artisan vendor:publish --provider="Lionix\SeoManager\SeoManagerServiceProvider" --tag=assets --force

and

php artisan migrate

to publish latest configs and new migration files.

Localization

In version v1.2.* you will have availability to localize your metadata and set translates to your data.

For that, you just should add your available locales with top right button "Add Locales" and chose locale for which you want to add translations.

That's it, Package will automatically detect your locale from website and will set needed translations, you don't need to do any other configs. Easy, isn't it?

Installation

You can install the package via composer:

composer require lionix/seo-manager

Publishing package files

php artisan vendor:publish --provider="Lionix\SeoManager\SeoManagerServiceProvider"

This command will create config/seo-manager.php file and will copy package assets directory to public/vendor/lionix.

Configurations

In config/seo-manager.php file you can do the following configurations:

return [
    /**
     * Database table name where your manager data will be stored
     */
    'database' => [
            'table' => 'seo_manager',
            'locales_table' => 'seo_manager_locales',
            'translates_table' => 'seo_manager_translates'
        ],
        
    /**
     * Set default locale,
     * It will be added as default locale
     * when locales table migrated
     */
    'locale' => 'en',

    /**
     * Path where your eloquent models are
     */
    'models_path' => '',

    /**
     * Route from which your Dashboard will be available
     */
    'route' => 'seo-manager',

    /**
     * Middleware array for dashboard
     * to prevent unauthorized users visit the manager
     */
    'middleware' => [
        //  'auth',
    ],

    /**
     * Routes which shouldn't be imported to seo manager
     */
    'except_routes' => [
        'seo-manager',
        'admin'
        //
    ],

    /**
     * Columns which shouldn't be used ( in mapping )
     */
    'except_columns' => [
        // "created_at",
        // "updated_at",
    ],

    /**
     * Set this parameter to true
     * if you want to have "$metaData" variable
     * shared between all views in "web" middleware group
     */
    'shared_meta_data' => false
];

After finishing with all configurations run php artisan migrate to create SEO manager table.

That's it, now your SEO manager will be available from /seo-manager URL (or, if you changed route config, by that config URL)

Usage

After visiting your dashboard URL you have to import your routes to start to manage them.

routes import

Route importing will store all your GET routes into the database ( except the ones which specified in "except_routes" configs).

imported routes

Let the fun begin!

Mapping

To get dynamically changing metadata you should map your route params to the correct Models.

Param: Route param

Model: Eloquent Model which you are using to get the record by route param

Find By: Database table column name which you are using to get the record by route param

Use Columns: Database table columns which we should use for further mapping

Note: If you have appended attributes inside your model via protected $appends and you want to use them in mapping you have to use Lionix\SeoManager\Traits\Appends; trait inside your model.

Mapping available only if your route has params

Next steps you can do, is to set Keywords, Description, Title, URL, Author, Title Dynamic, OpenGraph Data.

About "Title Dynamic":

Here you can drag & drop your mapped params, your title and write custom text to generate the dynamic title for your page. Every time your "title" will be changed or your mapped params value changed, the dynamic title will be changed automatically.

About "Open Graph":

Here you can write your open graph data or map your fields to mapping based on params.

Example Usage

Via SeoManager Facade

use Lionix\SeoManager\Facades\SeoManager;
This will return an array with all your SEO Manager data
SeoManager::metaData();

Example:

array:13 [▼
  "keywords" => "First Keyword, Second, Third"
  "description" => "Test Description"
  "title" => "Test Titile"
  "url" => "http://example.com/users/1"
  "author" => "Sergey Karakhanyan"
  "title_dynamic" => "Test Titile - Custom Text - Test User Name "
  "og:url" => "http://example.com/users/1"
  "og:type" => "website"
  "og:image:url" => "https://wallpaperbrowse.com/media/images/3848765-wallpaper-images-download.jpg"
  "og:title" => "Test Titile - Custom Open Graph Text"
  "og:locale" => "en_GB"
  "og:site_name" => "Seo Manager Package"
  "og:description" => "Open Graph Description"
]

SeoManager::metaData(); method can receive property variable to get the value of some property

Example:

SeoManager::metaData('keywords'); will return "First Keyword, Second, Third"

To get only OpenGraph data array:
SeoManager::metaData('og_data');

Example

array:7 [▼
  "og:url" => "http://example.com/users/1"
  "og:type" => "website"
  "og:image:url" => "https://wallpaperbrowse.com/media/images/3848765-wallpaper-images-download.jpg"
  "og:title" => "Test Titile - Custom Open Graph Text"
  "og:locale" => "en_GB"
  "og:site_name" => "Seo Manager Package"
  "og:description" => "Open Graph Description"
]
Aliases

SeoManager::metaKeywords()

SeoManager::metaTitle()

SeoManager::metaDescription()

SeoManager::metaUrl()

SeoManager::metaAuthor()

SeoManager::metaTitleDynamic()

SeoManager::metaOpenGraph() - Can receive property variable to get the value of some OG property

Example

SeoManager::metaOpenGraph('og:image:url')

Will return "https://wallpaperbrowse.com/media/images/3848765-wallpaper-images-download.jpg"

Via helper functions

metaData()

metaKeywords()

metaTitle()

metaDescription()

metaUrl()

metaAuthor()

metaTitleDynamic()

metaOpenGraph()

Via @Blade directives

You can use this blade directives in your view files to get metadata.

@meta

Output Example

<meta property="keywords" content="First Keyword, Second, Third">
<meta property="description" content="Test Description">
<meta property="title" content="Test Titile">
<meta property="url" content="http://packages.loc/users/1">
<meta property="author" content="Sergey Karakhanyan">
<meta property="title_dynamic" content="Test Titile - Custom Text - Test User Name ">
<meta property="og:url" content="http://packages.loc/users/1">
<meta property="og:type" content="website">
<meta property="og:image:url" content="https://wallpaperbrowse.com/media/images/3848765-wallpaper-images-download.jpg">
<meta property="og:title" content="Test Titile - Custom Open Graph Text">
<meta property="og:locale" content="en_GB">
<meta property="og:site_name" content="Seo Manager Package">
<meta property="og:description" content="Open Graph Description">

@meta can receive property param

@meta('description')

Output Example

<meta property="description" content="Test Description">

Note: You can't add open graph properties to @meta() like @meta('og:url') But you can get only OpenGraph meta data by @meta('og_data'). If you want to get concrete OG param meta tag you can use @openGraph (similar to @meta('og_data')) and pass param there like @openGraph('og:url)

Note #2: If you want to do modifications in your og data and display it manually, you should do that before @meta

Example:

<meta property="og:image:url" content="{{ asset(metaOpenGraph('og:image:url')) }}">
@meta
Aliases

@keywords

@url

@author

@description

@title

@openGraph

@titleDynamic - will return dynamically generated title which you can use inside your <title></title> tags.

Contributing

How to start developing on this project

  1. Install the module in a existing Laravel project and check if the module is working.

  2. Delete the folder vendor/lionix/seo-manager.

  3. Copy the fork of the module in the vendor/lionix/seo-manager folder (don't know how to make a fork? https://kbroman.org/github_tutorial/pages/fork.html)

  4. Add the following line to your webpack.mix.js mix.js('vendor/lionix/seo-manager/src/vue/seo-manager.app.js', 'public/vendor/lionix/js');

  5. run the NPM Watch command npm run watch

  6. If everything works fine, you can start developing on the module

  7. PLEASE REMIND TO COPY YOUR public/vendor/lionix/js/seo-manager.app.js TO vendor/lionix/seo-manager/src/assets/seo-manager.app.js

Credits

Comments
  • Help in understanding how it works?

    Help in understanding how it works?

    Hey. I cannot understand why when I do set params mapping "Find By:" is not shown. I have a route Route::get('post/{slug}', 'PostController@index')->name('post');, I have a model for an example called Post. I see my route in SEO manager, I click on edit, I see my model and all other fields are empty. Tell me what I'm doing wrong. Thanks for any help :) image

    opened by web-vitality 5
  • Param mapping error

    Param mapping error

    Hi, there is an error when using param mapping, I think it does not fetch the models list and expects some params, the dynamic url is /{{slug}} "message": "Too few arguments to function Illuminate\\Foundation\\Console\\Kernel::__construct(), 0 passed in \vendor\\lionix\\seo-manager\\src\\Traits\\SeoManagerTrait.php on line 116 and exactly 2 expected", "exception": "Symfony\\Component\\Debug\\Exception\\FatalThrowableError", "file": "vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Console\\Kernel.php", "line": 80, "trace": [ { "file": "\vendor\\lionix\\seo-manager\\src\\Traits\\SeoManagerTrait.php", "line": 116, "function": "__construct", "class": "Illuminate\\Foundation\\Console\\Kernel", "type": "->" },

    opened by mshoaibdev 4
  • array_merge(): Expected parameter 2 to be an array, null given on seo-manager\src\routes\seo-manager.php:3

    array_merge(): Expected parameter 2 to be an array, null given on seo-manager\src\routes\seo-manager.php:3

    i am getting this error while installing package ...?

    ErrorException : array_merge(): Expected parameter 2 to be an array, null given

    at E:\xampp\htdocs\Personal\brandzshop\vendor\lionix\seo-manager\src\routes\seo-manager.php:3 1| <?php 2| $web = ['web'];

    3| $middleware = array_merge($web, config('seo-manager.middleware')); 4| Route::group([ 5| 'middleware' => $middleware, 6| 'prefix' => config('seo-manager.route'), 7| 'as' => 'seo-manager.', 8| 'namespace' => 'Lionix\SeoManager' 9| ], function () {

    Exception trace:

    1 array_merge() E:\xampp\htdocs\Personal\brandzshop\vendor\lionix\seo-manager\src\routes\seo-manager.php:3

    2 require("E:\xampp\htdocs\Personal\brandzshop\vendor\lionix\seo-manager\src\routes\seo-manager.php") E:\xampp\htdocs\Personal\brandzshop\vendor\laravel\framework\src\Illuminate\Support\ServiceProvider.php:78

    Please use the argument -v to see more details. PS E:\xampp\htdocs\Personal\brandzshop> php artisan vendor:publish --provider="Lionix\SeoManager\SeoManagerServiceProvider" --tag=assets --force
    ErrorException : array_merge(): Expected parameter 2 to be an array, null given

    at E:\xampp\htdocs\Personal\brandzshop\vendor\lionix\seo-manager\src\routes\seo-manager.php:3 1| <?php 2| $web = ['web'];

    3| $middleware = array_merge($web, config('seo-manager.middleware')); 4| Route::group([ 5| 'middleware' => $middleware, 6| 'prefix' => config('seo-manager.route'), 7| 'as' => 'seo-manager.', 8| 'namespace' => 'Lionix\SeoManager' 9| ], function () {

    Exception trace:

    1 array_merge() E:\xampp\htdocs\Personal\brandzshop\vendor\lionix\seo-manager\src\routes\seo-manager.php:3

    2 require("E:\xampp\htdocs\Personal\brandzshop\vendor\lionix\seo-manager\src\routes\seo-manager.php") E:\xampp\htdocs\Personal\brandzshop\vendor\laravel\framework\src\Illuminate\Support\ServiceProvider.php:78

    Please use the argument -v to see more details.

    opened by ghost 3
  • Auto redirecting to the previous page when auth middleware defined

    Auto redirecting to the previous page when auth middleware defined

    It is not working with auth middleware or even with any other middleware. When defining custom middleware it is showing an error auth()->user() null. But, I am already logged in.

    image

    opened by devzakir 2
  • models path error in production env

    models path error in production env

    When I'm in a development environment, the library works perfect. but when I publish the site where I am occupying the library , Therefore the dropdown to select the model doesn't work.

    I am presenting the following warnings in developer tools console:

    [Vue warn]: Invalid prop: type check failed for prop "options". Expected Array, got Undefined.
    
    found in
    
    ---> <VueMultiselect>
           <MappingModal> at packages/lionix/seo-manager/src/vue/components/routes/partials/modals/MappingModal.vue
             <Routes> at packages/lionix/seo-manager/src/vue/components/routes/Routes.vue
               <App> at packages/lionix/seo-manager/src/vue/App.vue
                 <Root>
    
    [Vue warn]: Error in getter for watcher "filteredOptions": "TypeError: Cannot read property 'concat' of undefined"
    
    found in
    
    ---> <VueMultiselect>
           <MappingModal> at packages/lionix/seo-manager/src/vue/components/routes/partials/modals/MappingModal.vue
             <Routes> at packages/lionix/seo-manager/src/vue/components/routes/Routes.vue
               <App> at packages/lionix/seo-manager/src/vue/App.vue
                 <Root>
    
    TypeError: Cannot read property 'concat' of undefined
        at VueComponent.filteredOptions (seo-manager.app.js:22022)
        at Watcher.get (seo-manager.app.js:3671)
        at Watcher.evaluate (seo-manager.app.js:3778)
        at VueComponent.computedGetter [as filteredOptions] (seo-manager.app.js:4036)
        at VueComponent.<anonymous> (seo-manager.app.js:1008)
        at Watcher.get (seo-manager.app.js:3671)
        at Watcher.run (seo-manager.app.js:3748)
        at flushSchedulerQueue (seo-manager.app.js:3510)
        at Array.<anonymous> (seo-manager.app.js:2366)
        at flushCallbacks (seo-manager.app.js:2287)
    

    my seo-manager.php is:

    <?php
    
    return [
        /**
         * Database table name where your manager data will be stored
         */
        'database' => [
            'table' => 'seo_manager',
            'locales_table' => 'seo_manager_locales',
            'translates_table' => 'seo_manager_translates'
        ],
    
        /**
         * Set default locale,
         * It will be added as default locale
         * when locales table migrated
         */
        'locale' => 'en',
    
        /**
         * Path where your eloquent models are
         * Leave this config empty if you want to look for models in whole project
         */
        'models_path' => '',
    
        /**
         * Route from which your Dashboard will be available
         */
        'route' => 'admin/seo-manager',
    
        /**
         * Middleware array for dashboard
         * to prevent unauthorized users visit the manager
         */
        'middleware' => [
             'web',
             'auth',
             'admin',
        ],
    
        /**
         * Routes which shouldn't be imported to seo manager
         */
        'except_routes' => [
            'seo-manager',
            'admin'
            //
        ],
    
        /**
         * Columns which shouldn't be used ( in mapping )
         */
        'except_columns' => [
            // "created_at",
            // "updated_at",
        ],
    
        /**
         * Set this parameter to true
         * if you want to have "$metaData" variable
         * shared between all views in "web" middleware group
         */
        'shared_meta_data' => false
    ];
    

    These errors or warnings only happen when I am in the production environment

    opened by marvintrejoxi 2
  • Unable to install

    Unable to install

    When trying to add this package using this command composer require lionix/seo-manager

    Got these errors Problem 1 - Conclusion: remove laravel/framework v5.8.8 - Conclusion: don't install laravel/framework v5.8.8 - lionix/seo-manager v1.2.0 requires illuminate/support 5.5.* || 5.6.* || 5.7.* -> satisfiable by illuminate/support[5.5.x-dev, 5.6.x-dev, 5.7.17, 5.7.18, 5.7.19, 5.7.x-dev, v5.5.0, v5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5.5.34, v5.5.35, v5.5.36, v5.5.37, v5.5.39, v5.5.40, v5.5.41, v5.5.43, v5.5.44, v5.6.0, v5.6.1, v5.6.10, v5.6.11, v5.6.12, v5.6.13, v5.6.14, v5.6.15, v5.6.16, v5.6.17, v5.6.19, v5.6.2, v5.6.20, v5.6.21, v5.6.22, v5.6.23, v5.6.24, v5.6.25, v5.6.26, v5.6.27, v5.6.28, v5.6.29, v5.6.3, v5.6.30, v5.6.31, v5.6.32, v5.6.33, v5.6.34, v5.6.35, v5.6.36, v5.6.37, v5.6.38, v5.6.39, v5.6.4, v5.6.5, v5.6.6, v5.6.7, v5.6.8, v5.6.9, v5.7.0, v5.7.1, v5.7.10, v5.7.11, v5.7.15, v5.7.2, v5.7.20, v5.7.21, v5.7.22, v5.7.23, v5.7.26, v5.7.27, v5.7.28, v5.7.3, v5.7.4, v5.7.5, v5.7.6, v5.7.7, v5.7.8, v5.7.9].

    opened by prappo 2
  • SeoManager object error when seoManager variable is null

    SeoManager object error when seoManager variable is null

    When you don't have any data in SeoManger table for the current URI, it throws an error of the object, because it is null, for that you need to just check if it is empty just return a blank string. I don't know how to submit the PR.

    to fixed the problem just add this after $metaData = []; if(empty($seoManager)){ return ''; }

    opened by mshoaibdev 2
  • Delete url not working - CSRF issue

    Delete url not working - CSRF issue

    As I already said in #15 there where still some CSRF issues.

    Found out today that the delete function is not working right now. Needs almost same fix as #15.

    opened by robertvanlienden 1
  • Backend fatal error

    Backend fatal error

    Backend fatal error: PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Call to a member function uri() on null in /home/user/project/vendor/lionix/seo-manager/src/Traits/SeoManagerTrait.php:199\nStack trace:\n#0 /home/user/project/vendor/lionix/seo-manager/src/SeoManager.php(24): Lionix\SeoManager\SeoManager->getMetaData('')\n#1

    /home/user/project/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(221): Lionix\SeoManager\SeoManager->metaData('')\n#2 /home/user/project/vendor/lionix/seo-manager/src/helpers/helpers.php(8): Illuminate\Support\Facades\Facade::__callStatic('metaData', Array)\n#3

    /home/user/project/vendor/lionix/seo-manager/src/SeoManagerServiceProvider.php(82): metaData('')\n#4 [internal function]: Lionix\SeoManager\SeoManagerServiceProvider->Lionix\SeoManager\{closure}('')\n#5

    /home/user/project/vendor/laravel/framework/src/Illuminate/View/Compilers/BladeCompiler.php(347): call_user_func(Object(Closure), '')\n#6 /home/user in /home/user/project/vendor/lionix/seo-manager/src/Traits/SeoManagerTrait.php on line 199\n, referer: http://www.mywebsite.com

    opened by awolad 1
  • support laravel 8

    support laravel 8

    Hi Owner,

    I am not so sure if this is the correct way to pull request for the adjustment i done. i desperately need this cool package to be able to support laravel 8 so i did little changes to php version and also illuminate/support.

    to be very honest, i had tried adding

    || 8.*
    

    but it seem still doesn't work. so i changed to ~8 and it works on my side.

    pls verify. thanks

    opened by wikichua 0
  • Feature/add howto develop

    Feature/add howto develop

    @karakhanyans Added some info to the README about how to get this package ready for development.

    This was the way I did it, maybe if there are better ways to start developing. Feel free to update the information I added if there are easy'er ways to start developing, or maybe add some contribution guidelines to the readme?

    If I did this the right way, I hope to help people to easy start developing on this project :-).

    opened by robertvanlienden 0
  • The parametres I add disappear after a refresh.

    The parametres I add disappear after a refresh.

    It's not working for me at all, I try to add some stuff like title and all, but when I refresh it all disappears, I get a lot of errors on the console too. Can you tell me what's wrong and how to fix it.Thanks. Screenshot_2021-10-05_02_47_38

    opened by mmassymassy 0
Releases(v1.4.6)
Owner
Lionix
Software Development Company
Lionix
Laravel SEO - This is a simple and extensible package for improving SEO via meta tags, such as OpenGraph tags.

This is a simple and extensible package for improving SEO via meta tags, such as OpenGraph tags.

ARCHTECH 191 Dec 30, 2022
Laravel Seo package for Content writer/admin/web master who do not know programming but want to edit/update SEO tags from dashboard

Laravel Seo Tools Laravel is becoming more and more popular and lots of web application are developing. In most of the web application there need some

Tuhin Bepari 130 Dec 23, 2022
SEO Helper is a package that provides tools and helpers for SEO (Search Engine Optimization).

SEO Helper By ARCANEDEV© SEO Helper is a package that provides tools and helpers for SEO (Search Engine Optimization). Feel free to check out the rele

ARCANEDEV 301 Nov 25, 2022
A Laravel Larex plugin to import/export localization strings from/to Crowdin

Laravel Larex: Crowdin Plugin A Laravel Larex plugin to import/export localization strings from/to Crowdin ?? Requirements PHP 7.4 | 8.0 Laravel ≥ 7 L

Luca Patera 4 Oct 27, 2021
Easy Localization for Laravel

Query String Localization Package for Laravel Use this package to localize your laravel application via query strings easily. Features: Localization b

Cosnavel 50 Dec 15, 2021
A package to handle the SEO in any Laravel application, big or small.

Never worry about SEO in Laravel again! Currently there aren't that many SEO-packages for Laravel and the available ones are quite complex to set up a

Ralph J. Smit 267 Jan 2, 2023
A convenient helper for using the laravel-seo package with Filament Admin and Forms

Combine the power of Laravel SEO and Filament PHP. This package is a convenient helper for using the laravel-seo package with Filament Admin and Forms

Ralph J. Smit 39 Dec 21, 2022
Laravel package for manage your URL redirects in database or other sources to get better SEO results

Laravel 8 and 9 package to manage URL redirections inside your Laravel application using different data sources. It allows a better SEO support for your Laravel site.

Siro Díaz Palazón 51 Sep 21, 2022
Laravel Manager - provides some manager functionality for Laravel

Laravel Manager Laravel Manager was created by, and is maintained by Graham Campbell, and provides some manager functionality for Laravel. Feel free t

Graham Campbell 371 Dec 17, 2022
Laravel Manager provides some manager functionality for Laravel

Laravel Manager Laravel Manager was created by, and is maintained by Graham Campbell, and provides some manager functionality for Laravel. Feel free t

Graham Campbell 371 Jul 11, 2022
SEO Tools for Laravel

SEOTools - SEO Tools for Laravel and Lumen SEOTools is a package for Laravel 5.8+ and Lumen that provides helpers for some common SEO techniques. Curr

Artesãos 2.7k Dec 31, 2022
This repo is for the Laracon 2021 talk "Manage SEO with Laravel and Nova"

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Kristin 7 Dec 9, 2022
Easily setup SEO in your laravel project with lara-head :heart: @code4mk

installation composer require code4mk/lara-head usage meta ~ inside controller use Khead; class Test { public function home() { Khead::setMeta

null 173 Dec 23, 2022
This is an open source demo of administration panel for polymorphic relationship and SEO content

Laravel SEO admin This application demonstrates usage of polymorphic relationships described at (http://maxoffsky.com/code-blog/using-polymorphic-rela

Maksim Surguy 127 Oct 11, 2022
A Laravel package to retrieve key management from AWS Secrets Manager

A Laravel package to retrieve key management from AWS Secrets Manager Communication via AWS Secrets Manager may incur unnecessary charges. So we devel

null 2 Oct 10, 2022
laravel - Potion is a pure PHP asset manager for Laravel 5 based off of Assetic.

laravel-potion Potion is a pure PHP asset manager for Laravel based off of Assetic. Description Laravel 5 comes with a great asset manager called Elix

Matthew R. Miller 61 Mar 1, 2022
Laravel-tagmanager - An easier way to add Google Tag Manager to your Laravel application.

Laravel TagManager An easier way to add Google Tag Manager to your Laravel application. Including recommended GTM events support. Requirements Laravel

Label84 16 Nov 23, 2022
Migrator is a GUI migration manager for Laravel which you can create, manage and delete your migration.

Migrator Migrator is a GUI migration manager for Laravel which you can create, manage and delete your migration. Installation: To install Migrator you

Reza Amini 457 Jan 8, 2023
Bring multi themes support to your Laravel application with a full-featured Themes Manager

Introduction hexadog/laravel-themes-manager is a Laravel package which was created to let you developing multi-themes Laravel application. Installatio

hexadog 86 Dec 15, 2022