Skip to content

Commit fc1852d

Browse files
committed
feature #71 Symfony UX Turbo: content negotiation and Doctrine integration (dunglas)
This PR was merged into the main branch. Discussion ---------- Symfony UX Turbo: content negotiation and Doctrine integration | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | Tickets | Fix #64 | License | MIT Same as #64, just squashed. See there for details and history. Commits ------- 95d5f00 Symfony UX Turbo: content negotiation and Doctrine integration
2 parents 06521ce + 95d5f00 commit fc1852d

Some content is hidden

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

61 files changed

+2766
-10
lines changed

.github/workflows/test-turbo.yml

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
name: Symfony UX Turbo
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
phpstan:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v2
13+
14+
- name: Setup PHP
15+
uses: shivammathur/setup-php@v2
16+
with:
17+
php-version: '8.0'
18+
extensions: zip
19+
20+
- name: Get composer cache directory
21+
id: composercache
22+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
23+
24+
- name: Cache dependencies
25+
uses: actions/cache@v2
26+
with:
27+
path: ${{ steps.composercache.outputs.dir }}
28+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
29+
restore-keys: ${{ runner.os }}-composer-
30+
31+
- name: Install dependencies
32+
working-directory: src/Turbo
33+
run: composer install --prefer-dist
34+
35+
- name: Install PHPUnit dependencies
36+
working-directory: src/Turbo
37+
run: vendor/bin/simple-phpunit --version
38+
39+
- name: PHPStan
40+
working-directory: src/Turbo
41+
run: vendor/bin/phpstan analyse --no-progress
42+
43+
tests-php-high-deps:
44+
runs-on: ubuntu-latest
45+
strategy:
46+
matrix:
47+
php-versions: ['7.2', '7.3', '7.4', '8.0']
48+
fail-fast: false
49+
name: PHP ${{ matrix.php-versions }} Test on ubuntu-latest
50+
51+
services:
52+
mercure:
53+
image: dunglas/mercure
54+
env:
55+
SERVER_NAME: :3000
56+
MERCURE_PUBLISHER_JWT_KEY: '!ChangeMe!'
57+
MERCURE_SUBSCRIBER_JWT_KEY: '!ChangeMe!'
58+
MERCURE_EXTRA_DIRECTIVES: |
59+
anonymous
60+
cors_origins *
61+
ports:
62+
- 3000:3000
63+
64+
steps:
65+
- name: Checkout
66+
uses: actions/checkout@v2
67+
68+
- name: Setup PHP
69+
uses: shivammathur/setup-php@v2
70+
with:
71+
php-version: ${{ matrix.php-versions }}
72+
extensions: zip, pdo_sqlite
73+
74+
- name: Get composer cache directory
75+
id: composercache
76+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
77+
78+
- name: Cache PHP dependencies
79+
uses: actions/cache@v2
80+
with:
81+
path: ${{ steps.composercache.outputs.dir }}
82+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
83+
restore-keys: ${{ runner.os }}-composer-
84+
85+
- name: Install PHP dependencies
86+
working-directory: src/Turbo
87+
run: composer install --prefer-dist
88+
89+
- name: Get yarn cache directory path
90+
id: yarn-cache-dir-path
91+
run: echo "::set-output name=dir::$(yarn cache dir)"
92+
93+
- uses: actions/cache@v2
94+
id: yarn-cache
95+
with:
96+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
97+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/package.json') }}
98+
restore-keys: |
99+
${{ runner.os }}-yarn-
100+
101+
- name: Install JavaScript dependencies
102+
working-directory: src/Turbo/Tests/app
103+
run: yarn install
104+
105+
- name: Build JavaScript
106+
working-directory: src/Turbo/Tests/app
107+
run: yarn build
108+
109+
- name: Create DB
110+
working-directory: src/Turbo/Tests/app
111+
run: php public/index.php doctrine:schema:create
112+
113+
- name: Run tests
114+
working-directory: src/Turbo
115+
env:
116+
SYMFONY_DEPRECATIONS_HELPER: max[direct]=0
117+
run: vendor/bin/simple-phpunit
118+
119+
tests-php-low-deps:
120+
runs-on: ubuntu-latest
121+
name: PHP 8.0 (lowest) Test on ubuntu-latest
122+
123+
services:
124+
mercure:
125+
image: dunglas/mercure
126+
env:
127+
SERVER_NAME: :3000
128+
MERCURE_PUBLISHER_JWT_KEY: '!ChangeMe!'
129+
MERCURE_SUBSCRIBER_JWT_KEY: '!ChangeMe!'
130+
MERCURE_EXTRA_DIRECTIVES: |
131+
anonymous
132+
cors_origins *
133+
ports:
134+
- 3000:3000
135+
136+
steps:
137+
- name: Checkout
138+
uses: actions/checkout@v2
139+
140+
- name: Setup PHP
141+
uses: shivammathur/setup-php@v2
142+
with:
143+
php-version: '8.0'
144+
extensions: zip, pdo_sqlite
145+
146+
- name: Get composer cache directory
147+
id: composercache
148+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
149+
150+
- name: Cache PHP dependencies
151+
uses: actions/cache@v2
152+
with:
153+
path: ${{ steps.composercache.outputs.dir }}
154+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
155+
restore-keys: ${{ runner.os }}-composer-
156+
157+
- name: Install PHP dependencies
158+
working-directory: src/Turbo
159+
run: composer update --prefer-dist --prefer-lowest --prefer-stable
160+
161+
- name: Get yarn cache directory path
162+
id: yarn-cache-dir-path
163+
run: echo "::set-output name=dir::$(yarn cache dir)"
164+
165+
- uses: actions/cache@v2
166+
id: yarn-cache
167+
with:
168+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
169+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/package.json') }}
170+
restore-keys: |
171+
${{ runner.os }}-yarn-
172+
173+
- name: Install JavaScript dependencies
174+
working-directory: src/Turbo/Tests/app
175+
run: yarn install
176+
177+
- name: Build JavaScript
178+
working-directory: src/Turbo/Tests/app
179+
run: yarn build
180+
181+
- name: Create DB
182+
working-directory: src/Turbo/Tests/app
183+
run: php public/index.php doctrine:schema:create
184+
185+
- name: Run tests
186+
working-directory: src/Turbo
187+
env:
188+
SYMFONY_DEPRECATIONS_HELPER: max[total]=9223372036854775807 # PHP_INT_MAX
189+
run: vendor/bin/simple-phpunit

