定制 skuola/sitemap-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

skuola/sitemap-bundle

Composer 安装命令:

composer require skuola/sitemap-bundle

包简介

Sitemap generator for Symfony 2 project

README 文档

README

SensioLabsInsight Build Status

##Installation

Install the bundle:

composer require skuola/sitemap-bundle

Register the bundle in app/AppKernel.php:

<?php
// app/AppKernel.php
public function registerBundles()
{
    return array(
        // ...
        new Skuola\SitemapBundle\SkuolaSitemapBundle()
    );
}

##Basic Configuration

# app/config/config.yml
skuola_sitemap:
    scheme: http
    host: www.example.com
    db_driver: orm # orm|mongodb
    sitemaps:
        FirstSitemap:    
            index:
                # If you want to specify a custom base url for sitemap_index
                base_url: ~ # Or your custom base url: http://%domain%/sitemaps/home
                path: ~ # %kernel.root_dir%/../web/sitemap_index.xml
            path: ~ # %kernel.root_dir%/../web/sitemap.xml
            routes:
                category_show:
                    options:
                        slug:
                            repository:
                                object: SkuolaTestBundle:Category
                                property: slug
                                method: findPublic
                        type:
                            defaults: ["free", "open-source", "premium"]
                    changefreq: weekly
                    priority: 0.5
                open_source_post:
                    options:
                        slug:
                            repository:
                                object: SkuolaTestBundle:Category
                                property: slug
                                method: findBySlug
                                #Call findWithSlug($slug) method with custom arguments
                                arguments: ["open-source"]
                    changefreq: weekly
                    priority: 0.3
                tag_show:
                    options:
                        slug:
                            repository:
                                object: SkuolaTestBundle:Tag
                                property: slug
                        type:
                            repository:
                                object: SkuolaTestBundle:Type
                                property: id
                                method: findEnabled
                             #merge repository results with defaults options   
                            defaults: [0]
                    changefreq: weekly
                    priority: 0.8

##Multi Sitemaps

skuola_sitemap:
    scheme: http
    host: www.example.com
    db_driver: orm
    sitemaps:
        Blog:
            index:
                base_url: http://www.example.com/sitemaps/home
                path: %kernel.root_dir%/../web/shared/sitemaps/home/sitemap_index.xml
            path: %kernel.root_dir%/../web/shared/sitemaps/home/sitemap.xml
            routes:
                ...
        Store:
            index:
                base_url: http://www.example.com/sitemaps/store
                path: %kernel.root_dir%/../web/shared/sitemaps/store/sitemap_index.xml
            path: %kernel.root_dir%/../web/shared/sitemaps/store/sitemap.xml
            routes:
                ...

##Configuration with custom service:

###Example Routing

# app/config/test_routing.yml
page_show: 
    path: /{category_slug}/{page_slug}

Configuration

# app/config/config.yml
skuola_sitemap:
    scheme: http
    host: www.example.com
    db_driver: orm
    sitemaps:
        FirstSitemap:
            routes:
                page_show:
                    provider: skuola_testbundle.sitemap.page_provider
                    changefreq: weekly
                    priority: 0.5

Create your generator service, implements Skuola\SitemapBundle\Service\ParametersCollectionInterface

# src/TestBundle/Resources/config/services.yml
services:
  skuola_testbundle.sitemap.page_provider:
      class: Skuola\TestBundle\Service\Sitemap\PageProvider
      arguments: [@doctrine.orm.entity_manager]

Create PageProvider class

use Skuola\SitemapBundle\Service\ParametersCollectionInterface;
class PageProvider implements ParametersCollectionInterface {
    protected $entityManager;
    public function __construct($entityManager)
    {
        $this->entityManager = $entityManager;
    }
    //Implement getParametersCollection()
    public function getParametersCollection() {
        $collection = [];
        $pages = $this->entityManager->getRepository('Page')->findAll();
        foreach($pages as $page) {
            $collection[] = [
               'category_slug' => $page->getCategory()->getSlug(),
               'page_slug'     => $page->getSlug()
            ]
        }
        return $collection;
    }
}

Run

app/console sitemap:generator

Run single Sitemap

app/console sitemap:generator --name "FirstSitemap"

SitemapGeneratorCommand

skuola/sitemap-bundle 适用场景与选型建议

skuola/sitemap-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.99k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2015 年 10 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「symfony」 「generator」 「bundle」 「Sitemap」 「sitemap generator」 「sitemap bundle」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 skuola/sitemap-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 skuola/sitemap-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 skuola/sitemap-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.99k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 11
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 9
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-10-13