|
1 | 1 | # Symfony Code Snippets And Twig Support
|
2 | 2 |
|
3 | 3 | Over 50 Symfony Code Snippets for PhP code And Over 50 Twig Code Snippets.
|
4 |
| -Just type the letters 'sy' to get a list of all available Symfony Code Snippets. |
| 4 | +Just type the letters 'sf' to get a list of all available Symfony Code Snippets. |
5 | 5 | For Twig Just Type the Tag name and you will get AutoCompletion.
|
6 | 6 |
|
7 | 7 | ## For using the snippets in the Annotations Comments you need to add this Code To Your Settings.json File
|
@@ -34,76 +34,76 @@ For Twig Just Type the Tag name and you will get AutoCompletion.
|
34 | 34 |
|
35 | 35 | Trigger | Description
|
36 | 36 | --- | ---
|
37 |
| -syFun | you can use this snippet to genarate public function statment just like that |
38 |
| -syControllerFunction | use this snippets to generate function in the controller with Route,RouteName,FunctionName,Template for rendering in twig. |
39 |
| -syFormGen | use this snippet to generate $form variable into the controller function change the formtype and the entity. |
40 |
| -syHandleRequest | use this snippet to Generate handleRequest Function change the RequestVar with your requestvar name. |
41 |
| -syRemove | use this snippet to remove or delete data from the database do not forgot to inject the class entitymanagerenterface in the function parametters |
42 |
| -syRedirectToRoute | use this snippet to generate return to redirecttoroute name change the routeName with Your RouteName. |
43 |
| -syRedirect | use this snippet to return the redirection to url |
44 |
| -syUserHash | use this function to generate function for hashing the users password don not forgot to setup the file security.yaml. |
45 |
| -syTwigForm | use this function to send the $form var to the frontend using twig. |
46 |
| -syLogout | use this snippet to generate logout function withe symfony you just need to setup the file security.yaml. |
47 |
| -syAddFlash | use this snippet to generate flash message you need to setup the display code in the file base.html.twig. |
48 |
| -syTwigVar | use this snippet to send the vars to twig via the function render. |
49 |
| -syRender | use this snippet to generate render function to send the view into twig. |
50 |
| -syGetUser | use this snippet to get the current conected user. |
51 |
| -syDump | use this snippet to generate the dump function in symfony. |
52 |
| -syJson | use this snippet to generate return json in symfony controller. |
53 |
| -syFindAll | use this snippet to generate the function findAll from one repository you need to inject the repo you want in the function parameters. |
54 |
| -syFindOneBy | use this snippet to generate the function findOneBy to get one value from repo do not forgot to inject the repository in this function parameters. |
55 |
| -syFindOne | use this snippet to generate the function findOne you need to inject the repo in this function parameters. |
56 |
| -syFindBy | use this function to generate the function findBy from one repo do not forgot to incject the repo you want in this function parameters. |
57 |
| -syManager | use this snippet to generate the var $manager to reacte with the database. |
58 |
| -syRepo | use this snippet to generate the $repo var ex $repo = $this->getDoctrine()->getRepository(Product::class);. |
59 |
| -syPersist | use this snippet to generate $manager persist. |
60 |
| -syGetSalt | use this snippet to generate the function getSalt for the user entity when you implaments the UserInterFace. |
61 |
| -syGetUsername | use this snippet to generate the function getUsername for the user entity when you implaments the UserInterFace. |
62 |
| -syEraseCredentials | use this snippet to generate the function eraseCredentials for the user entity when you implaments the UserInterFace. |
63 |
| -syQueryBuilder | use this snippt to create querybuilder in the repos to get data from the database. |
64 |
| -syEqualTo | use this snippet to generate the assert equalto in the symfony Annotations. |
65 |
| -syLength | use this snippet to generate the assert Length in the symfony Annotations. |
66 |
| -syNotBlank | use this snippet to generate the assert NotBlank in the symfony Annotations. |
67 |
| -syNotNull | use this snippet to generate the assert NotNull in the symfony Annotations. |
68 |
| -syBlank | use this snippet to generate the assert Blank in the symfony Annotations. |
69 |
| -syIsNull | use this snippet to generate the assert IsNull in the symfony Annotations. |
70 |
| -syTrue | use this snippet to generate the assert IsTrue in the symfony Annotations. |
71 |
| -syFalse | use this snippet to generate the assert IsFalse in the symfony Annotations. |
72 |
| -syType | use this snippet to generate the assert Type in the symfony Annotations. |
73 |
| -syRegex | use this snippet to generate the assert Regex in the symfony Annotations. |
74 |
| -syIp | use this snippet to generate the assert Ip in the symfony Annotations. |
75 |
| -syAJson | use this snippet to generate the assert Json in the symfony Annotations. |
76 |
| -syUuid | use this snippet to generate the assert Uuid in the symfony Annotations. |
77 |
| -syUserPassword | use this snippet to generate the SecurityAssert UserPassword in the symfony Annotations. |
78 |
| -syEmail | use this snippet to generate the assert Email in the symfony Annotations. |
79 |
| -syUrl | use this snippet to generate the assert Url in the symfony Annotations. |
80 |
| -syNotEqualTo | use this snippet to generate the assert notEqualto in the symfony Annotations. |
81 |
| -syIdenticalTo | use this snippet to generate the assert IdenticalTo in the symfony Annotations. |
82 |
| -syNotIdenticalTo | use this snippet to generate the assert NotIdenticalTo in the symfony Annotations. |
83 |
| -syGreaterThan | use this snippet to generate the assert GreaterThan in the symfony Annotations. |
84 |
| -syGreaterThanOrEqual | use this snippet to generate the assert GreaterThanOrEqual in the symfony Annotations. |
85 |
| -syLessThan | use this snippet to generate the assert LessThan in the symfony Annotations. |
86 |
| -syLessThanOrEqual | use this snippet to generate the assert LessThanOrEqual in the symfony Annotations. |
87 |
| -syRange | use this snippet to generate the assert Range in the symfony Annotations. |
88 |
| -syDivisibleBy | use this snippet to generate the assert DivisibleBy in the symfony Annotations. |
89 |
| -syUnique | use this snippet to generate the assert Unique in the symfony Annotations. |
90 |
| -syPositive | use this snippet to generate the assert Positive in the symfony Annotations. |
91 |
| -syPositiveOrZero | use this snippet to generate the assert PositiveOrZero in the symfony Annotations. |
92 |
| -syNegative | use this snippet to generate the assert Negative in the symfony Annotations. |
93 |
| -syNegativeOrZero | use this snippet to generate the assert NegativeOrZero in the symfony Annotations. |
94 |
| -syDate | use this snippet to generate the assert Date in the symfony Annotations. |
95 |
| -syDateTime | use this snippet to generate the assert DateTime in the symfony Annotations. |
96 |
| -syTime | use this snippet to generate the assert Time in the symfony Annotations. |
97 |
| -syTimezone | use this snippet to generate the assert Timezone in the symfony Annotations. |
98 |
| -syLanguage | use this snippet to generate the assert Language in the symfony Annotations. |
99 |
| -syLocale | use this snippet to generate the assert Locale in the symfony Annotations. |
100 |
| -syCountry | use this snippet to generate the assert Country in the symfony Annotations. |
101 |
| -syUniqueEntity | use this snippent to generate uniqueEntity to make sure that the fields are uniques. |
102 |
| -syhasLife | use this snippet to generate the Annotation @ORM\\HasLifecycleCallbacks() in symfony entity. |
103 |
| -syPre | use this snippet to generate the * @ORM\\PrePersist * @ORM\\PreUpdate . |
104 |
| -syRoute | use this snippet to get the @Route of symfony |
105 |
| -syVichUploadable | use this snippets to gereate the Annotation for Vich Uploader Bundle @Vich\Uploadable |
106 |
| -syVichField | use this snippets to gereate the Annotation for Vich Uploader Bundle @Vich\UploadableField(...) |
| 37 | +sfFun | you can use this snippet to genarate public function statment just like that |
| 38 | +sfControllerFunction | use this snippets to generate function in the controller with Route,RouteName,FunctionName,Template for rendering in twig. |
| 39 | +sfFormGen | use this snippet to generate $form variable into the controller function change the formtype and the entity. |
| 40 | +sfHandleRequest | use this snippet to Generate handleRequest Function change the RequestVar with your requestvar name. |
| 41 | +sfRemove | use this snippet to remove or delete data from the database do not forgot to inject the class entitymanagerenterface in the function parametters |
| 42 | +sfRedirectToRoute | use this snippet to generate return to redirecttoroute name change the routeName with Your RouteName. |
| 43 | +sfRedirect | use this snippet to return the redirection to url |
| 44 | +sfUserHash | use this function to generate function for hashing the users password don not forgot to setup the file security.yaml. |
| 45 | +sfTwigForm | use this function to send the $form var to the frontend using twig. |
| 46 | +sfLogout | use this snippet to generate logout function withe symfony you just need to setup the file security.yaml. |
| 47 | +sfAddFlash | use this snippet to generate flash message you need to setup the display code in the file base.html.twig. |
| 48 | +sfTwigVar | use this snippet to send the vars to twig via the function render. |
| 49 | +sfRender | use this snippet to generate render function to send the view into twig. |
| 50 | +sfGetUser | use this snippet to get the current conected user. |
| 51 | +sfDump | use this snippet to generate the dump function in symfony. |
| 52 | +sfJson | use this snippet to generate return json in symfony controller. |
| 53 | +sfFindAll | use this snippet to generate the function findAll from one repository you need to inject the repo you want in the function parameters. |
| 54 | +sfFindOneBy | use this snippet to generate the function findOneBy to get one value from repo do not forgot to inject the repository in this function parameters. |
| 55 | +sfFindOne | use this snippet to generate the function findOne you need to inject the repo in this function parameters. |
| 56 | +sfFindBy | use this function to generate the function findBy from one repo do not forgot to incject the repo you want in this function parameters. |
| 57 | +sfManager | use this snippet to generate the var $manager to reacte with the database. |
| 58 | +sfRepo | use this snippet to generate the $repo var ex $repo = $this->getDoctrine()->getRepository(Product::class);. |
| 59 | +sfPersist | use this snippet to generate $manager persist. |
| 60 | +sfGetSalt | use this snippet to generate the function getSalt for the user entity when you implaments the UserInterFace. |
| 61 | +sfGetUsername | use this snippet to generate the function getUsername for the user entity when you implaments the UserInterFace. |
| 62 | +sfEraseCredentials | use this snippet to generate the function eraseCredentials for the user entity when you implaments the UserInterFace. |
| 63 | +sfQueryBuilder | use this snippt to create querybuilder in the repos to get data from the database. |
| 64 | +sfEqualTo | use this snippet to generate the assert equalto in the symfony Annotations. |
| 65 | +sfLength | use this snippet to generate the assert Length in the symfony Annotations. |
| 66 | +sfNotBlank | use this snippet to generate the assert NotBlank in the symfony Annotations. |
| 67 | +sfNotNull | use this snippet to generate the assert NotNull in the symfony Annotations. |
| 68 | +sfBlank | use this snippet to generate the assert Blank in the symfony Annotations. |
| 69 | +sfIsNull | use this snippet to generate the assert IsNull in the symfony Annotations. |
| 70 | +sfTrue | use this snippet to generate the assert IsTrue in the symfony Annotations. |
| 71 | +sfFalse | use this snippet to generate the assert IsFalse in the symfony Annotations. |
| 72 | +sfType | use this snippet to generate the assert Type in the symfony Annotations. |
| 73 | +sfRegex | use this snippet to generate the assert Regex in the symfony Annotations. |
| 74 | +sfIp | use this snippet to generate the assert Ip in the symfony Annotations. |
| 75 | +sfAJson | use this snippet to generate the assert Json in the symfony Annotations. |
| 76 | +sfUuid | use this snippet to generate the assert Uuid in the symfony Annotations. |
| 77 | +sfUserPassword | use this snippet to generate the SecurityAssert UserPassword in the symfony Annotations. |
| 78 | +sfEmail | use this snippet to generate the assert Email in the symfony Annotations. |
| 79 | +sfUrl | use this snippet to generate the assert Url in the symfony Annotations. |
| 80 | +sfNotEqualTo | use this snippet to generate the assert notEqualto in the symfony Annotations. |
| 81 | +sfIdenticalTo | use this snippet to generate the assert IdenticalTo in the symfony Annotations. |
| 82 | +sfNotIdenticalTo | use this snippet to generate the assert NotIdenticalTo in the symfony Annotations. |
| 83 | +sfGreaterThan | use this snippet to generate the assert GreaterThan in the symfony Annotations. |
| 84 | +sfGreaterThanOrEqual | use this snippet to generate the assert GreaterThanOrEqual in the symfony Annotations. |
| 85 | +sfLessThan | use this snippet to generate the assert LessThan in the symfony Annotations. |
| 86 | +sfLessThanOrEqual | use this snippet to generate the assert LessThanOrEqual in the symfony Annotations. |
| 87 | +sfRange | use this snippet to generate the assert Range in the symfony Annotations. |
| 88 | +sfDivisibleBy | use this snippet to generate the assert DivisibleBy in the symfony Annotations. |
| 89 | +sfUnique | use this snippet to generate the assert Unique in the symfony Annotations. |
| 90 | +sfPositive | use this snippet to generate the assert Positive in the symfony Annotations. |
| 91 | +sfPositiveOrZero | use this snippet to generate the assert PositiveOrZero in the symfony Annotations. |
| 92 | +sfNegative | use this snippet to generate the assert Negative in the symfony Annotations. |
| 93 | +sfNegativeOrZero | use this snippet to generate the assert NegativeOrZero in the symfony Annotations. |
| 94 | +sfDate | use this snippet to generate the assert Date in the symfony Annotations. |
| 95 | +sfDateTime | use this snippet to generate the assert DateTime in the symfony Annotations. |
| 96 | +sfTime | use this snippet to generate the assert Time in the symfony Annotations. |
| 97 | +sfTimezone | use this snippet to generate the assert Timezone in the symfony Annotations. |
| 98 | +sfLanguage | use this snippet to generate the assert Language in the symfony Annotations. |
| 99 | +sfLocale | use this snippet to generate the assert Locale in the symfony Annotations. |
| 100 | +sfCountry | use this snippet to generate the assert Country in the symfony Annotations. |
| 101 | +sfUniqueEntity | use this snippent to generate uniqueEntity to make sure that the fields are uniques. |
| 102 | +sfhasLife | use this snippet to generate the Annotation @ORM\\HasLifecycleCallbacks() in symfony entity. |
| 103 | +sfPre | use this snippet to generate the * @ORM\\PrePersist * @ORM\\PreUpdate . |
| 104 | +sfRoute | use this snippet to get the @Route of symfony |
| 105 | +sfVichUploadable | use this snippets to gereate the Annotation for Vich Uploader Bundle @Vich\Uploadable |
| 106 | +sfVichField | use this snippets to gereate the Annotation for Vich Uploader Bundle @Vich\UploadableField(...) |
107 | 107 |
|
108 | 108 | # Twig
|
109 | 109 | ## Add these lines to your VS Code settings to get emmet working and also to associate HTML files as twig syntax.
|
@@ -211,14 +211,14 @@ verbatim | `{% verbatim %}{% endverbatim %}` | Tag
|
211 | 211 |
|
212 | 212 | Trigger | Description
|
213 | 213 | --- | ---
|
214 |
| -syBootstrap | yaml snippet to add the bootstrap theme to our form display form_themes |
215 |
| -syEncoder | snippet to generate encoder password in yaml file |
216 |
| -syNewProvider | new provider for your user |
217 |
| -syProvider | symfony main fierwall for add the provider and login logout path |
218 |
| -syMappingsVich | yaml snippet to add vich uploader configration |
219 |
| -<hr> |
220 |
| -## Author |
221 |
| -<hr> |
| 214 | +sfBootstrap | yaml snippet to add the bootstrap theme to our form display form_themes |
| 215 | +sfEncoder | snippet to generate encoder password in yaml file |
| 216 | +sfNewProvider | new provider for your user |
| 217 | +sfProvider | symfony main fierwall for add the provider and login logout path |
| 218 | +sfMappingsVich | yaml snippet to add vich uploader configration |
| 219 | + |
| 220 | +## 🤝 Contributing |
| 221 | + |
222 | 222 | 👤 **Nadim Al Abdou**
|
223 | 223 |
|
224 | 224 | * Github: [@nalabdou](https://github.com/nalabdou)
|
|
0 commit comments