Joomla! Day Chicago 2011 Presentation - Steven Pignataro

1,125 views

Published on

Joomla! Day Chicago Development, Tips and Tricks presented by Steven Pignataro

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,125
On SlideShare
0
From Embeds
0
Number of Embeds
181
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Joomla! Day Chicago 2011 Presentation - Steven Pignataro

  1. 1. Joomla Development<br />Steven Pignataro – CEO/Partner ‘corePHP’<br />
  2. 2. Intro<br />
  3. 3. Quick Questions first<br /><ul><li>How many here work as a team developing projects?
  4. 4. How many have used SVN or GIT?
  5. 5. How many of you are developers?
  6. 6. How many of you are experts?
  7. 7. How many of you would like to make more money by working faster?</li></li></ul><li>Coding Standards<br /><ul><li>What is a coding standards?
  8. 8. Have higher quality / improved standards of released products / web sites
  9. 9. Easier to maintain from developer to developer</li></li></ul><li>Naming Conventions<br /><ul><li>Classes:
  10. 10. Classes should be given descriptive names. Avoid using abbreviations where possible.
  11. 11. Separate each word with underscore.
  12. 12. We use underscores instead of Camel Case (like Joomla!)
  13. 13. Private Class members are preceded with _
  14. 14. Example: _init_tree()</li></li></ul><li>Function Definitions <br /><ul><li>This example is based on the K&R style</li></li></ul><li>Descriptions<br /><ul><li>Descriptions are important as it helps other developers determine what is going on in the code itself</li></li></ul><li>Coding Standards Example<br />
  15. 15. Coding Standards Tricks<br /><ul><li>Make sure all coding is done with Maximum Error Reporting or E_STRICT
  16. 16. Make sure all your developers use the same patterns and have there IDE or favorite text editor setup properly to interpret the code.
  17. 17. Some example references:
  18. 18. http://pear.php.net/manual/en/standards.php
  19. 19. http://area51.phpbb.com/docs/30x/coding-guidelines.html
  20. 20. http://docs.joomla.org/Coding_style_and_standards</li></li></ul><li>SVN vs GIT<br /><ul><li>Speed
  21. 21. Handling of the repository
  22. 22. Size of repositories
  23. 23. Maturity of the repository
  24. 24. Ability to move to different versions</li></li></ul><li>Why use SVN or GIT?<br /><ul><li>Ability to work with code with a team of developers
  25. 25. Copy of revision code
  26. 26. Apply immediate backups to a last known working revision
  27. 27. See who performed the update
  28. 28. Version control allows you to bring your new member up to speed with branches for testing instead of using actual live code to test.</li></li></ul><li>Which is betters?<br /><ul><li>GIT of course!
  29. 29. You can use GIT off the grid – instead of being connected to the network
  30. 30. GIT is fast and leaner then other systems
  31. 31. Easy to use</li></li></ul><li>References<br /><ul><li>http://svnbook.red-bean.com/
  32. 32. http://book.git-scm.com/</li></li></ul><li>Code Review<br /><ul><li>Peer Code Review
  33. 33. Software based code review
  34. 34. Blame
  35. 35. Comments
  36. 36. Diff Tools</li></li></ul><li>Team Development Software<br /><ul><li>Beanstalk App
  37. 37. Cornerstone (mac)
  38. 38. Eclipse / Zend Studio
  39. 39. Assembla</li></li></ul><li>Development Tricks<br /><ul><li>The following are tips and tricks of developing that will enhance and make Joomla! development more focused.</li></li></ul><li>Don’t use die for debug<br /><ul><li>$mainframe->close();
  40. 40. Because of how PHP5 handles code database connection errors can occur similar to the following if using a die();
  41. 41. Warning: mysqli_query() [<a href='function.mysqli-query'>function.mysqli-query</a>]: Couldn't fetch mysqli in /home/corephptest/public_html/libraries/joomla/database/database/mysqli.php on line 147</li></li></ul><li>Use the Joomla! framework elsewhere<br /><ul><li>With Joomla! you can extract the framework and use inside of applications out side of the CMS
  42. 42. Example would be http://www.corephp.com/members
  43. 43. This is a complete system that pulls in Joomla! modules / data into a 3rd party system WHMCS natively.</li></li></ul><li>How do you?<br />/* Initialize Joomla framework */ define( '_JEXEC', 1 ); define( 'JPATH_BASE', dirname( __FILE__ ) ); define( 'DS', DIRECTORY_SEPARATOR ); /* Required Files */ require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' ); require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' ); /* To use Joomla's Database Class */ require_once ( JPATH_BASE .DS.'libraries'.DS.'joomla'.DS.'factory.php' ); /* Create the Application */ $mainframe = JFactory::getApplication( 'site’ );// Your code starts here...<br />
  44. 44. Move a site with ease<br /><ul><li>Akeeba Backup
  45. 45. Configure to use FTP for backup
  46. 46. Will backup to the new server that all the data was backed up to
  47. 47. Execute installation on new server.</li></li></ul><li>Quick Debugging<br /><ul><li>Here is a nifty example of doing quick debug – lets assume we have a lot of logic in our debug output:/* */print_r($var);// Other logic printing// Other debug code here// Blah blah blah/* */
  48. 48. Note how /* */ starts at the top and bottom
  49. 49. Add a space to the first one /* * / and the code is now commented out. Uncomment to have execute.</li></li></ul><li>Quick Debugging<br /><ul><li>Are you having an issue with trying to find where the code is located that is causing the issue?
  50. 50. Load the following code at the bottom of your index.php (last line)
  51. 51. debug_print_backtrace();</li></li></ul><li>Single or Double Quote<br /><ul><li>In PHP there is a difference when using either single or double quotes, either ‘ or “. If you use double quotes ” then you are telling the code to check for a variable. If you are using single quotes ‘ then you are telling it to print whatever is between them. This might seem a bit trivial, but if you use the double quotes instead of the single quotes, it will still output correctly, but you will be wasting processer time.</li></li></ul><li>Test for SQL Injections<br /><ul><li>Test your code. SQL injections are common in many applications and you can prevent it by testing. Here is a great cheat sheet:
  52. 52. http://ferruh.mavituna.com/sql-injection-cheatsheet-oku/#AboutMySQLandPHP</li></li></ul><li>Remove MooTools<br /><ul><li>Remove mootools and any unnecessary scripts loading to the page.
  53. 53. $user =& JFactory::getUser();if ( $user->get( 'guest' ) == 1 ) { $document =& JFactory::getDocument(); $headerstuff = $document->getHeadData();reset($headerstuff['scripts']);foreach ($headerstuff['scripts'] as $key=>$value){ if (substr_count($key, 'mootools') > 0)unset($headerstuff['scripts'][$key]); } $document->setHeadData( $headerstuff );}</li></li></ul><li>Speeding up your sites<br /><ul><li>Using CDN support on your site will increase the speed of the site.
  54. 54. Using products like jomCDN or other CDN solutions will help decrease the speed of your site and increase your score.
  55. 55. Why?
  56. 56. Assets are loaded from servers that are close to you and not directly from the server the data is being served from.</li></li></ul><li>Share and work together<br />Share development concepts that work<br />Got a great idea for Joomla! – lets us know and help improve the platform and CMS<br />
  57. 57. Questions?<br />
  58. 58. THE END<br />There is no end when the beginning is so near!<br />

×