test
+coucou
+diff --git a/.gitignore b/.gitignore index de562d7..9a33506 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,10 @@ .phpunit.result.cache /phpunit.xml ###< symfony/phpunit-bridge ### + +###> symfony/webpack-encore-bundle ### +/node_modules/ +/public/build/ +npm-debug.log +yarn-error.log +###< symfony/webpack-encore-bundle ### diff --git a/assets/app.js b/assets/app.js new file mode 100644 index 0000000..bb0a6aa --- /dev/null +++ b/assets/app.js @@ -0,0 +1,12 @@ +/* + * Welcome to your app's main JavaScript file! + * + * We recommend including the built version of this JavaScript file + * (and its CSS file) in your base layout (base.html.twig). + */ + +// any CSS you import will output into a single css file (app.css in this case) +import './styles/app.css'; + +// start the Stimulus application +import './bootstrap'; diff --git a/assets/bootstrap.js b/assets/bootstrap.js new file mode 100644 index 0000000..4ab2df6 --- /dev/null +++ b/assets/bootstrap.js @@ -0,0 +1,11 @@ +import { startStimulusApp } from '@symfony/stimulus-bridge'; + +// Registers Stimulus controllers from controllers.json and in the controllers/ directory +export const app = startStimulusApp(require.context( + '@symfony/stimulus-bridge/lazy-controller-loader!./controllers', + true, + /\.[jt]sx?$/ +)); + +// register any custom, 3rd party controllers here +// app.register('some_controller_name', SomeImportedController); diff --git a/assets/controllers.json b/assets/controllers.json new file mode 100644 index 0000000..a1c6e90 --- /dev/null +++ b/assets/controllers.json @@ -0,0 +1,4 @@ +{ + "controllers": [], + "entrypoints": [] +} diff --git a/assets/controllers/hello_controller.js b/assets/controllers/hello_controller.js new file mode 100644 index 0000000..e847027 --- /dev/null +++ b/assets/controllers/hello_controller.js @@ -0,0 +1,16 @@ +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'; + } +} diff --git a/assets/styles/app.css b/assets/styles/app.css new file mode 100644 index 0000000..cb33b13 --- /dev/null +++ b/assets/styles/app.css @@ -0,0 +1,3 @@ +body { + background-color: lightgray; +} diff --git a/composer.json b/composer.json index 06f6660..70513a3 100644 --- a/composer.json +++ b/composer.json @@ -37,6 +37,7 @@ "symfony/twig-bundle": "6.1.*", "symfony/validator": "6.1.*", "symfony/web-link": "6.1.*", + "symfony/webpack-encore-bundle": "^1.17", "symfony/yaml": "6.1.*", "twig/extra-bundle": "^2.12|^3.0", "twig/twig": "^2.12|^3.0" diff --git a/composer.lock b/composer.lock index 184019c..95813c4 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a8178a18a538fee6184abe0543732c72", + "content-hash": "8c1abe2e8026fc52bc20a96868b85bcf", "packages": [ { "name": "doctrine/cache", @@ -6811,6 +6811,79 @@ ], "time": "2023-01-01T08:36:55+00:00" }, + { + "name": "symfony/webpack-encore-bundle", + "version": "v1.17.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/webpack-encore-bundle.git", + "reference": "471ebbc03072dad6e31840dc317bc634a32785f5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/webpack-encore-bundle/zipball/471ebbc03072dad6e31840dc317bc634a32785f5", + "reference": "471ebbc03072dad6e31840dc317bc634a32785f5", + "shasum": "" + }, + "require": { + "php": ">=7.1.3", + "symfony/asset": "^4.4 || ^5.0 || ^6.0", + "symfony/config": "^4.4 || ^5.0 || ^6.0", + "symfony/dependency-injection": "^4.4 || ^5.0 || ^6.0", + "symfony/deprecation-contracts": "^2.1 || ^3.0", + "symfony/http-kernel": "^4.4 || ^5.0 || ^6.0", + "symfony/polyfill-php80": "^1.25.0", + "symfony/service-contracts": "^1.0 || ^2.0 || ^3.0" + }, + "require-dev": { + "symfony/framework-bundle": "^4.4 || ^5.0 || ^6.0", + "symfony/phpunit-bridge": "^5.3 || ^6.0", + "symfony/twig-bundle": "^4.4 || ^5.0 || ^6.0", + "symfony/web-link": "^4.4 || ^5.0 || ^6.0" + }, + "type": "symfony-bundle", + "extra": { + "thanks": { + "name": "symfony/webpack-encore", + "url": "https://github.com/symfony/webpack-encore" + } + }, + "autoload": { + "psr-4": { + "Symfony\\WebpackEncoreBundle\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Integration with your Symfony app & Webpack Encore!", + "support": { + "issues": "https://github.com/symfony/webpack-encore-bundle/issues", + "source": "https://github.com/symfony/webpack-encore-bundle/tree/v1.17.2" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-09-26T14:36:28+00:00" + }, { "name": "symfony/yaml", "version": "v6.1.11", diff --git a/config/bundles.php b/config/bundles.php index 0457f99..3325715 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -11,4 +11,5 @@ return [ Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true], + Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], ]; diff --git a/config/packages/webpack_encore.yaml b/config/packages/webpack_encore.yaml new file mode 100644 index 0000000..4c009ee --- /dev/null +++ b/config/packages/webpack_encore.yaml @@ -0,0 +1,45 @@ +webpack_encore: + # The path where Encore is building the assets - i.e. Encore.setOutputPath() + output_path: '%kernel.project_dir%/public/build' + # If multiple builds are defined (as shown below), you can disable the default build: + # output_path: false + + # Set attributes that will be rendered on all script and link tags + script_attributes: + defer: true + # Uncomment (also under link_attributes) if using Turbo Drive + # https://turbo.hotwired.dev/handbook/drive#reloading-when-assets-change + # 'data-turbo-track': reload + # link_attributes: + # Uncomment if using Turbo Drive + # 'data-turbo-track': reload + + # If using Encore.enableIntegrityHashes() and need the crossorigin attribute (default: false, or use 'anonymous' or 'use-credentials') + # crossorigin: 'anonymous' + + # Preload all rendered script and link tags automatically via the HTTP/2 Link header + # preload: true + + # Throw an exception if the entrypoints.json file is missing or an entry is missing from the data + # strict_mode: false + + # If you have multiple builds: + # builds: + # frontend: '%kernel.project_dir%/public/frontend/build' + + # pass the build name as the 3rd argument to the Twig functions + # {{ encore_entry_script_tags('entry1', null, 'frontend') }} + +framework: + assets: + json_manifest_path: '%kernel.project_dir%/public/build/manifest.json' + +#when@prod: +# webpack_encore: +# # Cache the entrypoints.json (rebuild Symfony's cache when entrypoints.json changes) +# # Available in version 1.2 +# cache: true + +#when@test: +# webpack_encore: +# strict_mode: false diff --git a/package.json b/package.json new file mode 100644 index 0000000..d83a414 --- /dev/null +++ b/package.json @@ -0,0 +1,22 @@ +{ + "devDependencies": { + "@babel/core": "^7.17.0", + "@babel/preset-env": "^7.16.0", + "@hotwired/stimulus": "^3.0.0", + "@symfony/stimulus-bridge": "^3.2.0", + "@symfony/webpack-encore": "^4.0.0", + "core-js": "^3.23.0", + "regenerator-runtime": "^0.13.9", + "webpack": "^5.74.0", + "webpack-cli": "^4.10.0", + "webpack-notifier": "^1.15.0" + }, + "license": "UNLICENSED", + "private": true, + "scripts": { + "dev-server": "encore dev-server", + "dev": "encore dev", + "watch": "encore dev --watch", + "build": "encore production --progress" + } +} diff --git a/public/css/style.css b/public/css/style.css new file mode 100644 index 0000000..40be313 --- /dev/null +++ b/public/css/style.css @@ -0,0 +1,6 @@ +body { + margin: 1em auto; + max-width: 800px; + width: 95%; + font: 18px/1.5 sans-serif; +} diff --git a/src/Controller/HomeController.php b/src/Controller/HomeController.php index 07aad4f..6515f13 100644 --- a/src/Controller/HomeController.php +++ b/src/Controller/HomeController.php @@ -8,11 +8,11 @@ use Symfony\Component\Routing\Annotation\Route; class HomeController extends AbstractController { - #[Route('/home', name: 'app_home')] + #[Route('/', name: 'app_home')] public function index(): Response { return $this->render('home/index.html.twig', [ - 'controller_name' => 'HomeController', + 'controller_name' => 'Home', ]); } } diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php new file mode 100644 index 0000000..92372fa --- /dev/null +++ b/src/Controller/UserController.php @@ -0,0 +1,34 @@ +render('user/index.html.twig', [ + 'controller_name' => 'UserController', + ]); + } + + #[Route('/user/signup', name: 'app_user_signup')] + public function signup(): Response + { + return $this->render('user/signup.html.twig', [ + 'controller_name' => 'UserController', + ]); + } + + #[Route('/user/login', name: 'app_user_login')] + public function login(): Response + { + return $this->render('user/login.html.twig', [ + 'controller_name' => 'UserController', + ]); + } +} diff --git a/src/Form/UserLoginType.php b/src/Form/UserLoginType.php new file mode 100644 index 0000000..9d86015 --- /dev/null +++ b/src/Form/UserLoginType.php @@ -0,0 +1,31 @@ +add('name') + ->add('fullname') + ->add('grade') + ->add('mail') + ->add('mdp') + ->add('address') + ->add('id_resto') + ; + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + 'data_class' => User::class, + ]); + } +} diff --git a/src/Form/UserSignupType.php b/src/Form/UserSignupType.php new file mode 100644 index 0000000..a6fccb9 --- /dev/null +++ b/src/Form/UserSignupType.php @@ -0,0 +1,31 @@ +add('name') + ->add('fullname') + ->add('grade') + ->add('mail') + ->add('mdp') + ->add('address') + ->add('id_resto') + ; + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + 'data_class' => User::class, + ]); + } +} diff --git a/symfony.lock b/symfony.lock index 1e3e112..13db5f3 100644 --- a/symfony.lock +++ b/symfony.lock @@ -243,6 +243,25 @@ "config/routes/web_profiler.yaml" ] }, + "symfony/webpack-encore-bundle": { + "version": "1.17", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "1.10", + "ref": "eff2e505d4557c967b6710fe06bd947ba555cae5" + }, + "files": [ + "assets/app.js", + "assets/bootstrap.js", + "assets/controllers.json", + "assets/controllers/hello_controller.js", + "assets/styles/app.css", + "config/packages/webpack_encore.yaml", + "package.json", + "webpack.config.js" + ] + }, "twig/extra-bundle": { "version": "v3.7.1" } diff --git a/templates/base.html.twig b/templates/base.html.twig index 3d4a651..fca6a0f 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -5,13 +5,12 @@
src/Controller/HomeController.phptemplates/home/index.html.twigici
+
+ coucou
+InscriptionConnexion