34ml/laravel-seo
Composer 安装命令:
composer require 34ml/laravel-seo
包简介
This package will help you to manage your website SEO easily.
关键字:
README 文档
README
This package will help you to manage your website SEO easily.
Installation
You can install the package via composer:
composer require 34ml/laravel-seo
You can publish and run the migrations with:
php artisan vendor:publish --tag="seo-migrations"
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --tag="seo-config"
This is the contents of the published config file:
return [ /* |-------------------------------------------------------------------------- | SEO status |-------------------------------------------------------------------------- | | Set SEO status, if its set to false then all pages will have | the 'noindex, nofollow' follow type and also removed the meta tags except the title tag. | */ 'seo_status' => env('SEO_STATUS', true), /* |-------------------------------------------------------------------------- | Sitemap status |-------------------------------------------------------------------------- | | Should there be a sitemap available | */ 'sitemap_status' => env('SITEMAP_STATUS', false), /* |-------------------------------------------------------------------------- | SEO title formatter |-------------------------------------------------------------------------- | | If you want a specific default format for your SEO titles, then you can | specify it here. Example could be ':text - Test site', then all pages would have | the ' - Test site' appended to the actual SEO title. | */ 'title_formatter' => ':text', /* |-------------------------------------------------------------------------- | Follow type options |-------------------------------------------------------------------------- | | Here is all the possible follow types shown in the admin panel | which is an array with key -> value. | */ 'follow_type_options' => [ 'index, follow' => 'Index and follow', 'noindex, follow' => 'No index and follow', 'index, nofollow' => 'Index and no follow', 'noindex, nofollow' => 'No index and no follow', ], /* |-------------------------------------------------------------------------- | Default follow type |-------------------------------------------------------------------------- | | Set the default follow type. | */ 'default_follow_type' => env('SEO_DEFAULT_FOLLOW_TYPE', 'index, follow'), /* * SEO default title */ 'default_seo_title' => config('app.name'), /* * SEO default description */ 'default_seo_description' => null, /* * SEO default keywords * ex : keyword1, keyword2, keyword3 */ 'default_seo_keywords' => null, /* * */ /* |-------------------------------------------------------------------------- | Sitemap models |-------------------------------------------------------------------------- | | Insert all the laravel models which should be in the sitemap | */ 'sitemap_models' => [], /* |-------------------------------------------------------------------------- | Sitemap url |-------------------------------------------------------------------------- | | Set the path of the sitemap | */ 'sitemap_path' => '/sitemap', /* |-------------------------------------------------------------------------- | Available Locales |-------------------------------------------------------------------------- | | Set the available locales in your project and fallback locale | */ 'available_locales' => ['en'], 'fallback_locale' => 'en', ];
Usage
Find the model you want to have the SEO fields on, example could be App\Models\Page, then add the SeoTrait trait:
use _34ML\SEO\Traits\SeoTrait; class Page extends Model { use SeoTrait; ... }
When you want the eloquent model to be shown in the sitemap then you need to add the SeoSiteMapTrait trait to it:
use _34ML\SEO\Traits\SeoTrait; use _34ML\SEO\Traits\SeoSiteMapTrait; class Page extends Model { use SeoTrait, SeoSiteMapTrait; ... /** * Get the Page url by item * * @return string */ public function getSitemapItemUrl() { return url($this->slug); } /** * Query all the Page items which should be * part of the sitemap (crawlable for google). * * @return Builder */ public static function getSitemapItems() { return static::all(); } }
Then go to the top of your layout blade as the default is resources/views/welcome.blade.php:
... <head> @include('laravel-seo::seo') ... </head>
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.
34ml/laravel-seo 适用场景与选型建议
34ml/laravel-seo 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.45k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2023 年 12 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「laravel-seo」 「34ML」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 34ml/laravel-seo 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 34ml/laravel-seo 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 34ml/laravel-seo 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Manage SEO tags within your Laravel application
An Elegant & flexible SEO tag builder for Laravel
Analyze keywords in the content and make diagnostics to improve the seo score of the content.
A laravel filament field that handle translation
A complete SEO package for Laravel, covering everything from meta tags to social sharing and structured data.
Laravel SEO package
统计信息
- 总下载量: 5.45k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 11
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-12-24