Skip to content

Commit

Permalink
feat: added symfony/ux-turbo
Browse files Browse the repository at this point in the history
  • Loading branch information
COil committed Apr 1, 2024
1 parent 15429cd commit 799127f
Show file tree
Hide file tree
Showing 11 changed files with 172 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ go-dev: ## Switch to the development environment
@rm -rf ./public/assets/*
#@composer dump-autoload

warmup: ## Warmup the dev cache for the statis analysis
warmup: ## Warmup the dev cache for the static analysis
@bin/console c:w --env=dev

purge: ## Purge all Symfony cache and logs
Expand Down
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ I'll update it when needed:
So, this blog post is the official documentation.
This readme is a teaser of what MicroSymfony contains.

If you want to use the last Symfony **6.4 LTS** version, in your `composer.json`
If you want to use the last Symfony **6.4 LTS** version in your `composer.json`
file, replace all occurrences of `7.0` with `6.4`, run `composer up`, and you are
done.

Expand All @@ -23,7 +23,7 @@ done.
Because a live demo is always better than all explanations. Here is it:

* Live demo at [https://microsymfony.ovh](https://microsymfony.ovh)
* Live demo powered by FrankenPHP at [https://frankenphp.microsymfony.ovh](https://frankenphp.microsymfony.ovh)
* Live demo powered by [FrankenPHP](#frankenphp-) at [https://frankenphp.microsymfony.ovh](https://frankenphp.microsymfony.ovh)


## Quick-start with the Symfony binary 🎶
Expand Down Expand Up @@ -90,7 +90,8 @@ Open [https://localhost](https://localhost) and enjoy! 🙂

* [Symfony 7.0](https://symfony.com/7)
* [Twig 3.8](https://twig.symfony.com)
* [Stimulus 3.2](https://stimulus.hotwired.dev/)
* [hotwired/stimulus 3.2](https://stimulus.hotwired.dev/)
* [hotwired/turbo 7.3](https://turbo.hotwired.dev/)
* [PHPUnit 11.0](https://phpunit.de)
* The classless [BareCSS](http://barecss.com) CSS framework

Expand Down Expand Up @@ -128,6 +129,14 @@ to fix some issues as the project is not maintained anymore.
* [Demo](https://microsymfony.ovh/404)


## Notes 📒

Turbo forms are disabled in [assets/app.js](assets/app.js).
To enable the feature for a given form, add the `data-turbo="true"` attribute to it.
Or change the parameter `Turbo.setFormMode` to `on` to activate the feature globally.
In both cases, your controller code has to be [modified accordingly](https://symfony.com/bundles/ux-turbo/current/index.html#3-form-response-code-changes).


## Other good practices 👌

* Using strict types in all PHP files ([source](https://github.com/strangebuzz/MicroSymfony/blob/main/src/Controller/AppController.php#L3))
Expand Down
4 changes: 4 additions & 0 deletions assets/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ import './bootstrap.js';
import './vendor/barecss/css/bare.min.css';
import './styles/app.css';

// "optin" - No turbo forms unless you insist. Use data-turbo="true" to enable turbo on individual forms.
// @see https://stackoverflow.com/a/76286583/633864
Turbo.setFormMode('optin') // "on" | "off" | "optin"

console.log('This log comes from assets/app.js - welcome to AssetMapper! 🎉')
13 changes: 12 additions & 1 deletion assets/controllers.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
{
"controllers": [],
"controllers": {
"@symfony/ux-turbo": {
"turbo-core": {
"enabled": true,
"fetch": "eager"
},
"mercure-turbo-stream": {
"enabled": false,
"fetch": "eager"
}
}
},
"entrypoints": []
}
34 changes: 34 additions & 0 deletions assets/vendor/@hotwired/turbo/turbo.index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"symfony/stimulus-bundle": "^2.0",
"symfony/string": "7.0.*",
"symfony/twig-bundle": "~7.0.0",
"symfony/ux-turbo": "^2.16",
"symfony/validator": "~7.0.0",
"symfony/web-link": "7.0.*",
"symfony/yaml": "~7.0.0",
Expand Down
98 changes: 97 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
Symfony\UX\StimulusBundle\StimulusBundle::class => ['all' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
Symfony\UX\Turbo\TurboBundle::class => ['all' => true],
];
5 changes: 4 additions & 1 deletion importmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
'path' => '@symfony/stimulus-bundle/loader.js',
],
'barecss/css/bare.min.css' => [
'version' => '1.2.0',
'version' => '1.1.0',
'type' => 'css',
],
'@hotwired/turbo' => [
'version' => '7.3.0',
],
];
3 changes: 3 additions & 0 deletions symfony.lock
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@
"templates/base.html.twig"
]
},
"symfony/ux-turbo": {
"version": "v2.16.0"
},
"symfony/validator": {
"version": "6.2",
"recipe": {
Expand Down
3 changes: 3 additions & 0 deletions templates/_form.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div id="user-form">
{{ form(form, {'attr': {'novalidate': 'novalidate'}}) }}
</div>

0 comments on commit 799127f

Please sign in to comment.