All Projects → nalabdou → Symfony-code-snippets

nalabdou / Symfony-code-snippets

Licence: GPL-3.0 license
Over 100 Symfony Code Snippets for PhP code And Over 80 Twig Code Snippets. Just type the letters 'sf' to get a list of all available Symfony Code Snippets. For Twig Just Type the Tag name and you will get AutoCompletion.

Projects that are alternatives of or similar to Symfony-code-snippets

twig.vim
Twig syntax highlighting, indentation, neocomplete and UltiSnips snippets in Vim
Stars: ✭ 30 (+100%)
Mutual labels:  snippets, twig
vscode-react-javascript-snippets
Extension for React/Javascript snippets with search supporting ES7+ and babel features
Stars: ✭ 782 (+5113.33%)
Mutual labels:  snippets, vscode-snippets
stencil-snippets
An extension to add some snippets on vs code
Stars: ✭ 21 (+40%)
Mutual labels:  snippets, vscode-snippets
testcafe-snippets
Code snippets for TestCafe
Stars: ✭ 54 (+260%)
Mutual labels:  snippets, vscode-snippets
Assertion
The power of Respect\Validation into an assertion library.
Stars: ✭ 23 (+53.33%)
Mutual labels:  assert
Snippet2
A simple Code Snippet with user account and share feature
Stars: ✭ 20 (+33.33%)
Mutual labels:  snippets
DrupalTwigFood
Useful functions, filters for twig @ Drupal 8
Stars: ✭ 1 (-93.33%)
Mutual labels:  twig
data
NGXS Persistence API
Stars: ✭ 82 (+446.67%)
Mutual labels:  entity
EthereumSoliditySnippets
Set of useful snippet for efficiently using SublimeText and the Ethereum Solidity SmartContract programming language.
Stars: ✭ 27 (+80%)
Mutual labels:  snippets
competitive-programming-rs
Algorithm Snippets for Competitive Programming in Rust
Stars: ✭ 157 (+946.67%)
Mutual labels:  snippets
assert matches
Provides macro `assert_matches` for testing pattern matching
Stars: ✭ 51 (+240%)
Mutual labels:  assert
antd-snippets
Ant-Design Snippets for VS Code
Stars: ✭ 37 (+146.67%)
Mutual labels:  snippets
ethereum-scripts
Common useful JavaScript snippets for geth
Stars: ✭ 33 (+120%)
Mutual labels:  snippets
markdown-extra
Markdown extension for Twig
Stars: ✭ 83 (+453.33%)
Mutual labels:  twig
competitive-haskell
Snippets for competitive programming in Haskell
Stars: ✭ 23 (+53.33%)
Mutual labels:  snippets
craft-helper
A collection of useful Craft CMS macros and components.
Stars: ✭ 23 (+53.33%)
Mutual labels:  twig
VSC-React-Native-React-Redux-Snippets
Snippets for React and React-Native with a bit of Redux for es6/es7 user.
Stars: ✭ 56 (+273.33%)
Mutual labels:  snippets
ZenScript
Visual Studio Code extension/Language Server for ZenScript, includes highlight, code snippet and language server(WIP). Works with 👇
Stars: ✭ 29 (+93.33%)
Mutual labels:  snippets
IOTA101
IOTA Developer Essentials
Stars: ✭ 38 (+153.33%)
Mutual labels:  snippets
vscode-cql
CQL language support for VS Code.
Stars: ✭ 15 (+0%)
Mutual labels:  vscode-snippets

Symfony Code Snippets And Twig Support

Over 100 symfony snippets for php code And Over 50 twig snippets. Just type the letters 'sf' to get a list of all available symfony snippets. For twig just type the tag name and you will get AutoCompletion.

You can use it in the annotations comments

Image-of-Snippets-comments

For annotations you need to add this code to your settings.json file

    "editor.quickSuggestions": {
        "other": true,
        "comments": true,
        "strings": true
    }

You can use it in the .php files

Image-of-Snippets-php-code

You can use it in .twig files

Image-of-Snippets-twig

You can use it in .yaml files

Image-of-Snippets-yaml

Snippets Symfony

