Skip to content

RedSHOP for Joomla 2.5 guidelines

florianv edited this page Sep 20, 2012 · 2 revisions

Some things that we need to do in order to have the code better.

  • Remove closing tags ?> in all files. PHP doesn't need it and what is after the closing tag is ignored by the PHP parser. So if there is any space or white line, a Http Response will be sent.

  • All constructors must be renamed __construct(). We need to move away from the PHP4 style, since Joomla 2.5 is only PHP5.2+ compatible.

  • Use foreach instead of for when you don't have to know the array size. Foreach is faster than For.

  • Useless references should be removed, $db = &JFactory::getDBO() => $db = JFactory::getDBO().

  • All classes must begin with an upper case letter and be camelcased : 'ProductHelper', 'CategoryViewCategory'.

  • All methods must begin with a lower case letter and be camelcased : 'getProduct', 'setValue'. No underscore allowed.

They must have a little DocComment explaining what is done in that method :

See in Joomla how the comments are clean : https://github.com/joomla/joomla-platform/blob/staging/libraries/joomla/database/driver.php

  • All classes properties or methods must mention their visibility (public, protected or private).
  • function test() {} must become : public function test().
  • var $var must become : public $var
  • GLOBAL vars are strongly discouraged. $mainframe = JFactory::getApplication();

  • We need to drop the '_' prefix on class properties and methods. Joomla is moving away from that too.

  • For portability use the new Joomla Database API :

http://www.theartofjoomla.com/home/9-developer/135-database-upgrades-in-joomla-16.html

  • Use JInput instead of JRequest. JRequest will be removed in future versions :

http://docs.joomla.org/Retrieving_request_data_using_JInput

  • Be aware of the backward compatibility issue :

http://docs.joomla.org/Potential_backward_compatibility_issues_in_Joomla_2.5_and_Joomla_Platform_11.4

http://docs.joomla.org/Potential_backward_compatibility_issues_in_Joomla_3.0_and_Joomla_Platform_12.1

Clone this wiki locally