Skip to content

Commit

Permalink
Add pages
Browse files Browse the repository at this point in the history
  • Loading branch information
HypeMC committed Oct 27, 2024
1 parent 6554fbd commit 9822e83
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 35 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ If your project doesn't use [Symfony Flex](https://github.com/symfony/flex), con

## Usage

For detailed instructions and examples, refer to the [documentation](/docs/).
For detailed instructions and examples, refer to the [documentation](https://sofascore.github.io/purgatory-bundle/).

## Versioning

Expand Down
8 changes: 8 additions & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
remote_theme: pages-themes/cayman@v0.2.0
plugins:
- jekyll-remote-theme

title: "Sofascore Purgatory Bundle"
description: "A Symfony bundle for creating and sending cache purge requests to HTTP cache backends like Varnish."

show_downloads: false
9 changes: 6 additions & 3 deletions docs/complex-route-params.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Complex Route Parameters
---
title: Complex Route Parameters
---

This section covers advanced configurations for mapping route parameters in scenarios where properties alone are not
sufficient. You'll learn how to work with nested properties, collections, non-property values, and dynamically provided
Expand Down Expand Up @@ -143,8 +145,7 @@ App\MyService:
- { name: 'purgatory.route_parameter_service', alias: my_service }
```
Alternatively, you can use the [`#[AsRouteParamService]`](/src/Attribute/AsRouteParamService.php) attribute directly in
the service class:
Alternatively, you can use the [`#[AsRouteParamService]`][0] attribute directly in the service class:

```php
use Sofascore\PurgatoryBundle\Attribute\AsRouteParamService;
Expand All @@ -158,3 +159,5 @@ class MyService
}
}
```

[0]: https://github.com/sofascore/purgatory-bundle/blob/1.x/src/Attribute/AsRouteParamService.php
9 changes: 6 additions & 3 deletions docs/custom-expression-language-functions.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Custom Expression Language Functions
---
title: Custom Expression Language Functions
---

You can add custom functions to the Expression Language for use with the `if` parameter.

Expand All @@ -19,8 +21,7 @@ App\ShouldPurge:
- { name: 'purgatory.expression_language_function', function: should_purge }
```
Alternatively, you can use the [`#[AsExpressionLanguageFunction]`](/src/Attribute/AsExpressionLanguageFunction.php)
attribute directly in the service class:
Alternatively, you can use the [`#[AsExpressionLanguageFunction]`][0] attribute directly in the service class:

```php
use Sofascore\PurgatoryBundle\Attribute\AsExpressionLanguageFunction;
Expand All @@ -34,3 +35,5 @@ class ShouldPurge
}
}
```

[0]: https://github.com/sofascore/purgatory-bundle/blob/1.x/src/Attribute/AsExpressionLanguageFunction.php
12 changes: 8 additions & 4 deletions docs/custom-purgers.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Custom Purgers
---
title: Custom Purgers
---

You can create custom purgers by implementing the [`PurgerInterface`](/src/Purger/PurgerInterface.php). This allows you
to define your own logic for handling purge requests. Once implemented, be sure to tag your custom purger with
`purgatory.purger` to make it available for configuration.
You can create custom purgers by implementing the [`PurgerInterface`][0]. This allows you to define your own logic for
handling purge requests. Once implemented, be sure to tag your custom purger with `purgatory.purger` to make it
available for configuration.

Here's an example of a custom purger for Cloudflare:

Expand Down Expand Up @@ -31,3 +33,5 @@ purgatory:
```
In this example, the alias `cloudflare` is used to refer to the custom purger.

[0]: https://github.com/sofascore/purgatory-bundle/blob/1.x/src/Purger/PurgerInterface.php
16 changes: 10 additions & 6 deletions docs/custom-route-providers.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Custom Route Providers
---
title: Custom Route Providers
---

To create a custom route provider, implement
the [`RouteProviderInterface`](/src/RouteProvider/RouteProviderInterface.php). This interface defines two methods:
To create a custom route provider, implement the [`RouteProviderInterface`][0]. This interface defines two methods:

- **`supports` method**: Determines whether the route provider supports a given entity and action. This method helps
filter which entities the provider should be responsible for.

- **`provideRoutesFor` method**: Generates and yields routes for the given entity. This method uses instances of
[`PurgeRoute`](/src/RouteProvider/PurgeRoute.php) to define route names and their parameters. You can implement custom
logic to determine the appropriate routes based on the action, the entity, and any changes detected in the entity's
properties.
[`PurgeRoute`][1] to define route names and their parameters. You can implement custom logic to determine the
appropriate routes based on the action, the entity, and any changes detected in the entity's properties.

### Example

Expand Down Expand Up @@ -57,3 +57,7 @@ App\RouteProvider\MyPostRouteProvider:
By tagging it with `purgatory.route_provider`, the bundle will automatically recognize and use your custom route
provider when processing purge requests.

[0]: https://github.com/sofascore/purgatory-bundle/blob/1.x/src/RouteProvider/RouteProviderInterface.php

[1]: https://github.com/sofascore/purgatory-bundle/blob/1.x/src/RouteProvider/PurgeRoute.php
45 changes: 28 additions & 17 deletions docs/README.md → docs/index.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Getting Started
---
title: Getting Started
---

The bundle is designed to automatically generate and send cache purge requests to HTTP cache backends such as Symfony's
HTTP cache or Varnish. It leverages Doctrine events to track changes in entities and generates URLs that need to be
Expand All @@ -19,13 +21,13 @@ This bundle uses URL-based invalidation instead of tag-based invalidation due to

The bundle includes built-in support for [Symfony HTTP Cache](https://symfony.com/doc/current/http_cache.html) and a
basic [Varnish](https://varnish-cache.org/) implementation. Each backend is implemented through
the [`PurgerInterface`](/src/Purger/PurgerInterface.php).
the [`PurgerInterface`][0].

It also provides a `void` purger, which can be used during development when cache purging is not needed. The `void`
purger simply ignores all purge requests, making it ideal for non-production environments. Additionally, an `in-memory`
purger is included, specifically designed for testing purposes.

For advanced use cases, you can create [custom purgers](/docs/custom-purgers.md) to integrate with any custom or
For advanced use cases, you can create [custom purgers](custom-purgers.md) to integrate with any custom or
third-party HTTP cache backend that fits your project requirements.

### Configuring Symfony's HTTP Cache
Expand Down Expand Up @@ -139,14 +141,14 @@ new parameters.
Using this information, the bundle generates the URLs that need to be purged. It then sends these purge requests to the
configured purger, which clears the cached content for those URLs.

You can also create [custom route providers](/docs/custom-route-providers.md) to define additional routes for specific
You can also create [custom route providers](custom-route-providers.md) to define additional routes for specific
entities and properties, giving you greater control over purging behavior in more complex scenarios.

## Configuring Purge Subscriptions

Purge subscriptions can be configured using the [`#[PurgeOn]`](/src/Attribute/PurgeOn.php) attribute.
Purge subscriptions can be configured using the [`#[PurgeOn]`][1] attribute.

You can also configure purge subscriptions [using YAML](/docs/purge-subscriptions-using-yaml.md). This is particularly
You can also configure purge subscriptions [using YAML](purge-subscriptions-using-yaml.md). This is particularly
useful if you have routes without an associated controller or action.

### Basic Example
Expand Down Expand Up @@ -237,7 +239,7 @@ public function detailsAction(Post $post)
}
```

For more advanced examples of mapping route parameters, see the [dedicated section](/docs/complex-route-params.md).
For more advanced examples of mapping route parameters, see the [dedicated section](complex-route-params.md).

### Targeting Specific Properties

Expand Down Expand Up @@ -265,8 +267,7 @@ public function detailsAction(Post $post)
}
```