Trigger Description
sfFun you can use this snippet to genarate public function statment just like that
sfControllerFunction use this snippets to generate function in the controller with Route,RouteName,FunctionName,Template for rendering in twig.
sfFormGen use this snippet to generate $form variable into the controller function change the formtype and the entity.
sfHandleRequest use this snippet to Generate handleRequest Function change the RequestVar with your requestvar name.
sfRemove use this snippet to remove or delete data from the database do not forgot to inject the class entitymanagerenterface in the function parametters
sfRedirectToRoute use this snippet to generate return to redirecttoroute name change the routeName with Your RouteName.
sfRedirect use this snippet to return the redirection to url
sfUserHash use this function to generate function for hashing the users password don not forgot to setup the file security.yaml.
sfTwigForm use this function to send the $form var to the frontend using twig.
sfLogout use this snippet to generate logout function withe symfony you just need to setup the file security.yaml.
sfAddFlash use this snippet to generate flash message you need to setup the display code in the file base.html.twig.
sfTwigVar use this snippet to send the vars to twig via the function render.
sfRender use this snippet to generate render function to send the view into twig.
sfGetUser use this snippet to get the current conected user.
sfDump use this snippet to generate the dump function in symfony.
sfJson use this snippet to generate return json in symfony controller.
sfFindAll use this snippet to generate the function findAll from one repository you need to inject the repo you want in the function parameters.
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.
sfFindOne use this snippet to generate the function findOne you need to inject the repo in this function parameters.
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.
sfManager use this snippet to generate the var $manager to reacte with the database.
sfRepo use this snippet to generate the $repo var ex $repo = $this->getDoctrine()->getRepository(Product::class);.
sfPersist use this snippet to generate $manager persist.
sfGetSalt use this snippet to generate the function getSalt for the user entity when you implaments the UserInterFace.
sfGetUsername use this snippet to generate the function getUsername for the user entity when you implaments the UserInterFace.
sfEraseCredentials use this snippet to generate the function eraseCredentials for the user entity when you implaments the UserInterFace.
sfQueryBuilder use this snippt to create querybuilder in the repos to get data from the database.
sfEqualTo use this snippet to generate the assert equalto in the symfony Annotations.
sfLength use this snippet to generate the assert Length in the symfony Annotations.
sfNotBlank use this snippet to generate the assert NotBlank in the symfony Annotations.
sfNotNull use this snippet to generate the assert NotNull in the symfony Annotations.
sfBlank use this snippet to generate the assert Blank in the symfony Annotations.
sfIsNull use this snippet to generate the assert IsNull in the symfony Annotations.
sfTrue use this snippet to generate the assert IsTrue in the symfony Annotations.
sfFalse use this snippet to generate the assert IsFalse in the symfony Annotations.
sfType use this snippet to generate the assert Type in the symfony Annotations.
sfRegex use this snippet to generate the assert Regex in the symfony Annotations.
sfIp use this snippet to generate the assert Ip in the symfony Annotations.
sfAJson use this snippet to generate the assert Json in the symfony Annotations.
sfUuid use this snippet to generate the assert Uuid in the symfony Annotations.
sfUserPassword use this snippet to generate the SecurityAssert UserPassword in the symfony Annotations.
sfEmail use this snippet to generate the assert Email in the symfony Annotations.
sfUrl use this snippet to generate the assert Url in the symfony Annotations.
sfNotEqualTo use this snippet to generate the assert notEqualto in the symfony Annotations.
sfIdenticalTo use this snippet to generate the assert IdenticalTo in the symfony Annotations.
sfNotIdenticalTo use this snippet to generate the assert NotIdenticalTo in the symfony Annotations.
sfGreaterThan use this snippet to generate the assert GreaterThan in the symfony Annotations.
sfGreaterThanOrEqual use this snippet to generate the assert GreaterThanOrEqual in the symfony Annotations.
sfLessThan use this snippet to generate the assert LessThan in the symfony Annotations.
sfLessThanOrEqual use this snippet to generate the assert LessThanOrEqual in the symfony Annotations.
sfRange use this snippet to generate the assert Range in the symfony Annotations.
sfDivisibleBy use this snippet to generate the assert DivisibleBy in the symfony Annotations.
sfUnique use this snippet to generate the assert Unique in the symfony Annotations.
sfPositive use this snippet to generate the assert Positive in the symfony Annotations.
sfPositiveOrZero use this snippet to generate the assert PositiveOrZero in the symfony Annotations.
sfNegative use this snippet to generate the assert Negative in the symfony Annotations.
sfNegativeOrZero use this snippet to generate the assert NegativeOrZero in the symfony Annotations.
sfDate use this snippet to generate the assert Date in the symfony Annotations.
sfDateTime use this snippet to generate the assert DateTime in the symfony Annotations.
sfTime use this snippet to generate the assert Time in the symfony Annotations.
sfTimezone use this snippet to generate the assert Timezone in the symfony Annotations.
sfLanguage use this snippet to generate the assert Language in the symfony Annotations.
sfLocale use this snippet to generate the assert Locale in the symfony Annotations.
sfCountry use this snippet to generate the assert Country in the symfony Annotations.
sfUniqueEntity use this snippent to generate uniqueEntity to make sure that the fields are uniques.
sfhasLife use this snippet to generate the Annotation @ORM\HasLifecycleCallbacks() in symfony entity.
sfPre use this snippet to generate the * @ORM\PrePersist * @ORM\PreUpdate .
sfRoute use this snippet to get the @Route of symfony
sfVichUploadable use this snippets to gereate the Annotation for Vich Uploader Bundle @Vich\Uploadable
sfVichField use this snippets to gereate the Annotation for Vich Uploader Bundle @Vich\UploadableField(...)

