Skip to content

Symfony UX Turbo: content negotiation and Doctrine integration #64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 77 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
52ef583
feat: initial implementation
dunglas Dec 24, 2020
0e528bc
refactor: decouple Broadcast from Twig and Mercure
dunglas Dec 30, 2020
9550346
refactor: broadcast template conventions and config
dunglas Dec 30, 2020
b5352a0
Merge pull request #1 from symfony/refactor/broadcast
dunglas Dec 31, 2020
4471ffe
ci: add PHP-CS-Fixer
dunglas Dec 31, 2020
0684f44
ci: add PHPStan
dunglas Dec 31, 2020
601b394
Merge pull request #2 from symfony/ci
dunglas Dec 31, 2020
73662ca
test: add UI tests (#4)
dunglas Jan 7, 2021
0612bca
fix: various quality improvements (#6)
dunglas Jan 8, 2021
2364545
Relax minimum php version (#5)
chalasr Jan 10, 2021
a90d68c
fix: regressions introduced in #5 (#7)
dunglas Jan 10, 2021
a08e7b6
ci: setup GitHub Actions (#8)
dunglas Jan 11, 2021
619b679
updating stream media type to match changes in Turbo (#11)
weaverryan Jan 14, 2021
a54ed8d
tweaking how the cloned form is used in the docs (#12)
weaverryan Jan 14, 2021
2f49b9f
prepare merge in symfony/ux
dunglas Mar 2, 2021
2d83462
Merge /Users/dunglas/workspace/hotwire-bundle into turbo
dunglas Mar 2, 2021
001308c
mark as experimental, fix PHP CS config
dunglas Mar 2, 2021
f3f22ea
CS
dunglas Mar 2, 2021
ec5e8f8
ci: fixes
dunglas Mar 2, 2021
47beb6b
Add JS test for TurboStreamController, CS
dunglas Mar 3, 2021
aef187e
fix tests
dunglas Mar 3, 2021
c7e1a74
fix tests
dunglas Mar 3, 2021
be52534
fix tests
dunglas Mar 3, 2021
44c588f
fix tests
dunglas Mar 3, 2021
851a349
Update src/Turbo/Broadcaster/TwigMercureBroadcaster.php
dunglas Mar 4, 2021
b18f6eb
Update src/Turbo/README.md
dunglas Mar 4, 2021
a6af2b6
Update src/Turbo/README.md
dunglas Mar 4, 2021
c0edafe
Update src/Turbo/README.md
dunglas Mar 4, 2021
5ef62cb
Update src/Turbo/README.md
dunglas Mar 4, 2021
5ff8cf4
Update src/Turbo/README.md
dunglas Mar 4, 2021
0d8bf24
Update src/Turbo/Tests/TurboStreamTest.php
dunglas Mar 4, 2021
ee49ac2
Update src/Turbo/Tests/TurboStreamTest.php
dunglas Mar 4, 2021
3e1d0ef
Update src/Turbo/Broadcaster/TwigMercureBroadcaster.php
dunglas Mar 4, 2021
27a1b65
Update src/Turbo/README.md
dunglas Mar 4, 2021
68b3324
Update src/Turbo/README.md
dunglas Mar 4, 2021
7b03787
Update src/Turbo/README.md
dunglas Mar 4, 2021
cce5f45
Update src/Turbo/README.md
dunglas Mar 4, 2021
f2c254c
Update src/Turbo/README.md
dunglas Mar 4, 2021
fee1f6e
cleanup
dunglas Mar 4, 2021
2e85605
Use stimulus_controller(), simplify the Twig integration
dunglas Mar 4, 2021
52e828e
fix tests
dunglas Mar 4, 2021
870c8ca
deprecs
dunglas Mar 4, 2021
4e5f9cd
fix tests
dunglas Mar 4, 2021
57f6eaa
allow to subscribe to updates of a single entity
dunglas Mar 4, 2021
695037b
typo
dunglas Mar 4, 2021
9522129
Add a transport mechanism, support multiple Mercure hubs
dunglas Mar 15, 2021
f0e7900
cleanup
dunglas Mar 15, 2021
f213ace
Update src/Turbo/README.md
dunglas Mar 16, 2021
8bb3db3
Update src/Turbo/README.md
dunglas Mar 16, 2021
e8b335b
fix CS
dunglas Mar 16, 2021
328786c
review
dunglas Mar 16, 2021
f244320
Update src/Turbo/Mercure/TurboStreamListenRenderer.php
dunglas Mar 16, 2021
b49727b
Upgrade to MercureBundle 0.3
dunglas Mar 22, 2021
4ebcb20
Merge branch 'turbo' of github.com:dunglas/ux into turbo
dunglas Mar 22, 2021
ee9d3c9
fix deprecations
dunglas Mar 22, 2021
8d057b1
fix reviews
dunglas Mar 23, 2021
6c3ef9e
fix reference to turbo_stream_mercure_controller.js
dunglas Mar 26, 2021
d28e5af
Tweaks and review
nicolas-grekas Mar 25, 2021
a1dffea
-
nicolas-grekas Mar 26, 2021
8353ff3
Merge pull request #1 from nicolas-grekas/turbo
dunglas Mar 26, 2021
2400139
Add $options to BroadcastListener::broadcast()
nicolas-grekas Mar 26, 2021
f3d1711
Merge pull request #2 from nicolas-grekas/turbo-options
dunglas Mar 26, 2021
47d8823
cleanup
dunglas Mar 26, 2021
9ba1566
Merge branch 'turbo' of github.com:dunglas/ux into turbo
dunglas Mar 26, 2021
fdcefe7
prettier
dunglas Mar 26, 2021
573ef7d
Add generic TwigBroadcaster
nicolas-grekas Mar 26, 2021
63efb1d
Merge pull request #3 from nicolas-grekas/turbo
dunglas Mar 29, 2021
3788406
Move Mercure integration to a dedicated bridge
nicolas-grekas Mar 30, 2021
b44ed86
Fix JS
dunglas Mar 30, 2021
c0dc43f
re-add main package.json
dunglas Mar 30, 2021
2d75ceb
fix build
dunglas Mar 30, 2021
2391126
fix cs
dunglas Mar 30, 2021
7a871fa
-
nicolas-grekas Mar 30, 2021
ab8d61c
-
nicolas-grekas Mar 30, 2021
80d3d9c
-
nicolas-grekas Mar 30, 2021
57da895
run yarn tests for all workspaces
dunglas Mar 30, 2021
861033a
Merge branch 'turbo-mercure' into turbo
nicolas-grekas Mar 30, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
189 changes: 189 additions & 0 deletions .github/workflows/test-turbo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
name: Symfony UX Turbo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to have a new CI file?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It allows to not set up a useless Mercure service for all other bundles (https://github.com/symfony/ux/pull/64/files/e8b335bd5fb7d50b209fa2e832f22fd846c16bbe#diff-b65cafb402a3698791b8c52f1f17bd1887642e197a7d453c6c3379910f06bd3fR51), but I can merge both files if you prefer.


on:
push:
pull_request:

jobs:
phpstan:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
extensions: zip

- name: Get composer cache directory
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
working-directory: src/Turbo
run: composer install --prefer-dist

- name: Install PHPUnit dependencies
working-directory: src/Turbo
run: vendor/bin/simple-phpunit --version

- name: PHPStan
working-directory: src/Turbo
run: vendor/bin/phpstan analyse --no-progress

tests-php-high-deps:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['7.2', '7.3', '7.4', '8.0']
fail-fast: false
name: PHP ${{ matrix.php-versions }} Test on ubuntu-latest

services:
mercure:
image: dunglas/mercure
env:
SERVER_NAME: :3000
MERCURE_PUBLISHER_JWT_KEY: '!ChangeMe!'
MERCURE_SUBSCRIBER_JWT_KEY: '!ChangeMe!'
MERCURE_EXTRA_DIRECTIVES: |
anonymous
cors_origins *
ports:
- 3000:3000

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: zip, pdo_sqlite

- name: Get composer cache directory
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache PHP dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install PHP dependencies
working-directory: src/Turbo
run: composer install --prefer-dist

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: Install JavaScript dependencies
working-directory: src/Turbo/Tests/app
run: yarn install

- name: Build JavaScript
working-directory: src/Turbo/Tests/app
run: yarn build

- name: Create DB
working-directory: src/Turbo/Tests/app
run: php public/index.php doctrine:schema:create

- name: Run tests
working-directory: src/Turbo
env:
SYMFONY_DEPRECATIONS_HELPER: max[direct]=0
run: vendor/bin/simple-phpunit

tests-php-low-deps:
runs-on: ubuntu-latest
name: PHP 8.0 (lowest) Test on ubuntu-latest

services:
mercure:
image: dunglas/mercure
env:
SERVER_NAME: :3000
MERCURE_PUBLISHER_JWT_KEY: '!ChangeMe!'
MERCURE_SUBSCRIBER_JWT_KEY: '!ChangeMe!'
MERCURE_EXTRA_DIRECTIVES: |
anonymous
cors_origins *
ports:
- 3000:3000

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
extensions: zip, pdo_sqlite

- name: Get composer cache directory
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache PHP dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install PHP dependencies
working-directory: src/Turbo
run: composer update --prefer-dist --prefer-lowest --prefer-stable

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: Install JavaScript dependencies
working-directory: src/Turbo/Tests/app
run: yarn install

- name: Build JavaScript
working-directory: src/Turbo/Tests/app
run: yarn build

- name: Create DB
working-directory: src/Turbo/Tests/app
run: php public/index.php doctrine:schema:create

- name: Run tests
working-directory: src/Turbo
env:
SYMFONY_DEPRECATIONS_HELPER: max[total]=9223372036854775807 # PHP_INT_MAX
run: vendor/bin/simple-phpunit
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
php-version: '7.4'
- name: php-cs-fixer
run: |
wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.16.1/php-cs-fixer.phar -q
wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.18.2/php-cs-fixer.phar -q
php php-cs-fixer.phar fix --dry-run --diff

coding-style-js:
Expand Down
2 changes: 2 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@ return PhpCsFixer\Config::create()
->in(__DIR__.'/src')
->append([__FILE__])
->notPath('#/Fixtures/#')
->notPath('#/app/var/#')
->notPath('Turbo/Attribute/Broadcast.php') // Need https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues/4702
)
;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"workspaces": [
"src/*/Resources/assets"
"src/**/Resources/assets"
],
"scripts": {
"build": "yarn workspaces run build",
Expand Down
2 changes: 1 addition & 1 deletion src/Chartjs/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"extra": {
"branch-alias": {
"dev-main": "1.1-dev"
"dev-main": "1.3-dev"
},
"thanks": {
"name": "symfony/ux",
Expand Down
2 changes: 1 addition & 1 deletion src/Cropperjs/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
"extra": {
"branch-alias": {
"dev-main": "1.1-dev"
"dev-main": "1.3-dev"
},
"thanks": {
"name": "symfony/ux",
Expand Down
2 changes: 1 addition & 1 deletion src/Dropzone/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"extra": {
"branch-alias": {
"dev-main": "1.1-dev"
"dev-main": "1.3-dev"
},
"thanks": {
"name": "symfony/ux",
Expand Down
2 changes: 1 addition & 1 deletion src/LazyImage/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
},
"extra": {
"branch-alias": {
"dev-main": "1.1-dev"
"dev-main": "1.3-dev"
},
"thanks": {
"name": "symfony/ux",
Expand Down
2 changes: 1 addition & 1 deletion src/Swup/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
],
"extra": {
"branch-alias": {
"dev-main": "1.1-dev"
"dev-main": "1.3-dev"
},
"thanks": {
"name": "symfony/ux",
Expand Down
5 changes: 5 additions & 0 deletions src/Turbo/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/.gitattributes export-ignore
/.gitignore export-ignore
/phpunit.xml.dist export-ignore
/Resources/assets/test export-ignore
/Tests export-ignore
12 changes: 12 additions & 0 deletions src/Turbo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/.php_cs.cache
/.php_cs
/.phpunit.result.cache
/composer.phar
/composer.lock
/phpunit.xml
/vendor/
/Tests/app/var
/Tests/app/public/build/
node_modules/
package-lock.json
yarn.lock
44 changes: 44 additions & 0 deletions src/Turbo/Attribute/Broadcast.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\UX\Turbo\Attribute;

use Symfony\UX\Turbo\Bridge\Mercure\Broadcaster;

/**
* Marks the entity as broadcastable.
*
* @author Kévin Dunglas <[email protected]>
*
* @experimental
*/
#[\Attribute(\Attribute::TARGET_CLASS)]
final class Broadcast
{
public const ACTION_CREATE = 'create';
public const ACTION_UPDATE = 'update';
public const ACTION_REMOVE = 'remove';

/**
* @var mixed[]
*/
public array $options;

/**
* Options can be any option supported by the broadcaster.
*
* @see Broadcaster for the default options when using Mercure
*/
public function __construct(mixed ...$options)
{
$this->options = $options;
}
}
Loading