To associate specific properties with a method, use the [`#[TargetedProperties]`](/src/Attribute/TargetedProperties.php)
attribute on your entity method:
To associate specific properties with a method, use the [`#[TargetedProperties]`][2] attribute on your entity method:

```php
use Doctrine\ORM\Mapping as ORM;
Expand Down Expand Up @@ -376,7 +377,7 @@ public function detailsAction(Post $post)

In this example, the purge will only occur if the post has more than 3,000 upvotes.

You can also add [custom Expression Language functions](/docs/custom-expression-language-functions.md).
You can also add [custom Expression Language functions](custom-expression-language-functions.md).

### Limiting Purge to Specific Routes

Expand All @@ -396,7 +397,7 @@ In this example, only the `post_details` route will be purged.

### Limiting by Action Type

You can also limit the purging to a specific action as defined in the [`Action`](/src/Listener/Enum/Action.php) enum:
You can also limit the purging to a specific action as defined in the [`Action`][3] enum:

```php
use Sofascore\PurgatoryBundle\Listener\Enum\Action;
Expand All @@ -414,7 +415,7 @@ Now, the purge will only occur when the entity is updated, but not when it is cr

For testing purposes, you can use the `in-memory` purger, which simulates purging without interacting with external
cache services. This allows you to verify your purging logic in a controlled environment. To simplify your tests, you
can also utilize the [`InteractsWithPurgatory`](/src/Test/InteractsWithPurgatory.php) trait.
can also utilize the [`InteractsWithPurgatory`][4] trait.

To configure the `in-memory` purger specifically for your test environment, add the following configuration:

Expand Down Expand Up @@ -482,8 +483,18 @@ This command provides insights into which routes and parameters are associated w

## See Also

- [Custom Purgers](/docs/custom-purgers.md)
- [Custom Route Providers](/docs/custom-route-providers.md)
- [Complex Route Parameters](/docs/complex-route-params.md)
- [Configure Purge Subscriptions Using YAML](/docs/purge-subscriptions-using-yaml.md)
- [Custom Expression Language Functions](/docs/custom-expression-language-functions.md)
- [Custom Purgers](custom-purgers.md)
- [Custom Route Providers](custom-route-providers.md)
- [Complex Route Parameters](complex-route-params.md)
- [Configure Purge Subscriptions Using YAML](purge-subscriptions-using-yaml.md)
- [Custom Expression Language Functions](custom-expression-language-functions.md)

[0]: https://github.com/sofascore/purgatory-bundle/blob/1.x/src/Purger/PurgerInterface.php

[1]: https://github.com/sofascore/purgatory-bundle/blob/1.x/src/Attribute/PurgeOn.php

[2]: https://github.com/sofascore/purgatory-bundle/blob/1.x/src/Attribute/TargetedProperties.php

[3]: https://github.com/sofascore/purgatory-bundle/blob/1.x/src/Listener/Enum/Action.php

[4]: https://github.com/sofascore/purgatory-bundle/blob/1.x/src/Test/InteractsWithPurgatory.php
4 changes: 3 additions & 1 deletion docs/purge-subscriptions-using-yaml.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Configure Purge Subscriptions Using YAML
---
title: Configure Purge Subscriptions Using YAML
---

Purge subscriptions can also be configured using YAML. This is particularly useful if you have routes without an
associated controller or action.
Expand Down

0 comments on commit 9822e83

Please sign in to comment.