noud/laravel-seo-google-structured-data

Laravel SEO Google 结构化数据

v1.0.0 2020-01-11 21:10 UTC

This package is auto-updated.

Last update: 2024-09-26 20:32:37 UTC


README

Laravel SEO Google 结构化数据包。

要求

  • PHP 7.2+
  • Laravel 5.6+

安装

在您的终端/cmd中运行此命令以安装包

composer require noud/laravel-seo-google-structured-data

在模型中使用

现在您可以从 Google 结构化数据扩展您的模型

<?php

namespace App\Models;

use SEO\Google\Structured\data\Models\WebSite as GoogleWebSite;

class WebSiteGoogle extends GoogleWebSite
{}

使用的结构化数据和类型

Google Search 结构化数据

Google Search 结构化数据 符合 Schema.org

实体-关系图

Google Structured data Entity-Relationship Diagram

开发

将此包目录放置在您的项目目录旁边。

在目标项目的 composer.json 中添加以下内容

    "require": {
        "noud/laravel-seo-google-structured-data": "*"
    },
    "repositories": [
        {
            "type": "path",
            "url": "../laravel-seo-google-structured-data"
        }
    ]

在目标项目的 .env 中,我将数据库设置为备用数据库

DB_DATABASE=google-structured-data
#DB_DATABASE=seo

开发迁移

我在目标项目中这样迁移此模式

php artisan migrate --realpath --path=/var/www/laravel-seo-google-structured-data/src/database/migrations

开发模型生成

在目标项目中,在 config/models.php 中设置路径和命名空间

        'path' => app_path('Models-google-structured-data'),
        'namespace' => 'SEO\Google\Structured\data\Models',

我在目标项目中这样从此模式生成模型

php artisan code:models --schema=google-structured-data

然后将 app/Models-google-structured-data 中的所有内容复制到包中。