PHPackages                             whitedigital-eu/site-tree - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. whitedigital-eu/site-tree

ActiveSymfony-bundle

whitedigital-eu/site-tree
=========================

Site Tree

0.3.2(1y ago)0503↓100%2MITPHPPHP &gt;=8.2.0

Since Mar 15Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/whitedigital-eu/site-tree)[ Packagist](https://packagist.org/packages/whitedigital-eu/site-tree)[ RSS](/packages/whitedigital-eu-site-tree/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (26)Versions (26)Used By (0)

SiteTree
========

[](#sitetree)

### What is it?

[](#what-is-it)

This package adds site tree functionallity to api platform with addition of backend check of route validity when used together with separate frontend like vue.

### System Requirements

[](#system-requirements)

PHP 8.2+
Symfony 6.2+

### Installation

[](#installation)

The recommended way to install is via Composer:

```
composer require whitedigital-eu/site-tree
```

---

### Configuration

[](#configuration)

Only mandatory configuration parameter is `index_template` -&gt; file to include as response when backend has finished routing check.

```
site_tree:
    index_template: index.html
```

```
use Symfony\Config\SiteTreeConfig;

return static function (SiteTreeConfig $config): void {
    $config
        ->indexTemplate('index.html');
};
```

> **IMPORTANT**: File given to this parameter must be in path configured for twig bundle

After this, you need to update your database schema to use Audit entity.
If using migrations:

```
bin/console doctrine:migrations:diff
bin/console doctrine:migrations:migrate
```

If by schema update:

```
bin/console doctrine:schema:update --force
```

---

By default this package comes with 2 predefined types to be used as site tree nodes: `Html` and `Redirect`.
`Html` is a straight forward type without any extra logic, just plain html content.
`Redirect` is a type that manages redirects between nodes or to external sources.

To add new type, you need:

1. Create new Entity and Resource for this type
2. Configure type in configuration:

```
site_tree:
    index_template: index.html
    types:
        news: ~
        news2:
            entity: App\Entity\NotNews
```

```
use Symfony\Config\SiteTreeConfig;
use App\Entity\NotNews;

return static function (SiteTreeConfig $config): void {
    $config
        ->indexTemplate('index.html');

    $config->types('news');
    // or exact entity class if it is not default App\Entity\News
    $config->types('news2')->entity(NotNews::class);
};
```

---

### Usage

[](#usage)

To add new site tree node, call site tree api. default: POST `/api/site_trees`:

```
{
    "title": "test",
    "slug": "test",
    "type": "html"
}
```

This is the minimal data to create a new node. As no parent is given, this call will create a new root node. Normally site would need only one node, but if there are multiple menus or other links that require new nodes, like, `login`, for example, it is possible to do with this package.
If you want to add node to other node, simply add `parent`parameter:

```
{
    "title": "test",
    "slug": "test",
    "type": "html",
    "parent": "/api/site_trees/1"
}
```

To query all nodes, call GET `/api/site_trees` or to query just roots with children, call GET `/api/site_trees?level=0`

**Additionally** this package provides a check if url is defined in any node. To check if url is valid, call GET `/api/content_types/`.
For example, from example above, GET `/api/content_types/test` would return: `200 OK` +

```
{
    "nodeId": 1,
    "node": "/api/site_trees/1",
    "type": "resource"
}
```

but GET `/api/content_types/test2` would return: `404 Not Found` +

```
{
    "type": "https://tools.ietf.org/html/rfc2616#section-10",
    "title": "An error occurred",
    "detail": "Not Found"
}
```

### Extra configuration parameters

[](#extra-configuration-parameters)

As this library does use route listener to override router when any url is called to include index template file, you might need to filter out some paths where this should not be done.
To configure these paths, you can do:

```
site_tree:
    index_template: index.html
    excluded_path_prefixes:
        - '/admin'
    excluded_path_prefixes_dev:
        - '/test'
```

```
use Symfony\Config\SiteTreeConfig;

return static function (SiteTreeConfig $config): void {
    $config
        ->indexTemplate('index.html')
        ->excludedPathPrefixes([
            '/admin',
        ])
        ->excludedPathPrefixesDev([
            '/test',
        ]);
};
```

This configuration skips listener logic for any path that starts with these definded paths.
By default this bundle alrady skip some paths:
In any environment:

- `/api`
- `/sitemap.xml`

In dev/test environment:

- `/_profiler`
- `/_wdt`
- `/_error`

### For more advanced security, all custom content types should extend `AbstractContentTypeProvider`

[](#for-more-advanced-security-all-custom-content-types-should-extend-abstractcontenttypeprovider)

If you have any custom content types that are accessed publicly, you should use `AbstractContentTypeProvider` as a base provider so poblicly you can access only type data from active site tree nodes.

```
use WhiteDigital\SiteTree\DataProvider\AbstractContentTypeProvider;

class CustomContentTypeDataProvider extends AbstractContentTypeProvider {
    // ...
}
```

If this extension is not possible, you can use `LimitContentTypePublicAccessTrait` to get limiter function for use with `Doctrine\Orm\QueryBuilder` for collection and single items.

### Overriding parts of the bundle

[](#overriding-parts-of-the-bundle)

**Overriding default api resources (and therefore api endpoints)**

By default, SiteTree bundle resources is based on `src/Api/Resource` directory contents.
If you wish not to use these resources and not expose the api endpoints they provide, just set a custom api resource path with a configuration value. If you set it as `null`, api platform will not register api resources located within this package.

```
site_tree:
    custom_api_resource_path: '%kernel.project_dir%/src/MyCustomPath'
#    custom_api_resource_path: null
```

```
use Symfony\Config\SiteTreeConfig;

return static function (SiteTreeConfig $config): void {
    $config
        ->customApiResourcePath('%kernel.project_dir%/src/MyCustomPath')
        // or  ->customApiResourcePath(null);
};
```

After overriding default api resources, do not forget to update ClassMapperConfigurator configuration that is used for resource &lt;-&gt; entity mapping in `whitedigital-eu/entity-resource-mapper-bundle`

```
use App\ApiResource\Admin\SiteTreeResource;
use WhiteDigital\SiteTree\Entity\SiteTree;
use WhiteDigital\EntityResourceMapper\Mapper\ClassMapper;
use WhiteDigital\EntityResourceMapper\Mapper\ClassMapperConfiguratorInterface;

final class ClassMapperConfigurator implements ClassMapperConfiguratorInterface
{
    public function __invoke(ClassMapper $classMapper): void
    {
        $classMapper->registerMapping(SiteTreeResource::class, SiteTree::class);
    }
}
```

---

### Sitemap

[](#sitemap)

To add sitemap to `GET /sitemap.xml`, you need to add route configuration to project routes.

```
# config/routes/site-tree.yaml
site_tree:
    resource: '../vendor/whitedigital-eu/site-tree/src/Controller/'
    type:     attribute
```

```
// config/routes/site-tree.php
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return static function (RoutingConfigurator $routes): void {
    $routes->import('../vendor/whitedigital-eu/site-tree/src/Controller/', 'attribute');
};
```

Sitemap only returns enabled routes with `isActive: true` and `isVisible: true`. If you want to include invisible (but still active routes) with `isActive: true` and `isVisible: false`, configure it in configuration:

```
site_tree:
    #...
    sitemap:
        include_invisible: true
```

```
use Symfony\Config\SiteTreeConfig;

return static function (SiteTreeConfig $config): void {
    $config
        ->sitemap()
            ->includeInvisible(true);
};
```

###  Health Score

36

↑

LowBetter than 83% of packages

Maintenance51

Moderate activity, may be stable

Popularity15

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 83.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~32 days

Recently: every ~41 days

Total

16

Last Release

612d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c4db85e32518c5a6caa2fd625032a2b016ef42d60cf8a101c165cc5c0048b221?d=identicon)[k0d3r1s](/maintainers/k0d3r1s)

![](https://www.gravatar.com/avatar/d54d4c03974bdc6923785b90b54575e77570057e72fd6b9915e06656e60b842e?d=identicon)[andis.cirulis](/maintainers/andis.cirulis)

---

Top Contributors

[![k0d3r1s](https://avatars.githubusercontent.com/u/38725938?v=4)](https://github.com/k0d3r1s "k0d3r1s (90 commits)")[![acirulis](https://avatars.githubusercontent.com/u/27766961?v=4)](https://github.com/acirulis "acirulis (12 commits)")[![raraworks](https://avatars.githubusercontent.com/u/18421085?v=4)](https://github.com/raraworks "raraworks (4 commits)")[![iliepins-wd](https://avatars.githubusercontent.com/u/183823746?v=4)](https://github.com/iliepins-wd "iliepins-wd (2 commits)")

---

Tags

phpsymfonySymfony Bundlesite treeapi-platform

###  Code Quality

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/whitedigital-eu-site-tree/health.svg)

```
[![Health](https://phpackages.com/badges/whitedigital-eu-site-tree/health.svg)](https://phpackages.com/packages/whitedigital-eu-site-tree)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.5M596](/packages/sylius-sylius)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M125](/packages/sulu-sulu)[sonata-project/admin-bundle

The missing Symfony Admin Generator

2.1k18.7M273](/packages/sonata-project-admin-bundle)[pimcore/pimcore

Content &amp; Product Management Framework (CMS/PIM/E-Commerce)

3.7k3.6M345](/packages/pimcore-pimcore)[oro/platform

Business Application Platform (BAP)

648132.0k71](/packages/oro-platform)[kunstmaan/bundles-cms

The Kunstmaan CMS is an advanced yet user-friendly content management system, based on the full stack Symfony framework combined with a whole host of community bundles. It provides a full featured, multi-language CMS system with an innovative page and form assembling process, versioning, workflow, translation and media managers and much more.

413283.8k18](/packages/kunstmaan-bundles-cms)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
