Naming Conventions and Coding Guidelines

The Amfphp codebase was written bearing in mind that namespaces are useful to eliminate ambiguity, but that they are too recent to be used as a lot of shared hosting doesn’t use PHP 5.3 yet. So namespaces are emulated. For example the Constants class that would be in the Amfphp/Core/Amf namespace is contained in the Amfphp/Core/Amf folder, the class is called Amfphp_Core_Amf_Constants, and the file is called Constants.php. Folders and classes are camel-cased, and start with a capital letter.

This convention applies everywhere except in the plugins folder. Third party plugins can be installed there, so the idea is to have <author><plugin description> as the name for the plugin folder and the class that is contained. So for example for the authentication plugin that is proposed by Amfphp, the folder is called AmfphpAuthentication, the class is contained in AmfphpAuthentication.php, and the class is called AmfphpAuthentication.

Filter names are defined by constants in the class where they are implemented, and an explanation of its use can be found there. The convention for naming the method called by the filter is to call it the same as the value of the filter constant. So for example the filter allowing a plugin to filter the serializer is defined with the following line of code:

const FILTER_SERIALIZER = "filterSerializer";

You should use « filterSerializer » as the name of the function.

The normal guidelines concerning the order of declarations in your class apply. This means first member variables, then the constructor, then the methods.

Please use phpdoc style comments to help other developers understand your plugin.

Laissez un commentaire

Événements à venir / Upcoming Events

  1. Apéro de mars: Silex Labs #apéropensource #37

    30 mars @ 19:00 - 23:00
  2. Node (plus haut) dans les nuages

    5 avril @ 19:00 - 21:00

News letter

Evénements Silex Labs sur Paris et sa région: Inscrivez vous à la Newsletter mensuelle

Silex Labs community Tweets

Facebook page

Abonnez-vous aux news via Email

Rejoignez 41 autres abonnés