Download the PHP package ecourty/sitemap-bundle without Composer

On this page you can find all versions of the php package ecourty/sitemap-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package sitemap-bundle

ecourty/sitemap-bundle

CI

A Symfony bundle for generating XML sitemaps. Supports static routes, dynamic Doctrine entities, and extensive configuration options.

The bundle handles both dynamic generation via controller and static file generation via command.
Memory-efficient streaming prevents issues with large datasets.

Table of Contents

Requirements

Installation

The bundle will be automatically registered in config/bundles.php if using Symfony Flex (otherwise, add it manually):

Quick Start

1. Basic Configuration

Create config/packages/sitemap.yaml:

Example: Static routes only

Example: With dynamic entities

2. Import Routes (Optional)

Only required if you want dynamic generation via /sitemap.xml.

If you only use static generation (sitemap:dump command), you can skip this step.

⚠️ Important: Dynamic generation only works for simple sitemaps (single file). If you're using sitemap indexes (use_index: true or above the configured URLs threshold, default to 50k URLs), you must use static generation.

Add the bundle routes to config/routes.yaml:

3. Access Your Sitemap

Dynamic generation - visit in your browser:

Static generation - generate a file:

That's it! 🎉

Configuration

Use Cases

Case 1: Simple Website (Static Pages Only)

Perfect for marketing sites, landing pages, or small websites with fixed pages:

Case 2: Blog or News Site

Static pages + dynamic articles from database:

Case 3: E-commerce Site

Multiple entity types with different priorities:

Case 4: Filtering with DQL Conditions

When you need simple filtering without creating custom repository methods, use conditions:

Note: Use the alias e in your DQL conditions. You cannot combine conditions with query_builder_method.

Case 5: Large Dataset (Automatic Index)

For sites with 50,000+ URLs, the bundle automatically creates a sitemap index:

Full Configuration Example

Configuration Reference

Option Type Default Description
base_url string required Base URL for absolute URLs
use_index string|bool 'auto' Index strategy: 'auto', true, false
index_threshold int 50000 URL count threshold for auto index
static_routes[].route string required Symfony route name
static_routes[].priority float 0.5 Priority (0.0-1.0)
static_routes[].changefreq string 'weekly' Change frequency
static_routes[].lastmod string|null null Relative time (e.g., '-2 days')
entity_routes[].entity string required Entity class name (FQCN)
entity_routes[].route string required Symfony route name
entity_routes[].route_params array required Property → parameter mapping
entity_routes[].priority float 0.5 Priority (0.0-1.0)
entity_routes[].changefreq string 'weekly' Change frequency
entity_routes[].lastmod_property string|null null DateTime property name
entity_routes[].query_builder_method string|null null Repository method OR FQCN::method
entity_routes[].conditions string|null null DQL WHERE clause

Valid changefreq values: always, hourly, daily, weekly, monthly, yearly, never

Important:

Usage

Dynamic Generation (Controller)

Requires routes import - see step 2 in Quick Start.

Once routes are imported, access the dynamic sitemap at:

The sitemap is generated on-the-fly from your configuration and database.

⚠️ Important limitation: Dynamic generation only works for simple sitemaps (single sitemap.xml file). If your configuration generates a sitemap index with multiple files (due to use_index: true or exceeding the threshold), the controller will only serve the main sitemap.xml index file. The individual sitemap files (sitemap_static.xml, sitemap_entity_*.xml) will not be accessible via controller routes.

Recommended for:

For sitemap indexes, use static generation instead (see below).

Static Generation (Command)

No routes import needed - works out of the box after configuration.

Generate a static sitemap file:

Important: The --output option specifies a directory, not a file, because the generator may create multiple files:

✅ Recommended for:

Required for sitemap indexes: Dynamic generation via controller cannot serve individual sitemap files. Use static generation to write all files to disk.

Tip: Run via cron to regenerate periodically:

Generated XML Output

Simple Sitemap (Mixed Content)

When you have both static routes and dynamic entities with use_index: false:

Sitemap Index (Large Datasets)

When use_index: true or URL count exceeds threshold, the bundle generates an index file referencing separate sitemaps per source.

Benefits:

sitemap.xml (index file):

sitemap_static.xml (static routes only):

sitemap_entity_article.xml (articles only):

Note: When a source has more than 50,000 URLs, it's automatically split into numbered files (sitemap_entity_product_1.xml, sitemap_entity_product_2.xml, etc.)

Advanced Configuration

Custom Repository Method

For better performance with filtering and optimization, create a custom repository method that returns a QueryBuilder:

Important: Return a QueryBuilder, not the query result. The bundle will:

Then reference it in config:

Custom Service with FQCN::method

For more flexibility, use any service (not just the entity's repository):

Configuration:

DQL Conditions

Use DQL conditions for simple filtering without custom methods:

Multiple Route Parameters

Map multiple entity properties to route parameters:

Sitemap Index Modes

Control how sitemaps are split:

Example with index:

Extensibility

Custom URL Providers

For complex URL generation needs beyond static routes and Doctrine entities, implement a custom UrlProviderInterface.

This is the most powerful extension point in the bundle, giving you complete control over URL generation.

Use Cases for Custom Providers

Implementation Example: Products with Category Parameters

This example shows how to generate URLs like /category/electronics/product/smartphone-x where both category and product slugs are needed:

Configuration:

That's it! The provider will be automatically discovered and used. No additional configuration needed.

Architecture

Design Patterns

Extension Points

The bundle is designed for extensibility:

Performance

Memory Optimization

The bundle automatically uses Doctrine's toIterable() to stream entities, preventing memory issues with large datasets.

What the bundle does internally:

Your responsibility: Return a QueryBuilder from repository methods (not query results):

Recommendations

  1. Use repository methods - The bundle optimizes the SELECT to fetch only needed fields
  2. Add database indexes on columns used in WHERE clauses and route parameters
  3. Enable sitemap index for datasets >50k URLs (automatic with use_index: 'auto')
  4. ⚠️ Use static generation for sitemap indexes - Dynamic controller cannot serve individual sitemap files
  5. Run static generation as a cron job during low-traffic periods
  6. Use a CDN to cache sitemap files

Example: Optimized for Large Datasets

Result: Can handle millions of products with minimal memory usage.

Development

Development Workflow

Contributions are welcome! The project follows strict coding standards to maintain high code quality.

Setup:

Development cycle:

Before submitting:

Code Standards

All contributions must follow the project's coding standards:

See AGENTS.md for detailed developer and AI agent guide.

License

MIT License - see LICENSE file for details.

Support


All versions of sitemap-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
ext-xmlwriter Version *
symfony/config Version ^6.4|^7.0|^8.0
symfony/dependency-injection Version ^6.4|^7.0|^8.0
symfony/http-kernel Version ^6.4|^7.0|^8.0
symfony/console Version ^6.4|^7.0|^8.0
symfony/routing Version ^6.4|^7.0|^8.0
symfony/property-access Version ^6.4|^7.0|^8.0
doctrine/orm Version ^3.0|^4.0
doctrine/doctrine-bundle Version ^2.18|^3.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ecourty/sitemap-bundle contains the following files

Loading the files please wait ...