mitopp/easy-seo-bundle
Composer 安装命令:
composer require mitopp/easy-seo-bundle
包简介
Easy SEO Bundle for Symfony
README 文档
README
Roadmap
- Title
- Meta Tags
- Breadcrumbs
- Schema.org
- Website
Installation
composer require mitopp/easy-seo-bundle
Configuration
Create configuration file config/packages/mitopp_easy_seo.yaml.
mitopp_easy_seo: title: # Required site: 'My website' # Optional. Default: '-' separator: '|' # Optional. Default: true append_site_title: false # Add global meta tags. Optional. Default: [] meta_tags: []
Usage
Inject the SeoManagerInterface into your controller and define your SEO tags.
// Controller #[AsController] final class DefaultController extends AbstractController { public const ROUTE_NAME = 'app_homepage'; #[Route(path: '/', name: self::ROUTE_NAME)] public function __invoke(SeoManagerInterface $seoManager): Response { $seoManager->setPageTitle('Default page'); $seoManager->addMetaTag(MetaTag::create('robots', 'index,follow')); $seoManager->addMetaTag(MetaTag::create('keywords', 'default,page')); $seoManager->addMetaTag(MetaTag::create('description', 'This is a default page.')); $seoManager->addMetaTag(MetaTag::create('author', 'John Doe')); $seoManager->addMetaTag(MetaTag::create('color-schema', 'light dark')); $seoManager->addMetaTag(MetaTag::create('generator', 'Symfony')); return $this->render('page/default/index.html.twig'); } }
Rendered as...
<!-- ... --> <head> <meta charset="UTF-8"> <title>Default page - My website</title> <meta name="robots" content="index,follow"> <meta name="keywords" content="default,page"> <meta name="description" content="This is a default page."> <meta name="author" content="John Doe"> <meta name="color-schema" content="light dark"> <meta name="generator" content="Symfony"> </head> <!-- ... -->
Development
- Create a blank Symfony project at the same level as the Easy SEO Bundle.
composer create-project symfony/skeleton easy-seo-bundle-demo
- Configure Composer to use the local repository.
// composer.json { // ... "repositories": [ { "type": "path", "url": "../easy-seo-bundle" } ] // ... }
- Install the bundle.
composer require mitopp/easy-seo-bundle:@dev
- Dump the config reference from the bundle.
bin/console config:dump-reference EasySeoBundle
# Default configuration for extension with alias: "mitopp_easy_seo" # Easy SEO configuration. mitopp_easy_seo: []
- Dump the current config from the bundle.
bin/console debug:config EasySeoBundle
Current configuration for extension with alias "mitopp_easy_seo" ================================================================ mitopp_easy_seo: { }
- Debug available twig extensions.
bin/console debug:twig
统计信息
- 总下载量: 982
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-21