.github/workflows/test.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
php-version: '7.4'
1717
- name: php-cs-fixer
1818
run: |
19-
wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.16.1/php-cs-fixer.phar -q
19+
wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.18.2/php-cs-fixer.phar -q
2020
php php-cs-fixer.phar fix --dry-run --diff
2121
2222
coding-style-js:
@@ -34,7 +34,6 @@ jobs:
3434
- uses: shivammathur/setup-php@v2
3535
with:
3636
php-version: '7.2'
37-
extensions: gd
3837
- name: Chartjs
3938
run: |
4039
cd src/Chartjs
@@ -63,7 +62,6 @@ jobs:
6362
- uses: shivammathur/setup-php@v2
6463
with:
6564
php-version: '8.0'
66-
extensions: gd
6765
- name: Chartjs
6866
run: |
6967
cd src/Chartjs

.php_cs.dist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,7 @@ return PhpCsFixer\Config::create()
2323
->in(__DIR__.'/src')
2424
->append([__FILE__])
2525
->notPath('#/Fixtures/#')
26+
->notPath('#/app/var/#')
27+
->notPath('Turbo/Attribute/Broadcast.php') // Need https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues/4702
2628
)
2729
;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"workspaces": [
4-
"src/*/Resources/assets"
4+
"src/**/Resources/assets"
55
],
66
"scripts": {
77
"build": "yarn workspaces run build",

src/Chartjs/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
},
4040
"extra": {
4141
"branch-alias": {
42-
"dev-main": "1.1-dev"
42+
"dev-main": "1.3-dev"
4343
},
4444
"thanks": {
4545
"name": "symfony/ux",

src/Cropperjs/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
},
4343
"extra": {
4444
"branch-alias": {
45-
"dev-main": "1.1-dev"
45+
"dev-main": "1.3-dev"
4646
},
4747
"thanks": {
4848
"name": "symfony/ux",

src/Dropzone/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ the `@symfony/ux-dropzone/src/style.css` autoimport to `false`:
6161
"@symfony/ux-dropzone": {
6262
"dropzone": {
6363
"enabled": true,
64-
"fetch": "eager",
64+
"webpackMode": "eager",
6565
"autoimport": {
6666
"@symfony/ux-dropzone/src/style.css": false
6767
}

src/Dropzone/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
},
4141
"extra": {
4242
"branch-alias": {
43-
"dev-main": "1.1-dev"
43+
"dev-main": "1.3-dev"
4444
},
4545
"thanks": {
4646
"name": "symfony/ux",

src/LazyImage/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
},
4242
"extra": {
4343
"branch-alias": {
44-
"dev-main": "1.1-dev"
44+
"dev-main": "1.3-dev"
4545
},
4646
"thanks": {
4747
"name": "symfony/ux",

src/Swup/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
],
2020
"extra": {
2121
"branch-alias": {
22-
"dev-main": "1.1-dev"
22+
"dev-main": "1.3-dev"
2323
},
2424
"thanks": {
2525
"name": "symfony/ux",

src/Turbo/.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/.gitattributes export-ignore
2+
/.gitignore export-ignore
3+
/phpunit.xml.dist export-ignore
4+
/Resources/assets/test export-ignore
5+
/Tests export-ignore

src/Turbo/.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/.php_cs.cache
2+
/.php_cs
3+
/.phpunit.result.cache
4+
/composer.phar
5+
/composer.lock
6+
/phpunit.xml
7+
/vendor/
8+
/Tests/app/var
9+
/Tests/app/public/build/
10+
node_modules/
11+
package-lock.json
12+
yarn.lock

src/Turbo/Attribute/Broadcast.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\UX\Turbo\Attribute;
13+
14+
use Symfony\UX\Turbo\Bridge\Mercure\Broadcaster;
15+
16+
/**
17+
* Marks the entity as broadcastable.
18+
*
19+
* @author Kévin Dunglas <[email protected]>
20+
*
21+
* @experimental
22+
*/
23+
#[\Attribute(\Attribute::TARGET_CLASS)]
24+
final class Broadcast
25+
{
26+
public const ACTION_CREATE = 'create';
27+
public const ACTION_UPDATE = 'update';
28+
public const ACTION_REMOVE = 'remove';
29+
30+
/**
31+
* @var mixed[]
32+
*/
33+
public array $options;
34+
35+
/**
36+
* Options can be any option supported by the broadcaster.
37+
*
38+
* @see Broadcaster for the default options when using Mercure
39+
*/
40+
public function __construct(mixed ...$options)
41+
{
42+
$this->options = $options;
43+
}
44+
}

0 commit comments

Comments
 (0)