mirror of
https://github.com/symfony/recipes.git
synced 2026-09-12 07:36:30 +03:00
Update Flex endpoint
This commit is contained in:
+2
-1
@@ -181,6 +181,7 @@ Additional recipes can be found on the [Contrib Recipes Repository](https://gith
|
||||
| [symfony/pushover-notifier](https://packagist.org/packages/symfony/pushover-notifier) | [6.3](../../../tree/main/symfony/pushover-notifier/6.3) | `pushover-notifier`, `pushovernotifier` |
|
||||
| [symfony/pushy-notifier](https://packagist.org/packages/symfony/pushy-notifier) | [7.1](../../../tree/main/symfony/pushy-notifier/7.1) | `pushy-notifier`, `pushynotifier` |
|
||||
| [symfony/redlink-notifier](https://packagist.org/packages/symfony/redlink-notifier) | [6.4](../../../tree/main/symfony/redlink-notifier/6.4) | `redlink-notifier`, `redlinknotifier` |
|
||||
| [symfony/reprise](https://packagist.org/packages/symfony/reprise) | [0.1](../../../tree/main/symfony/reprise/0.1) | `reprise` |
|
||||
| [symfony/requirements-checker](https://packagist.org/packages/symfony/requirements-checker) | [2.0](../../../tree/main/symfony/requirements-checker/2.0) | `req-check`, `req-checker`, `req-checks`, `reqcheck`, `reqchecker`, `reqchecks`, `requirement-check`, `requirement-checker`, `requirementcheck`, `requirementchecker`, `requirements-checker`, `requirementschecker` |
|
||||
| [symfony/resend-mailer](https://packagist.org/packages/symfony/resend-mailer) | [7.1](../../../tree/main/symfony/resend-mailer/7.1) | `resend-mailer`, `resendmailer` |
|
||||
| [symfony/ring-central-notifier](https://packagist.org/packages/symfony/ring-central-notifier) | [6.3](../../../tree/main/symfony/ring-central-notifier/6.3) | `ring-central-notifier`, `ringcentralnotifier` |
|
||||
@@ -208,7 +209,7 @@ Additional recipes can be found on the [Contrib Recipes Repository](https://gith
|
||||
| [symfony/smsense-notifier](https://packagist.org/packages/symfony/smsense-notifier) | [7.1](../../../tree/main/symfony/smsense-notifier/7.1) | `smsense-notifier`, `smsensenotifier` |
|
||||
| [symfony/smsmode-notifier](https://packagist.org/packages/symfony/smsmode-notifier) | [6.3](../../../tree/main/symfony/smsmode-notifier/6.3) | `smsmode-notifier`, `smsmodenotifier` |
|
||||
| [symfony/spot-hit-notifier](https://packagist.org/packages/symfony/spot-hit-notifier) | [5.3](../../../tree/main/symfony/spot-hit-notifier/5.3) | `spot-hit-notifier`, `spothitnotifier` |
|
||||
| [symfony/stimulus-bundle](https://packagist.org/packages/symfony/stimulus-bundle) | [2.25](../../../tree/main/symfony/stimulus-bundle/2.25) | `stimulus`, `stimulus-bundle`, `stimulusbundle` |
|
||||
| [symfony/stimulus-bundle](https://packagist.org/packages/symfony/stimulus-bundle) | [3.3](../../../tree/main/symfony/stimulus-bundle/3.3) | `stimulus`, `stimulus-bundle`, `stimulusbundle` |
|
||||
| [symfony/sweego-mailer](https://packagist.org/packages/symfony/sweego-mailer) | [7.2](../../../tree/main/symfony/sweego-mailer/7.2) | `sweego-mailer`, `sweegomailer` |
|
||||
| [symfony/sweego-notifier](https://packagist.org/packages/symfony/sweego-notifier) | [7.2](../../../tree/main/symfony/sweego-notifier/7.2) | `sweego-notifier`, `sweegonotifier` |
|
||||
| [symfony/swiftmailer-bundle](https://packagist.org/packages/symfony/swiftmailer-bundle) | [2.5](../../../tree/main/symfony/swiftmailer-bundle/2.5) | `swiftmailer`, `swiftmailer-bundle`, `swiftmailerbundle` |
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
{
|
||||
"manifests": {
|
||||
"symfony/reprise": {
|
||||
"manifest": {
|
||||
"bundles": {
|
||||
"Symfony\\Reprise\\RepriseBundle": [
|
||||
"all"
|
||||
]
|
||||
},
|
||||
"copy-from-recipe": {
|
||||
"assets/": "assets/",
|
||||
"config/": "%CONFIG_DIR%/"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/flex": "<1.20.0 || >=2.0.0,<2.3.0",
|
||||
"symfony/framework-bundle": "<6.4"
|
||||
},
|
||||
"gitignore": [
|
||||
"/node_modules/",
|
||||
"/%PUBLIC_DIR%/build/"
|
||||
],
|
||||
"add-lines": [
|
||||
{
|
||||
"file": "templates/base.html.twig",
|
||||
"content": " {{ reprise_entry_link_tags('app') }}",
|
||||
"position": "after_target",
|
||||
"target": "{% block stylesheets %}",
|
||||
"warn_if_missing": true
|
||||
},
|
||||
{
|
||||
"file": "templates/base.html.twig",
|
||||
"content": " {{ reprise_entry_script_tags('app') }}",
|
||||
"position": "after_target",
|
||||
"target": "{% block javascripts %}",
|
||||
"warn_if_missing": true
|
||||
}
|
||||
],
|
||||
"post-install-output": [
|
||||
"",
|
||||
" <bg=blue;fg=white> </>",
|
||||
" <bg=blue;fg=white> Symfony Reprise </>",
|
||||
" <bg=blue;fg=white> </>",
|
||||
"",
|
||||
" A few frontend steps remain to wire up your bundler.",
|
||||
" The commands below use npm (or pnpm, yarn, ...).",
|
||||
"",
|
||||
" * If you don't have a bundler yet, install <fg=green>Vite</> or <fg=green>Rsbuild</>:",
|
||||
"",
|
||||
" <fg=green>npm install --save-dev vite</>",
|
||||
" <comment># or</>",
|
||||
" <fg=green>npm install --save-dev @rsbuild/core</>",
|
||||
"",
|
||||
" * Install the Reprise plugin:",
|
||||
"",
|
||||
" <fg=green>npm install --save-dev @symfony/reprise</>",
|
||||
"",
|
||||
" * Register the plugin in your bundler config:",
|
||||
"",
|
||||
" <comment>// vite.config.js</>",
|
||||
" import { defineConfig } from 'vite'",
|
||||
" import Symfony from '@symfony/reprise/vite'",
|
||||
"",
|
||||
" export default defineConfig({",
|
||||
" build: {",
|
||||
" rollupOptions: {",
|
||||
" input: {",
|
||||
" app: './assets/app.js',",
|
||||
" },",
|
||||
" },",
|
||||
" },",
|
||||
" plugins: [",
|
||||
" Symfony({",
|
||||
" // Enable support for Stimulus Controller and Symfony UX",
|
||||
" // stimulus: './assets/controllers.json',",
|
||||
" }),",
|
||||
" ],",
|
||||
" })",
|
||||
"",
|
||||
" <comment>// rsbuild.config.js</>",
|
||||
" import { defineConfig } from '@rsbuild/core'",
|
||||
" import Symfony from '@symfony/reprise/rsbuild'",
|
||||
"",
|
||||
" export default defineConfig({",
|
||||
" source: {",
|
||||
" entry: {",
|
||||
" app: './assets/app.js',",
|
||||
" },",
|
||||
" },",
|
||||
" plugins: [",
|
||||
" Symfony({",
|
||||
" // Enable support for Stimulus Controller and Symfony UX",
|
||||
" // stimulus: './assets/controllers.json',",
|
||||
" }),",
|
||||
" ],",
|
||||
" })",
|
||||
"",
|
||||
" * Render your assets from Twig with <fg=green>reprise_entry_link_tags('app')</> and",
|
||||
" <fg=green>reprise_entry_script_tags('app')</> (already added to <fg=green>templates/base.html.twig</> for you).",
|
||||
"",
|
||||
" * Build your assets:",
|
||||
"",
|
||||
" <fg=green>npx vite build</> <comment># or: npx rsbuild build</>",
|
||||
" <fg=green>npx vite</> <comment># dev server (or: npx rsbuild dev)</>",
|
||||
"",
|
||||
" * Read the documentation: <comment>https://github.com/symfony/reprise</>"
|
||||
]
|
||||
},
|
||||
"files": {
|
||||
"assets/app.js": {
|
||||
"contents": [
|
||||
"/*",
|
||||
" * Welcome to your app's main JavaScript file!",
|
||||
" *",
|
||||
" * This file will be included onto the page via the reprise_entry_script_tags('app') Twig function,",
|
||||
" * which should already be in your base.html.twig.",
|
||||
" */",
|
||||
"import './styles/app.css';",
|
||||
"",
|
||||
"console.log('This log comes from assets/app.js - welcome to Symfony Reprise! \ud83c\udf89');",
|
||||
""
|
||||
],
|
||||
"executable": false
|
||||
},
|
||||
"assets/styles/app.css": {
|
||||
"contents": [
|
||||
"body {",
|
||||
" background-color: skyblue;",
|
||||
"}",
|
||||
""
|
||||
],
|
||||
"executable": false
|
||||
},
|
||||
"config/packages/reprise.yaml": {
|
||||
"contents": [
|
||||
"# Reprise works with zero configuration. Every option below is shown at its",
|
||||
"# default value; uncomment the block and tweak what you need.",
|
||||
"# See https://github.com/symfony/reprise/blob/main/doc/index.rst#configuration",
|
||||
"# reprise:",
|
||||
" # Directory the @symfony/reprise plugin writes entrypoints.json and manifest.json into.",
|
||||
" # output_path: '%kernel.project_dir%/public/build'",
|
||||
"",
|
||||
" # Throw when entrypoints.json or a requested entry is missing, instead of rendering nothing.",
|
||||
" # strict_mode: true",
|
||||
"",
|
||||
" # A framework.assets package name used to resolve entry URLs. null uses the default package.",
|
||||
" # asset_package: null",
|
||||
"",
|
||||
" # crossorigin attribute set alongside SRI integrity: false, 'anonymous' or 'use-credentials'.",
|
||||
" # crossorigin: false",
|
||||
"",
|
||||
" # Register rendered assets as WebLink HTTP/2 Link: preload headers (needs symfony/web-link).",
|
||||
" # preload: true",
|
||||
"",
|
||||
" # Default attributes added to every rendered <script> / <link> tag.",
|
||||
" # script_attributes: []",
|
||||
" # link_attributes: []",
|
||||
"",
|
||||
"framework:",
|
||||
" assets:",
|
||||
" json_manifest_path: '%kernel.project_dir%/public/build/manifest.json'",
|
||||
"",
|
||||
"when@prod:",
|
||||
" reprise:",
|
||||
" # In prod we'd rather render nothing than let a missing entrypoints.json (or entry) take the app down with a 500.",
|
||||
" strict_mode: false",
|
||||
"",
|
||||
" # Cache the entrypoints.json (rebuild Symfony's cache when entrypoints.json changes)",
|
||||
" cache: true",
|
||||
""
|
||||
],
|
||||
"executable": false
|
||||
}
|
||||
},
|
||||
"ref": "912ce6c6bd6b81afac04525159bfcceb08fdd9fe"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
{
|
||||
"manifests": {
|
||||
"symfony/stimulus-bundle": {
|
||||
"manifest": {
|
||||
"bundles": {
|
||||
"Symfony\\UX\\StimulusBundle\\StimulusBundle": [
|
||||
"all"
|
||||
]
|
||||
},
|
||||
"copy-from-recipe": {
|
||||
"assets/": "assets/"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/framework-bundle": "<7.2",
|
||||
"symfony/security-csrf": "<7.2",
|
||||
"symfony/webpack-encore-bundle": "<2.0",
|
||||
"symfony/flex": "<1.20.0 || >=2.0.0,<2.3.0"
|
||||
},
|
||||
"add-lines": [
|
||||
{
|
||||
"file": "webpack.config.js",
|
||||
"content": "\n // enables the Symfony UX Stimulus bridge (used in assets/stimulus_bootstrap.js)\n .enableStimulusBridge('./assets/controllers.json')",
|
||||
"position": "after_target",
|
||||
"target": ".splitEntryChunks()"
|
||||
},
|
||||
{
|
||||
"file": "assets/app.js",
|
||||
"content": "import './stimulus_bootstrap.js';",
|
||||
"position": "top",
|
||||
"warn_if_missing": true
|
||||
},
|
||||
{
|
||||
"file": "assets/stimulus_bootstrap.js",
|
||||
"content": "import { startStimulusApp } from '@symfony/stimulus-bridge';\n\n// Registers Stimulus controllers from controllers.json and in the controllers/ directory\nexport const app = startStimulusApp(import.meta.webpackContext('@symfony/stimulus-bridge/lazy-controller-loader!./controllers', {\n recursive: true,\n regExp: /\\.[jt]sx?$/,\n}));",
|
||||
"position": "top",
|
||||
"requires": "symfony/webpack-encore-bundle"
|
||||
},
|
||||
{
|
||||
"file": "assets/stimulus_bootstrap.js",
|
||||
"content": "import { startStimulusApp } from '@symfony/stimulus-bundle';\n\nconst app = startStimulusApp();",
|
||||
"position": "top",
|
||||
"requires": "symfony/asset-mapper"
|
||||
},
|
||||
{
|
||||
"file": "assets/stimulus_bootstrap.js",
|
||||
"content": "import { startStimulusApp } from '@symfony/reprise/stimulus';\n\nconst app = startStimulusApp();",
|
||||
"position": "top",
|
||||
"requires": "symfony/reprise"
|
||||
}
|
||||
],
|
||||
"post-install-output": [
|
||||
"",
|
||||
" * Add a <comment>data-controller=\"hello\"</> attribute to any element to try the example controller.",
|
||||
"",
|
||||
" * Using <fg=green>Symfony Reprise</>? Turn Stimulus on by adding the <fg=green>stimulus</> option to the",
|
||||
" Symfony() plugin in your <comment>vite.config</> or <comment>rsbuild.config</>:",
|
||||
"",
|
||||
" Symfony({",
|
||||
" stimulus: './assets/controllers.json',",
|
||||
" })",
|
||||
"",
|
||||
" * Using <fg=green>Webpack Encore</>? Install the Stimulus bridge, which is no longer",
|
||||
" added automatically as of StimulusBundle 3.3:",
|
||||
"",
|
||||
" <fg=green>npm install --save-dev @symfony/stimulus-bridge</>"
|
||||
]
|
||||
},
|
||||
"files": {
|
||||
"assets/controllers.json": {
|
||||
"contents": [
|
||||
"{",
|
||||
" \"controllers\": [],",
|
||||
" \"entrypoints\": []",
|
||||
"}",
|
||||
""
|
||||
],
|
||||
"executable": false
|
||||
},
|
||||
"assets/controllers/csrf_protection_controller.js": {
|
||||
"contents": [
|
||||
"const nameCheck = /^[-_a-zA-Z0-9]{4,22}$/;",
|
||||
"const tokenCheck = /^[-_/+a-zA-Z0-9]{24,}$/;",
|
||||
"",
|
||||
"// Generate and double-submit a CSRF token in a form field and a cookie, as defined by Symfony's SameOriginCsrfTokenManager",
|
||||
"// Use `form.requestSubmit()` to ensure that the submit event is triggered. Using `form.submit()` will not trigger the event",
|
||||
"// and thus this event-listener will not be executed.",
|
||||
"document.addEventListener('submit', function (event) {",
|
||||
" generateCsrfToken(event.target);",
|
||||
"}, true);",
|
||||
"",
|
||||
"// When @hotwired/turbo handles form submissions, send the CSRF token in a header in addition to a cookie",
|
||||
"// The `framework.csrf_protection.check_header` config option needs to be enabled for the header to be checked",
|
||||
"document.addEventListener('turbo:submit-start', function (event) {",
|
||||
" const h = generateCsrfHeaders(event.detail.formSubmission.formElement);",
|
||||
" Object.keys(h).map(function (k) {",
|
||||
" event.detail.formSubmission.fetchRequest.headers[k] = h[k];",
|
||||
" });",
|
||||
"});",
|
||||
"",
|
||||
"// When @hotwired/turbo handles form submissions, remove the CSRF cookie once a form has been submitted",
|
||||
"document.addEventListener('turbo:submit-end', function (event) {",
|
||||
" removeCsrfToken(event.detail.formSubmission.formElement);",
|
||||
"});",
|
||||
"",
|
||||
"export function generateCsrfToken (formElement) {",
|
||||
" const csrfField = formElement.querySelector('input[data-controller=\"csrf-protection\"], input[name=\"_csrf_token\"]');",
|
||||
"",
|
||||
" if (!csrfField) {",
|
||||
" return;",
|
||||
" }",
|
||||
"",
|
||||
" let csrfCookie = csrfField.getAttribute('data-csrf-protection-cookie-value');",
|
||||
" let csrfToken = csrfField.value;",
|
||||
"",
|
||||
" if (!csrfCookie && nameCheck.test(csrfToken)) {",
|
||||
" csrfField.setAttribute('data-csrf-protection-cookie-value', csrfCookie = csrfToken);",
|
||||
" csrfField.defaultValue = csrfToken = btoa(String.fromCharCode.apply(null, (window.crypto || window.msCrypto).getRandomValues(new Uint8Array(18))));",
|
||||
" }",
|
||||
" csrfField.dispatchEvent(new Event('change', { bubbles: true }));",
|
||||
"",
|
||||
" if (csrfCookie && tokenCheck.test(csrfToken)) {",
|
||||
" const cookie = csrfCookie + '_' + csrfToken + '=' + csrfCookie + '; path=/; samesite=strict';",
|
||||
" document.cookie = window.location.protocol === 'https:' ? '__Host-' + cookie + '; secure' : cookie;",
|
||||
" }",
|
||||
"}",
|
||||
"",
|
||||
"export function generateCsrfHeaders (formElement) {",
|
||||
" const headers = {};",
|
||||
" const csrfField = formElement.querySelector('input[data-controller=\"csrf-protection\"], input[name=\"_csrf_token\"]');",
|
||||
"",
|
||||
" if (!csrfField) {",
|
||||
" return headers;",
|
||||
" }",
|
||||
"",
|
||||
" const csrfCookie = csrfField.getAttribute('data-csrf-protection-cookie-value');",
|
||||
"",
|
||||
" if (tokenCheck.test(csrfField.value) && nameCheck.test(csrfCookie)) {",
|
||||
" headers[csrfCookie] = csrfField.value;",
|
||||
" }",
|
||||
"",
|
||||
" return headers;",
|
||||
"}",
|
||||
"",
|
||||
"export function removeCsrfToken (formElement) {",
|
||||
" const csrfField = formElement.querySelector('input[data-controller=\"csrf-protection\"], input[name=\"_csrf_token\"]');",
|
||||
"",
|
||||
" if (!csrfField) {",
|
||||
" return;",
|
||||
" }",
|
||||
"",
|
||||
" const csrfCookie = csrfField.getAttribute('data-csrf-protection-cookie-value');",
|
||||
"",
|
||||
" if (tokenCheck.test(csrfField.value) && nameCheck.test(csrfCookie)) {",
|
||||
" const cookie = csrfCookie + '_' + csrfField.value + '=0; path=/; samesite=strict; max-age=0';",
|
||||
"",
|
||||
" document.cookie = window.location.protocol === 'https:' ? '__Host-' + cookie + '; secure' : cookie;",
|
||||
" }",
|
||||
"}",
|
||||
"",
|
||||
"/* stimulusFetch: 'lazy' */",
|
||||
"export default 'csrf-protection-controller';",
|
||||
""
|
||||
],
|
||||
"executable": false
|
||||
},
|
||||
"assets/controllers/hello_controller.js": {
|
||||
"contents": [
|
||||
"import { Controller } from '@hotwired/stimulus';",
|
||||
"",
|
||||
"/*",
|
||||
" * This is an example Stimulus controller!",
|
||||
" *",
|
||||
" * Any element with a data-controller=\"hello\" attribute will cause",
|
||||
" * this controller to be executed. The name \"hello\" comes from the filename:",
|
||||
" * hello_controller.js -> \"hello\"",
|
||||
" *",
|
||||
" * Delete this file or adapt it for your use!",
|
||||
" */",
|
||||
"export default class extends Controller {",
|
||||
" connect() {",
|
||||
" this.element.textContent = 'Hello Stimulus! Edit me in assets/controllers/hello_controller.js';",
|
||||
" }",
|
||||
"}",
|
||||
""
|
||||
],
|
||||
"executable": false
|
||||
},
|
||||
"assets/stimulus_bootstrap.js": {
|
||||
"contents": [
|
||||
"// register any custom, 3rd party controllers here",
|
||||
"// app.register('some_controller_name', SomeImportedController);",
|
||||
""
|
||||
],
|
||||
"executable": false
|
||||
}
|
||||
},
|
||||
"ref": "30f7461c215766d446f3c990b2b18f08ff51386e"
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
-1
@@ -455,6 +455,7 @@
|
||||
"redlinknotifier": "symfony/redlink-notifier",
|
||||
"remote-event": "symfony/remote-event",
|
||||
"remoteevent": "symfony/remote-event",
|
||||
"reprise": "symfony/reprise",
|
||||
"req-check": "symfony/requirements-checker",
|
||||
"req-checker": "symfony/requirements-checker",
|
||||
"req-checks": "symfony/requirements-checker",
|
||||
@@ -1280,6 +1281,9 @@
|
||||
"symfony/redlink-notifier": [
|
||||
"6.4"
|
||||
],
|
||||
"symfony/reprise": [
|
||||
"0.1"
|
||||
],
|
||||
"symfony/requirements-checker": [
|
||||
"1.0",
|
||||
"2.0"
|
||||
@@ -1386,7 +1390,8 @@
|
||||
"2.13",
|
||||
"2.20",
|
||||
"2.24",
|
||||
"2.25"
|
||||
"2.25",
|
||||
"3.3"
|
||||
],
|
||||
"symfony/sweego-mailer": [
|
||||
"7.2"
|
||||
@@ -1687,6 +1692,12 @@
|
||||
"symfony/framework-bundle": "<5.4"
|
||||
}
|
||||
},
|
||||
"symfony/reprise": {
|
||||
"0.1": {
|
||||
"symfony/flex": "<1.20.0 || >=2.0.0,<2.3.0",
|
||||
"symfony/framework-bundle": "<6.4"
|
||||
}
|
||||
},
|
||||
"symfony/routing": {
|
||||
"5.3": {
|
||||
"symfony/framework-bundle": "<5.3"
|
||||
@@ -1744,6 +1755,12 @@
|
||||
"symfony/framework-bundle": "<7.2",
|
||||
"symfony/security-csrf": "<7.2",
|
||||
"symfony/webpack-encore-bundle": "<2.0"
|
||||
},
|
||||
"3.3": {
|
||||
"symfony/flex": "<1.20.0 || >=2.0.0,<2.3.0",
|
||||
"symfony/framework-bundle": "<7.2",
|
||||
"symfony/security-csrf": "<7.2",
|
||||
"symfony/webpack-encore-bundle": "<2.0"
|
||||
}
|
||||
},
|
||||
"symfony/twig-bundle": {
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
{
|
||||
"manifests": {
|
||||
"symfony/reprise": {
|
||||
"manifest": {
|
||||
"bundles": {
|
||||
"Symfony\\Reprise\\RepriseBundle": [
|
||||
"all"
|
||||
]
|
||||
},
|
||||
"copy-from-recipe": {
|
||||
"assets/": "assets/",
|
||||
"config/": "%CONFIG_DIR%/"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/flex": "<1.20.0 || >=2.0.0,<2.3.0",
|
||||
"symfony/framework-bundle": "<6.4"
|
||||
},
|
||||
"gitignore": [
|
||||
"/node_modules/",
|
||||
"/%PUBLIC_DIR%/build/"
|
||||
],
|
||||
"add-lines": [
|
||||
{
|
||||
"file": "templates/base.html.twig",
|
||||
"content": " {{ reprise_entry_link_tags('app') }}",
|
||||
"position": "after_target",
|
||||
"target": "{% block stylesheets %}",
|
||||
"warn_if_missing": true
|
||||
},
|
||||
{
|
||||
"file": "templates/base.html.twig",
|
||||
"content": " {{ reprise_entry_script_tags('app') }}",
|
||||
"position": "after_target",
|
||||
"target": "{% block javascripts %}",
|
||||
"warn_if_missing": true
|
||||
}
|
||||
],
|
||||
"post-install-output": [
|
||||
"",
|
||||
" <bg=blue;fg=white> </>",
|
||||
" <bg=blue;fg=white> Symfony Reprise </>",
|
||||
" <bg=blue;fg=white> </>",
|
||||
"",
|
||||
" A few frontend steps remain to wire up your bundler.",
|
||||
" The commands below use npm (or pnpm, yarn, ...).",
|
||||
"",
|
||||
" * If you don't have a bundler yet, install <fg=green>Vite</> or <fg=green>Rsbuild</>:",
|
||||
"",
|
||||
" <fg=green>npm install --save-dev vite</>",
|
||||
" <comment># or</>",
|
||||
" <fg=green>npm install --save-dev @rsbuild/core</>",
|
||||
"",
|
||||
" * Install the Reprise plugin:",
|
||||
"",
|
||||
" <fg=green>npm install --save-dev @symfony/reprise</>",
|
||||
"",
|
||||
" * Register the plugin in your bundler config:",
|
||||
"",
|
||||
" <comment>// vite.config.js</>",
|
||||
" import { defineConfig } from 'vite'",
|
||||
" import Symfony from '@symfony/reprise/vite'",
|
||||
"",
|
||||
" export default defineConfig({",
|
||||
" build: {",
|
||||
" rollupOptions: {",
|
||||
" input: {",
|
||||
" app: './assets/app.js',",
|
||||
" },",
|
||||
" },",
|
||||
" },",
|
||||
" plugins: [",
|
||||
" Symfony({",
|
||||
" // Enable support for Stimulus Controller and Symfony UX",
|
||||
" // stimulus: './assets/controllers.json',",
|
||||
" }),",
|
||||
" ],",
|
||||
" })",
|
||||
"",
|
||||
" <comment>// rsbuild.config.js</>",
|
||||
" import { defineConfig } from '@rsbuild/core'",
|
||||
" import Symfony from '@symfony/reprise/rsbuild'",
|
||||
"",
|
||||
" export default defineConfig({",
|
||||
" source: {",
|
||||
" entry: {",
|
||||
" app: './assets/app.js',",
|
||||
" },",
|
||||
" },",
|
||||
" plugins: [",
|
||||
" Symfony({",
|
||||
" // Enable support for Stimulus Controller and Symfony UX",
|
||||
" // stimulus: './assets/controllers.json',",
|
||||
" }),",
|
||||
" ],",
|
||||
" })",
|
||||
"",
|
||||
" * Render your assets from Twig with <fg=green>reprise_entry_link_tags('app')</> and",
|
||||
" <fg=green>reprise_entry_script_tags('app')</> (already added to <fg=green>templates/base.html.twig</> for you).",
|
||||
"",
|
||||
" * Build your assets:",
|
||||
"",
|
||||
" <fg=green>npx vite build</> <comment># or: npx rsbuild build</>",
|
||||
" <fg=green>npx vite</> <comment># dev server (or: npx rsbuild dev)</>",
|
||||
"",
|
||||
" * Read the documentation: <comment>https://github.com/symfony/reprise</>"
|
||||
]
|
||||
},
|
||||
"files": {
|
||||
"assets/app.js": {
|
||||
"contents": [
|
||||
"/*",
|
||||
" * Welcome to your app's main JavaScript file!",
|
||||
" *",
|
||||
" * This file will be included onto the page via the reprise_entry_script_tags('app') Twig function,",
|
||||
" * which should already be in your base.html.twig.",
|
||||
" */",
|
||||
"import './styles/app.css';",
|
||||
"",
|
||||
"console.log('This log comes from assets/app.js - welcome to Symfony Reprise! \ud83c\udf89');",
|
||||
""
|
||||
],
|
||||
"executable": false
|
||||
},
|
||||
"assets/styles/app.css": {
|
||||
"contents": [
|
||||
"body {",
|
||||
" background-color: skyblue;",
|
||||
"}",
|
||||
""
|
||||
],
|
||||
"executable": false
|
||||
},
|
||||
"config/packages/reprise.yaml": {
|
||||
"contents": [
|
||||
"# Reprise works with zero configuration. Every option below is shown at its",
|
||||
"# default value; uncomment the block and tweak what you need.",
|
||||
"# See https://github.com/symfony/reprise/blob/main/doc/index.rst#configuration",
|
||||
"# reprise:",
|
||||
" # Directory the @symfony/reprise plugin writes entrypoints.json and manifest.json into.",
|
||||
" # output_path: '%kernel.project_dir%/public/build'",
|
||||
"",
|
||||
" # Throw when entrypoints.json or a requested entry is missing, instead of rendering nothing.",
|
||||
" # strict_mode: true",
|
||||
"",
|
||||
" # A framework.assets package name used to resolve entry URLs. null uses the default package.",
|
||||
" # asset_package: null",
|
||||
"",
|
||||
" # crossorigin attribute set alongside SRI integrity: false, 'anonymous' or 'use-credentials'.",
|
||||
" # crossorigin: false",
|
||||
"",
|
||||
" # Register rendered assets as WebLink HTTP/2 Link: preload headers (needs symfony/web-link).",
|
||||
" # preload: true",
|
||||
"",
|
||||
" # Default attributes added to every rendered <script> / <link> tag.",
|
||||
" # script_attributes: []",
|
||||
" # link_attributes: []",
|
||||
"",
|
||||
"framework:",
|
||||
" assets:",
|
||||
" json_manifest_path: '%kernel.project_dir%/public/build/manifest.json'",
|
||||
"",
|
||||
"when@prod:",
|
||||
" reprise:",
|
||||
" # In prod we'd rather render nothing than let a missing entrypoints.json (or entry) take the app down with a 500.",
|
||||
" strict_mode: false",
|
||||
"",
|
||||
" # Cache the entrypoints.json (rebuild Symfony's cache when entrypoints.json changes)",
|
||||
" cache: true",
|
||||
""
|
||||
],
|
||||
"executable": false
|
||||
}
|
||||
},
|
||||
"ref": "912ce6c6bd6b81afac04525159bfcceb08fdd9fe"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
{
|
||||
"manifests": {
|
||||
"symfony/stimulus-bundle": {
|
||||
"manifest": {
|
||||
"bundles": {
|
||||
"Symfony\\UX\\StimulusBundle\\StimulusBundle": [
|
||||
"all"
|
||||
]
|
||||
},
|
||||
"copy-from-recipe": {
|
||||
"assets/": "assets/"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/framework-bundle": "<7.2",
|
||||
"symfony/security-csrf": "<7.2",
|
||||
"symfony/webpack-encore-bundle": "<2.0",
|
||||
"symfony/flex": "<1.20.0 || >=2.0.0,<2.3.0"
|
||||
},
|
||||
"add-lines": [
|
||||
{
|
||||
"file": "webpack.config.js",
|
||||
"content": "\n // enables the Symfony UX Stimulus bridge (used in assets/stimulus_bootstrap.js)\n .enableStimulusBridge('./assets/controllers.json')",
|
||||
"position": "after_target",
|
||||
"target": ".splitEntryChunks()"
|
||||
},
|
||||
{
|
||||
"file": "assets/app.js",
|
||||
"content": "import './stimulus_bootstrap.js';",
|
||||
"position": "top",
|
||||
"warn_if_missing": true
|
||||
},
|
||||
{
|
||||
"file": "assets/stimulus_bootstrap.js",
|
||||
"content": "import { startStimulusApp } from '@symfony/stimulus-bridge';\n\n// Registers Stimulus controllers from controllers.json and in the controllers/ directory\nexport const app = startStimulusApp(import.meta.webpackContext('@symfony/stimulus-bridge/lazy-controller-loader!./controllers', {\n recursive: true,\n regExp: /\\.[jt]sx?$/,\n}));",
|
||||
"position": "top",
|
||||
"requires": "symfony/webpack-encore-bundle"
|
||||
},
|
||||
{
|
||||
"file": "assets/stimulus_bootstrap.js",
|
||||
"content": "import { startStimulusApp } from '@symfony/stimulus-bundle';\n\nconst app = startStimulusApp();",
|
||||
"position": "top",
|
||||
"requires": "symfony/asset-mapper"
|
||||
},
|
||||
{
|
||||
"file": "assets/stimulus_bootstrap.js",
|
||||
"content": "import { startStimulusApp } from '@symfony/reprise/stimulus';\n\nconst app = startStimulusApp();",
|
||||
"position": "top",
|
||||
"requires": "symfony/reprise"
|
||||
}
|
||||
],
|
||||
"post-install-output": [
|
||||
"",
|
||||
" * Add a <comment>data-controller=\"hello\"</> attribute to any element to try the example controller.",
|
||||
"",
|
||||
" * Using <fg=green>Symfony Reprise</>? Turn Stimulus on by adding the <fg=green>stimulus</> option to the",
|
||||
" Symfony() plugin in your <comment>vite.config</> or <comment>rsbuild.config</>:",
|
||||
"",
|
||||
" Symfony({",
|
||||
" stimulus: './assets/controllers.json',",
|
||||
" })",
|
||||
"",
|
||||
" * Using <fg=green>Webpack Encore</>? Install the Stimulus bridge, which is no longer",
|
||||
" added automatically as of StimulusBundle 3.3:",
|
||||
"",
|
||||
" <fg=green>npm install --save-dev @symfony/stimulus-bridge</>"
|
||||
]
|
||||
},
|
||||
"files": {
|
||||
"assets/controllers.json": {
|
||||
"contents": [
|
||||
"{",
|
||||
" \"controllers\": [],",
|
||||
" \"entrypoints\": []",
|
||||
"}",
|
||||
""
|
||||
],
|
||||
"executable": false
|
||||
},
|
||||
"assets/controllers/csrf_protection_controller.js": {
|
||||
"contents": [
|
||||
"const nameCheck = /^[-_a-zA-Z0-9]{4,22}$/;",
|
||||
"const tokenCheck = /^[-_/+a-zA-Z0-9]{24,}$/;",
|
||||
"",
|
||||
"// Generate and double-submit a CSRF token in a form field and a cookie, as defined by Symfony's SameOriginCsrfTokenManager",
|
||||
"// Use `form.requestSubmit()` to ensure that the submit event is triggered. Using `form.submit()` will not trigger the event",
|
||||
"// and thus this event-listener will not be executed.",
|
||||
"document.addEventListener('submit', function (event) {",
|
||||
" generateCsrfToken(event.target);",
|
||||
"}, true);",
|
||||
"",
|
||||
"// When @hotwired/turbo handles form submissions, send the CSRF token in a header in addition to a cookie",
|
||||
"// The `framework.csrf_protection.check_header` config option needs to be enabled for the header to be checked",
|
||||
"document.addEventListener('turbo:submit-start', function (event) {",
|
||||
" const h = generateCsrfHeaders(event.detail.formSubmission.formElement);",
|
||||
" Object.keys(h).map(function (k) {",
|
||||
" event.detail.formSubmission.fetchRequest.headers[k] = h[k];",
|
||||
" });",
|
||||
"});",
|
||||
"",
|
||||
"// When @hotwired/turbo handles form submissions, remove the CSRF cookie once a form has been submitted",
|
||||
"document.addEventListener('turbo:submit-end', function (event) {",
|
||||
" removeCsrfToken(event.detail.formSubmission.formElement);",
|
||||
"});",
|
||||
"",
|
||||
"export function generateCsrfToken (formElement) {",
|
||||
" const csrfField = formElement.querySelector('input[data-controller=\"csrf-protection\"], input[name=\"_csrf_token\"]');",
|
||||
"",
|
||||
" if (!csrfField) {",
|
||||
" return;",
|
||||
" }",
|
||||
"",
|
||||
" let csrfCookie = csrfField.getAttribute('data-csrf-protection-cookie-value');",
|
||||
" let csrfToken = csrfField.value;",
|
||||
"",
|
||||
" if (!csrfCookie && nameCheck.test(csrfToken)) {",
|
||||
" csrfField.setAttribute('data-csrf-protection-cookie-value', csrfCookie = csrfToken);",
|
||||
" csrfField.defaultValue = csrfToken = btoa(String.fromCharCode.apply(null, (window.crypto || window.msCrypto).getRandomValues(new Uint8Array(18))));",
|
||||
" }",
|
||||
" csrfField.dispatchEvent(new Event('change', { bubbles: true }));",
|
||||
"",
|
||||
" if (csrfCookie && tokenCheck.test(csrfToken)) {",
|
||||
" const cookie = csrfCookie + '_' + csrfToken + '=' + csrfCookie + '; path=/; samesite=strict';",
|
||||
" document.cookie = window.location.protocol === 'https:' ? '__Host-' + cookie + '; secure' : cookie;",
|
||||
" }",
|
||||
"}",
|
||||
"",
|
||||
"export function generateCsrfHeaders (formElement) {",
|
||||
" const headers = {};",
|
||||
" const csrfField = formElement.querySelector('input[data-controller=\"csrf-protection\"], input[name=\"_csrf_token\"]');",
|
||||
"",
|
||||
" if (!csrfField) {",
|
||||
" return headers;",
|
||||
" }",
|
||||
"",
|
||||
" const csrfCookie = csrfField.getAttribute('data-csrf-protection-cookie-value');",
|
||||
"",
|
||||
" if (tokenCheck.test(csrfField.value) && nameCheck.test(csrfCookie)) {",
|
||||
" headers[csrfCookie] = csrfField.value;",
|
||||
" }",
|
||||
"",
|
||||
" return headers;",
|
||||
"}",
|
||||
"",
|
||||
"export function removeCsrfToken (formElement) {",
|
||||
" const csrfField = formElement.querySelector('input[data-controller=\"csrf-protection\"], input[name=\"_csrf_token\"]');",
|
||||
"",
|
||||
" if (!csrfField) {",
|
||||
" return;",
|
||||
" }",
|
||||
"",
|
||||
" const csrfCookie = csrfField.getAttribute('data-csrf-protection-cookie-value');",
|
||||
"",
|
||||
" if (tokenCheck.test(csrfField.value) && nameCheck.test(csrfCookie)) {",
|
||||
" const cookie = csrfCookie + '_' + csrfField.value + '=0; path=/; samesite=strict; max-age=0';",
|
||||
"",
|
||||
" document.cookie = window.location.protocol === 'https:' ? '__Host-' + cookie + '; secure' : cookie;",
|
||||
" }",
|
||||
"}",
|
||||
"",
|
||||
"/* stimulusFetch: 'lazy' */",
|
||||
"export default 'csrf-protection-controller';",
|
||||
""
|
||||
],
|
||||
"executable": false
|
||||
},
|
||||
"assets/controllers/hello_controller.js": {
|
||||
"contents": [
|
||||
"import { Controller } from '@hotwired/stimulus';",
|
||||
"",
|
||||
"/*",
|
||||
" * This is an example Stimulus controller!",
|
||||
" *",
|
||||
" * Any element with a data-controller=\"hello\" attribute will cause",
|
||||
" * this controller to be executed. The name \"hello\" comes from the filename:",
|
||||
" * hello_controller.js -> \"hello\"",
|
||||
" *",
|
||||
" * Delete this file or adapt it for your use!",
|
||||
" */",
|
||||
"export default class extends Controller {",
|
||||
" connect() {",
|
||||
" this.element.textContent = 'Hello Stimulus! Edit me in assets/controllers/hello_controller.js';",
|
||||
" }",
|
||||
"}",
|
||||
""
|
||||
],
|
||||
"executable": false
|
||||
},
|
||||
"assets/stimulus_bootstrap.js": {
|
||||
"contents": [
|
||||
"// register any custom, 3rd party controllers here",
|
||||
"// app.register('some_controller_name', SomeImportedController);",
|
||||
""
|
||||
],
|
||||
"executable": false
|
||||
}
|
||||
},
|
||||
"ref": "30f7461c215766d446f3c990b2b18f08ff51386e"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user