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
Drupal site performance
ReplyDelete1. use anonymous user caching
2. use external caching varnish memcahce apc
3. disable database logging
4. enable sys log
5. indexing on searching
6. do not use * in sql select query instead use only those field which require
7. do not use count(*) in count query instead use count(anyfield)
8. disable unwanted modules
9. update contributed and core modules
10. use devel module for query analysis
11. use xprof module for php profiling
12. uses fast_404 module so that 404 does not use drupal bootstrape
13. set slow query log and set long query time
14. innodb_lock_wait_timeout set to some seconds
15. innodb_deadlock_detect enable for less traffic disable for high traffic
16. keep fewer http request in every page
17. aggregate css and js file
18. compress css and js file
19. serve static content from cdn
20. use css sprite for small images combine into one or serve it from glyphyicon
21. use lazyload of images on image websites
22. restric file upload size and type of file can be uploaded
23. use gzip compression of static content from htacess
24. Remove multiple redirection of page
25. use pasc module performance and scalability checklist
26. use security review module
27. avoid using drupal views if used then do views query alter remove left join if not needed
28. remove broken link by checking from brokenlinkcheck.combine
29. use form api to protect ur site from CSRF attack
30. use far feature expiry date for static content
31. use drupal_get_token and and drupal_valid_token preventing from the csrf attack
32. sanatize input by using filter_xss preventing from cross site scripting
33. give full html permission of editor to trusted users only
34. use master slave database read from slave write from master
35. use path auto module for the url alias use ful for the seo
36. use global redirect module so that every url having url like node/1 should rediect to alias only. Good for seo no multiple page for google
37. to crawl
38. use db_query instead of db_select because db_select is costly query as it goes throguh hook_query_alter
39. put all js on footer only
40. defer or make async to all external js
41. we can use load balanacer as per budget of client
42. use xmlsite map and submit it to google for seo
43. create sitemap of our website links
44. use unique h1 tag on the page with the title of the page good for seo