Best Practice
Use 'elseif' instead of 'else if'
#CodingTips
As of PHP 5.4 you can also use the short array syntax, which replaces array() with []
#CodingTips
Functions in general shall be named using snake_case(say, my_function()), and using camelCase(say, myFunction()) when declared within a plugin class
#CodingTips
Variables in general shall be named using snake_case(say, $my_variable), and using camelCase(say, $myVariable) when declared within a plugin class
#CodingTips
Manage automatically assigning of new permissions whenever a module is enabled here- admin/config/people/accounts
#ConfigurationTips
Manage source of Main-menu and User-menu links here- admin/structure/menu/settings
#ConfigurationTips
Helper function(s) shall be named prefixing an underscore(say, _my_helper_function()), which can prevent hooks from being called
#CodingTips
Ideally, configuring of 'Private file system path' at admin/config/media/file-system should be located outside of your Drupal root folder(say, ../my_private_files)
#ConfigurationTips
You should be aware that uploading files as 'Private file' will slow down the process of loading the files as Drupal has to be bootstrapped for every file that needs to be downloaded
#ConfigurationTips #BeAware
Code should always be pushed up(dev -> staging -> production) and databases should only be pushed down(production -> staging -> dev)
#DevelopmentTips
Get Raw SQL Query of drupal dynamic queries before executing it using $query->__toString();
#DebugTips
In VI-Editor, Press ESC key to come in command mode and for undo type :U and for redo type :Ctrl+R
#LinuxTips
Insert queries must always use a query builder object(layer of abstraction), allowing individual database drivers special handling for column values (if applicable), example case for LOB and BLOB fields.
#DatabaseQueryTips
Drupal uses the .inc extension to prevent files from being executed directly.
#DevelopmentTips
VSCode
ReplyDeleteExtensions:
1 PHP Debug
2 PHP Intelephense
3 Empty Indent
4 Drupal 8 Snippets
5 Drupal 8 Javascript Snippets
6 Twig Language 2
7 Git Graph
8 Composer
VSCode Troubleshoot:
ReplyDeleteWhile using VSCode editor, the fan of my machine(Mac) runs continuously, and in Activity Monitor the CPU usage is also very high(200+).
Possible solution
This could be because of of heavy directory in your project.
So, if project's sites/default/files is heavy folder (say 2GB).
Then, add a pattern **/sites/default/files** to both search.exclude and watch.exclude in settings.
Also, go to Extensions and type @builtin- here you can disable unwanted extensions.
DeleteAlso, add pattern for **/sites/default/files** `intelephense.references.exclude` settings
Delete