Giter VIP home page Giter VIP logo

silex-sitemap-service-provider's Introduction

silex-sitemap-service-provider

Build Status Latest Stable Version License Issues Total Downloads

The provider supports both major Versions of Silex.

Installation

For applications based on Silex >= 2.0.0:

composer require tm/silex-sitemap-service-provider ^4.0

If you use Silex 1.3.x or lower in your application:

composer require tm/silex-sitemap-service-provider ^3.0

Example Basic Usage

First you have to register the ServiceProvider:

    $app->register(new TM\Provider\SitemapServiceProvider());

Optional you can also set some options for the generator:

    $app->register(new TM\Provider\SitemapServiceProvider(), [
        'sitemap.options' => [
            'charset' => 'ISO-8859-1',
            'version' => '1.0',
            'scheme' => 'http://www.sitemaps.org/schemas/sitemap/0.8'
        ]
    ]);

Then implement the route for the sitemap.xml with your custom logic:

    $app->get('sitemap.xml', function () use ($app) {
  
      $host = $app['request']->getSchemeAndHttpHost();
      
      $sitemap = $app['sitemap'];
      $sitemap->addEntry($host . '/', 1, 'yearly');
      
      $entities = $app['repository.entity']->findAll(50000);
  
      foreach ($entities as $entity) {
        $entityLoc = $app['url_generator']->generate('entity', array('entity' => $entity->getId()));
        $sitemap->addEntry($host . $entityLoc, 0.8, 'monthly', $entity->getLastModified());
      }
  
      return $sitemap->generate();
    })
    ->bind('sitemap');

Contributing

Please refer to CONTRIBUTING.md for information on how to contribute.

Development

Run tests with the following command in the project directory.

composer install
./vendor/bin/behat 

silex-sitemap-service-provider's People

Contributors

sebastian-marinescu avatar tommy-muehle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

silex-sitemap-service-provider's Issues

SitemapGenerator properties inheritance

Given an internationalized website, one has to declare specific nodes into sitemaps as follow:

<xhtml:link 
    rel="alternate"
    hreflang="de"
    href="http://www.example.com/deutsch/"
    />

Could you consider making the provider "extendable" to enable the overriding of the SitemapGenerator class?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.