Skip to content

Commit a098964

Browse files
dbuJohn Quairia
and
John Quairia
authored
remove annotation for 3.x release (#611)
* support symfony 7 * remove obsolete annotation support * document attributes * drop support for old php versions * adjust dependencies * fix codestyle * remove more annotation things --------- Co-authored-by: John Quairia <[email protected]>
1 parent 0deeee9 commit a098964

File tree

74 files changed

+637
-1500
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+637
-1500
lines changed

.github/workflows/php.yml

+14-15
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ env:
55

66
on:
77
push:
8-
branches:
9-
- "*.x"
8+
branches:
9+
- "*.x"
1010
pull_request:
1111

1212
jobs:
@@ -17,25 +17,24 @@ jobs:
1717
matrix:
1818
include:
1919
# Test the latest stable release
20-
- php-version: '7.3'
21-
- php-version: '7.4'
22-
- php-version: '8.0'
2320
- php-version: '8.1'
2421
dependencies: 'jean-beru/fos-http-cache-cloudfront'
25-
- php-version: '7.4'
26-
symfony-version: '4.*'
27-
- php-version: '7.4'
28-
symfony-version: '5.*'
29-
- php-version: '8.0'
30-
symfony-version: '6.*'
22+
- php-version: '8.1'
23+
symfony-version: '6.4'
24+
- php-version: '8.2'
25+
symfony-version: '7.*'
26+
- php-version: '8.3'
27+
symfony-version: '7.*'
28+
- php-version: '8.2'
29+
symfony-version: '6.4'
3130
# Minimum supported dependencies with the oldest PHP version
32-
- php-version: '7.3'
31+
- php-version: '8.1'
3332
composer-flag: '--prefer-stable --prefer-lowest'
34-
symfony-version: '4.4'
33+
symfony-version: '6.4'
3534
# Test latest unreleased versions
36-
- php-version: '8.0'
37-
symfony-version: '6.*'
35+
- php-version: '8.3'
3836
stability: 'dev'
37+
3938
name: PHP ${{ matrix.php-version }} Test on Symfony ${{ matrix.symfony-version }} ${{ matrix.dependencies}} ${{ matrix.stability }} ${{ matrix.composer-flag }}
4039
steps:
4140

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ Changelog
44
3.x
55
===
66

7+
* Minimum PHP version is no 8.1
8+
* Support Symfony 6.4 and 7
9+
* Drop obsolete annotations support, use attributes
10+
Remove all configuration you have at `fos_http_cache.tags.annotations`
711
* Make `fastly` and `cloudflare` clients lazy loaded to support Symfony secrets that are only available at runtime, but
812
not yet when the container is built.
913

Resources/doc/features/headers.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Caching Headers
55

66
You can configure HTTP caching headers based on request and response properties.
77
This configuration approach is more convenient than `manually setting cache headers`_
8-
and an alternative to `setting caching headers through annotations`_.
8+
and an alternative to `setting caching headers through attributes`_.
99

1010
Set caching headers under the ``cache_control`` configuration section,
1111
which consists of a set of rules. When the request matches all criteria under
@@ -70,4 +70,4 @@ This is an example configuration. For more, see the
7070
etag: "strong"
7171
7272
.. _manually setting cache headers: https://symfony.com/doc/current/http_cache.html#the-cache-control-header
73-
.. _setting caching headers through annotations: https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/cache.html
73+
.. _setting caching headers through attributes: https://symfony.com/doc/current/http_cache.html#making-your-responses-http-cacheable

Resources/doc/features/invalidation.rst

+9-10
Original file line numberDiff line numberDiff line change
@@ -94,25 +94,24 @@ returns a successful response, both routes ``villains_index`` and
9494
``villain_details`` will be purged. See the
9595
:doc:`/reference/configuration/invalidation` configuration reference.
9696

97-
Annotations
98-
-----------
97+
Attributes
98+
----------
9999

100-
Set the ``@InvalidatePath`` and ``@InvalidateRoute`` annotations to trigger
100+
Set the ``InvalidatePath`` and ``InvalidateRoute`` attributes to trigger
101101
invalidation from your controllers::
102102

103103
use FOS\HttpCacheBundle\Configuration\InvalidatePath;
104+
use Symfony\Component\ExpressionLanguage\Expression;
104105

105-
/**
106-
* @InvalidatePath("/articles")
107-
* @InvalidatePath("/articles/latest")
108-
* @InvalidateRoute("overview", params={"type" = "latest"})")
109-
* @InvalidateRoute("detail", params={"id" = {"expression"="id"}})")
110-
*/
106+
#[InvalidatePath('/articles')]
107+
#[InvalidatePath('/articles/latest')]
108+
#[InvalidateRoute('overview', params: ['type' => 'latest'])]
109+
#[InvalidateRoute("detail", params: ['id' => new Expression('my-expression="id"')])]
111110
public function editAction($id)
112111
{
113112
}
114113

115-
See the :doc:`/reference/annotations` reference.
114+
See the :doc:`/reference/attributes` reference.
116115

117116
Console Commands
118117
----------------

Resources/doc/features/tagging.rst

+8-9
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ You can tag responses in different ways:
4949
* From PHP code by using the response tagger to set tags and the cache manager
5050
to invalidate tags;
5151
* Set tags from twig templates with a function;
52-
* In project configuration or using annotations on controller actions.
52+
* In project configuration or using attributes on controller actions.
5353

5454
You can add tags before the response object exists. The tags are automatically
5555
added to the response by a listener. The listener also detects pending tag
@@ -149,19 +149,18 @@ Now if a :term:`safe` request matches the criteria under ``match``, the response
149149
will be tagged with ``news``. When an unsafe request matches, the tag ``news``
150150
will be invalidated.
151151

152-
Tagging and Invalidating with Controller Annotations
153-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
152+
Tagging and Invalidating with Controller Attributes
153+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
154154

155-
Add the ``@Tag`` annotations to your controllers to set and invalidate tags::
155+
Add the ``Tag`` attribute to your controllers to set and invalidate tags::
156156

157157
use FOS\HttpCacheBundle\Configuration\Tag;
158+
use Symfony\Component\ExpressionLanguage\Expression;
158159

159160
class NewsController
160161
{
161-
/**
162-
* @Tag("news", expression="'news-'~id")
163-
*/
164-
public function articleAction($id)
162+
#[Tag('news', expression: new Expression('"news-"~id'))]
163+
public function articleAction(string $id)
165164
{
166165
// Assume $id equals 123
167166
}
@@ -172,7 +171,7 @@ on the response. If a client tries to update or delete news article 123 with an
172171
unsafe request to ``articleAction``, such as POST or DELETE, tag ``news-123``
173172
is invalidated.
174173

175-
See the :ref:`@Tag reference <tag>` for full details.
174+
See the :ref:`Tag reference <tag>` for full details.
176175

177176
.. _Tagged Cache Invalidation: http://blog.kevburnsjr.com/tagged-cache-invalidation
178177
.. _Linked Cache Invalidation: http://tools.ietf.org/html/draft-nottingham-linked-cache-inv-03

Resources/doc/overview.rst

+9-36
Original file line numberDiff line numberDiff line change
@@ -39,41 +39,14 @@ For most features, you also need to :ref:`configure a caching proxy <foshttpcach
3939

4040
.. _requirements:
4141

42-
Requirements
43-
------------
44-
45-
SensioFrameworkExtraBundle
46-
~~~~~~~~~~~~~~~~~~~~~~~~~~
47-
48-
If you want to use this bundle’s annotations, install the
49-
SensioFrameworkExtraBundle_:
50-
51-
.. code-block:: bash
52-
53-
$ composer require sensio/framework-extra-bundle
54-
55-
And , if you don't use a recent version of Symfony, include it in your project::
56-
57-
<?php
58-
// app/AppKernel.php
59-
60-
public function registerBundles()
61-
{
62-
$bundles = array(
63-
// ...
64-
new FOS\HttpCacheBundle\FOSHttpCacheBundle(),
65-
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
66-
// ...
67-
);
68-
69-
.. _expression language requirement:
42+
Optional Dependencies
43+
---------------------
7044

7145
ExpressionLanguage
7246
~~~~~~~~~~~~~~~~~~
7347

74-
If you wish to use expressions_ in your annotations , you also need Symfony’s
75-
ExpressionLanguage_ component. If you’re not using full-stack Symfony 2.4 or
76-
later, you need to explicitly add the component:
48+
If you wish to use expressions_ in your :ref:`attributes <reference/attributes.rst>`,
49+
you need Symfony’s ExpressionLanguage_ component. Make sure it is part of your application with:
7750

7851
.. code-block:: bash
7952
@@ -92,10 +65,10 @@ Functionality
9265
This table shows where you can find specific functions.
9366

9467
========================= ==================================== ==================================================== ==============================================
95-
Functionality Annotations Configuration Manually
68+
Functionality Attributes Configuration Manually
9669
========================= ==================================== ==================================================== ==============================================
97-
Set Cache-Control headers (SensioFrameworkExtraBundle_) :doc:`rules <reference/configuration/headers>` (Symfony_)
98-
Tag and invalidate :doc:`@Tag </features/tagging>` :doc:`rules <reference/configuration/headers>` :doc:`cache manager <reference/cache-manager>`
70+
Set Cache-Control headers (`Symfony cache attributes`_) :doc:`rules <reference/configuration/headers>` (`Symfony cache control`_)
71+
Tag and invalidate :doc:`#[Tag] </features/tagging>` :doc:`rules <reference/configuration/tags>` :doc:`cache manager <reference/cache-manager>`
9972
Invalidate routes :ref:`invalidateroute` :ref:`invalidators <invalidation configuration>` :doc:`cache manager <reference/cache-manager>`
10073
Invalidate paths :ref:`invalidatepath` :ref:`invalidators <invalidation configuration>` :doc:`cache manager <reference/cache-manager>`
10174
========================= ==================================== ==================================================== ==============================================
@@ -109,7 +82,7 @@ This bundle is released under the MIT license.
10982
:language: none
11083

11184
.. _Packagist: https://packagist.org/packages/friendsofsymfony/http-cache-bundle
112-
.. _SensioFrameworkExtraBundle: https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/index.html
11385
.. _ExpressionLanguage: https://symfony.com/doc/current/components/expression_language.html
114-
.. _Symfony: https://symfony.com/doc/current/http_cache.html#the-cache-control-header
86+
.. _Symfony cache attributes: https://symfony.com/doc/current/http_cache.html#making-your-responses-http-cacheable
87+
.. _Symfony cache control: https://symfony.com/doc/current/http_cache.html#the-cache-control-header
11588
.. _client implementations: https://packagist.org/providers/php-http/client-implementation

Resources/doc/reference.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ Reference
22
=========
33

44
This part is a full description of all available configuration options,
5-
annotations and public methods.
5+
attributes and public methods.
66

77
.. toctree::
88
:maxdepth: 2
99

1010
reference/configuration
11-
reference/annotations
11+
reference/attributes
1212
reference/cache-manager
1313
reference/glossary

0 commit comments

Comments
 (0)