-
-
Notifications
You must be signed in to change notification settings - Fork 364
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
Closed
Changes from all commits
Commits
Show all changes
77 commits
Select commit
Hold shift + click to select a range
52ef583
feat: initial implementation
dunglas 0e528bc
refactor: decouple Broadcast from Twig and Mercure
dunglas 9550346
refactor: broadcast template conventions and config
dunglas b5352a0
Merge pull request #1 from symfony/refactor/broadcast
dunglas 4471ffe
ci: add PHP-CS-Fixer
dunglas 0684f44
ci: add PHPStan
dunglas 601b394
Merge pull request #2 from symfony/ci
dunglas 73662ca
test: add UI tests (#4)
dunglas 0612bca
fix: various quality improvements (#6)
dunglas 2364545
Relax minimum php version (#5)
chalasr a90d68c
fix: regressions introduced in #5 (#7)
dunglas a08e7b6
ci: setup GitHub Actions (#8)
dunglas 619b679
updating stream media type to match changes in Turbo (#11)
weaverryan a54ed8d
tweaking how the cloned form is used in the docs (#12)
weaverryan 2f49b9f
prepare merge in symfony/ux
dunglas 2d83462
Merge /Users/dunglas/workspace/hotwire-bundle into turbo
dunglas 001308c
mark as experimental, fix PHP CS config
dunglas f3f22ea
CS
dunglas ec5e8f8
ci: fixes
dunglas 47beb6b
Add JS test for TurboStreamController, CS
dunglas aef187e
fix tests
dunglas c7e1a74
fix tests
dunglas be52534
fix tests
dunglas 44c588f
fix tests
dunglas 851a349
Update src/Turbo/Broadcaster/TwigMercureBroadcaster.php
dunglas b18f6eb
Update src/Turbo/README.md
dunglas a6af2b6
Update src/Turbo/README.md
dunglas c0edafe
Update src/Turbo/README.md
dunglas 5ef62cb
Update src/Turbo/README.md
dunglas 5ff8cf4
Update src/Turbo/README.md
dunglas 0d8bf24
Update src/Turbo/Tests/TurboStreamTest.php
dunglas ee49ac2
Update src/Turbo/Tests/TurboStreamTest.php
dunglas 3e1d0ef
Update src/Turbo/Broadcaster/TwigMercureBroadcaster.php
dunglas 27a1b65
Update src/Turbo/README.md
dunglas 68b3324
Update src/Turbo/README.md
dunglas 7b03787
Update src/Turbo/README.md
dunglas cce5f45
Update src/Turbo/README.md
dunglas f2c254c
Update src/Turbo/README.md
dunglas fee1f6e
cleanup
dunglas 2e85605
Use stimulus_controller(), simplify the Twig integration
dunglas 52e828e
fix tests
dunglas 870c8ca
deprecs
dunglas 4e5f9cd
fix tests
dunglas 57f6eaa
allow to subscribe to updates of a single entity
dunglas 695037b
typo
dunglas 9522129
Add a transport mechanism, support multiple Mercure hubs
dunglas f0e7900
cleanup
dunglas f213ace
Update src/Turbo/README.md
dunglas 8bb3db3
Update src/Turbo/README.md
dunglas e8b335b
fix CS
dunglas 328786c
review
dunglas f244320
Update src/Turbo/Mercure/TurboStreamListenRenderer.php
dunglas b49727b
Upgrade to MercureBundle 0.3
dunglas 4ebcb20
Merge branch 'turbo' of github.com:dunglas/ux into turbo
dunglas ee9d3c9
fix deprecations
dunglas 8d057b1
fix reviews
dunglas 6c3ef9e
fix reference to turbo_stream_mercure_controller.js
dunglas d28e5af
Tweaks and review
nicolas-grekas a1dffea
-
nicolas-grekas 8353ff3
Merge pull request #1 from nicolas-grekas/turbo
dunglas 2400139
Add $options to BroadcastListener::broadcast()
nicolas-grekas f3d1711
Merge pull request #2 from nicolas-grekas/turbo-options
dunglas 47d8823
cleanup
dunglas 9ba1566
Merge branch 'turbo' of github.com:dunglas/ux into turbo
dunglas fdcefe7
prettier
dunglas 573ef7d
Add generic TwigBroadcaster
nicolas-grekas 63efb1d
Merge pull request #3 from nicolas-grekas/turbo
dunglas 3788406
Move Mercure integration to a dedicated bridge
nicolas-grekas b44ed86
Fix JS
dunglas c0dc43f
re-add main package.json
dunglas 2d75ceb
fix build
dunglas 2391126
fix cs
dunglas 7a871fa
-
nicolas-grekas ab8d61c
-
nicolas-grekas 80d3d9c
-
nicolas-grekas 57da895
run yarn tests for all workspaces
dunglas 861033a
Merge branch 'turbo-mercure' into turbo
nicolas-grekas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
name: Symfony UX Turbo | ||
|
||
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 | ||
chalasr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.