Twig

Add these lines to your VS Code settings to get emmet working and also to associate HTML files as twig syntax.

"files.associations": {
    "*.html": "twig"
},
"emmet.includeLanguages": {
    "twig": "html"
},

Symfony Twig Snippets

Trigger Twig Code Type
asset {{ asset('') }} Symfony
formStart {{ form_start(form) }} Symfony
formWidget {{ form_widget(form) }} Symfony
formEnd {{ form_end(form) }} Symfony
path {{ path(route) }} Symfony
render {{ render(uri, {options}) }} Symfony
controller {{ controller(controller, {attributes}, {query}) }} Symfony
csrf {{ csrf_token(intention) }} Symfony
isGranted {% if is_granted('ROLE_NAME',object,field) %} {% endif %} Symfony
url {{ url(route_name,{options}) }} Symfony
formErrors {{ form_errors(form) }} Symfony
formRow {{ form_row(form.name) }} Symfony
formRest {{ form_rest(form) }} Symfony
formTheme {% form_theme form resourcesPath %} Symfony
absolute_url {{ absolute_url(${path}) }} Symfony
relative_path {{ relative_path(${path}) }} Symfony
humanize humanize Symfony
yaml_encode yaml_encode() Symfony
yaml_dump yaml_dump() Symfony
abbr_class abbr_class Symfony
abbr_method abbr_method Symfony
format_args format_args Symfony
format_args_as_text format_args_as_text Symfony
encoreJs {{ encore_entry_scropt_tags('app') }} Symfony
encoreCss {{ encore_entry_link_tags('app') }} Symfony

Syntaxes Twig

Trigger Twig Code Type
attribute {{ attribute() }} Function
autoescape {% autoescape %}{% endautoescape %} Tag
block {% block name %}{% endblock %} Tag
batch batch(size, fill) Filter
constant {{ constant('constName') }} Test
convert_encoding convert_encoding('to', 'from') Filter
cycle {{ cycle(array, position) }} Filter
date date("m/d/Y") Filter
datef {% set currentDate = date() %} Function
date_modify date_modify("+1 day") Function
default default('defaultValue') Function
defined is defined Test
dump <pre>{{ dump(array) }}</pre> Function
do {% do someOp %} Tag
else {% else %} Tag
else if {% elseif condition %} Tag
embed {% embed "fileName.html.twig" %}{% endembed %} Tag
execute {% %} NULL
extends {% extends "fileName.html.twig" %} Tag
filter {% filter filterName %}{% endfilter %} Tag
flush {% flush %} Tag
for {% for row in array %}{% endfor %} Tag
for else {% for row in array %}{% else %}{% endfor %} Tag
for if else {% for row in array if condition %}{% else %}{% endfor %} Tag
format format() Filter
formTwig {{form_start(form)}}{{form_widget(form)}}{{form_end(form)}} Function
if {% if condition %}{% endif %} Tag
if else {% if condition %}{% else %}{% endif %} Tag
import {% import "fileName.html.twig" as alias %} Tag
include {% include "fileName.html.twig" %} Tag
join join('separator') Filter
json_encode json_encode() Filter
loop loop. Filter With AutoComplation
macro {% macro name() %}{% endmacro %} Tag
max {% set result = max(array) %} Filter
merge merge(array) Filter
min {% set result = min(array) %} Filter
number_format number_format(1, '${.}', '${,}') Filter
parent {{ parent() }} Function
random {% set result = random() %} Function
range range(low, high, step) Function
range set {% set result = range(low, high, step) %} Function
replace replace('search' : 'replace') Filter
round round(, 'floor') Filter
sandbox {% sandbox %}{% endsandbox %} Tag
set {% set varName = value %} Tag
show {{ }} Null
slice slice(start, length) Filter
source {{ source('fileName.html.twig') }} Tag
spaceless {% spaceless %}{% endspaceless %} Tag
split split('') Filter
self _self Null
template {{ include(template_from_string("strings")) }} Function
trim trim('') Filter
use {% use "fileName.html.twig" %} Tag
verbatim {% verbatim %}{% endverbatim %} Tag

Yaml Snippets

Trigger Description
sfBootstrap yaml snippet to add the bootstrap theme to our form display form_themes
sfEncoder snippet to generate encoder password in yaml file
sfNewProvider new provider for your user
sfProvider symfony main fierwall for add the provider and login logout path
sfMappingsVich yaml snippet to add vich uploader configration
sfRoute symfony yaml new Route

🤝 Contributing

see contributors

Contributions, issues and feature requests are welcome !
Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you !

Buy Me A Coffee

📝 License

Copyright © 2020 Nadim Al Abdou.
This project is GPL3 licensed.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].