File convention for PHP scripts added.
This commit is contained in:
parent
12e3b40235
commit
37b33453f3
|
@ -4,7 +4,7 @@
|
|||
<meta content="text/html; charset=UTF-8"
|
||||
http-equiv="content-type">
|
||||
<title>File Conventions</title>
|
||||
<meta content="$Author: maroy $" name="author">
|
||||
<meta content="$Author: tomas $" name="author">
|
||||
</head>
|
||||
<body>
|
||||
<h1>Preface</h1>
|
||||
|
@ -13,8 +13,8 @@ project, Copyright © 2004 <a href="http://www.mdlf.org/">Media
|
|||
Development Loan Fund</a>, under the GNU <a
|
||||
href="http://www.gnu.org/licenses/gpl.html">GPL</a>.<br>
|
||||
<ul>
|
||||
<li>Author: $Author: maroy $</li>
|
||||
<li>Version: $Revision: 1.2 $</li>
|
||||
<li>Author: $Author: tomas $</li>
|
||||
<li>Version: $Revision: 1.3 $</li>
|
||||
<li>Location: $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/doc/developmentEnvironment/fileConventions.html,v $</li>
|
||||
</ul>
|
||||
<h1>Scope</h1>
|
||||
|
@ -56,7 +56,7 @@ Following the GNU GPL <a
|
|||
applying a license term to source files, the typical header for a text
|
||||
file looks like the following:<br>
|
||||
<br>
|
||||
<pre><code> Copyright (c) 2004 Media Development Loan Fund<br> <br> This file is part of the LiveSupport project.<br> http://livesupport.campware.org/<br> To report bugs, send an e-mail to bugs@campware.org<br> <br> LiveSupport is free software; you can redistribute it and/or modify<br> it under the terms of the GNU General Public License as published by<br> the Free Software Foundation; either version 2 of the License, or<br> (at your option) any later version.<br> <br> LiveSupport is distributed in the hope that it will be useful,<br> but WITHOUT ANY WARRANTY; without even the implied warranty of<br> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br> GNU General Public License for more details.<br> <br> You should have received a copy of the GNU General Public License<br> along with LiveSupport; if not, write to the Free Software<br> Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA<br> <br> <br> Author : $Author: maroy $<br> Version : $Revision: 1.2 $<br> Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/doc/developmentEnvironment/fileConventions.html,v $<br></code><br></pre>
|
||||
<pre><code> Copyright (c) 2004 Media Development Loan Fund<br> <br> This file is part of the LiveSupport project.<br> http://livesupport.campware.org/<br> To report bugs, send an e-mail to bugs@campware.org<br> <br> LiveSupport is free software; you can redistribute it and/or modify<br> it under the terms of the GNU General Public License as published by<br> the Free Software Foundation; either version 2 of the License, or<br> (at your option) any later version.<br> <br> LiveSupport is distributed in the hope that it will be useful,<br> but WITHOUT ANY WARRANTY; without even the implied warranty of<br> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br> GNU General Public License for more details.<br> <br> You should have received a copy of the GNU General Public License<br> along with LiveSupport; if not, write to the Free Software<br> Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA<br> <br> <br> Author : $Author: tomas $<br> Version : $Revision: 1.3 $<br> Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/doc/developmentEnvironment/fileConventions.html,v $<br></code><br></pre>
|
||||
Note the CVS keywords (as an example) for having up-to-date information
|
||||
on the author, version and location of the file.<br>
|
||||
<h2>partitions</h2>
|
||||
|
@ -109,6 +109,10 @@ files.<br>
|
|||
<h3>C++ source files</h3>
|
||||
<a href="cxxSourceFileConventions.html">convention</a> and <a
|
||||
href="templates/Bar.cxx">template</a>.<br>
|
||||
<h2>PHP scripts</h2>
|
||||
<a href="phpFileConventions.html">convention</a> and <a
|
||||
href="templates/phpScriptTemplate.phps">template</a>
|
||||
(<a href="templates/phpScriptTemplate.php.txt">downlodable version</a>).<br>
|
||||
<br>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -0,0 +1,136 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta content="text/html; charset=UTF-8"
|
||||
http-equiv="content-type">
|
||||
<title>PHP file conventions</title>
|
||||
<meta content="$Author: tomas $" name="author">
|
||||
</head>
|
||||
<body>
|
||||
<h1>Preface</h1>
|
||||
This document is part of the <a href="http://livesupport.campware.org/">LiveSupport</a>
|
||||
project, Copyright © 2004 <a href="http://www.mdlf.org/">Media
|
||||
Development Loan Fund</a>, under the GNU <a
|
||||
href="http://www.gnu.org/licenses/gpl.html">GPL</a>.<br>
|
||||
<ul>
|
||||
<li>Author: $Author: tomas $</li>
|
||||
<li>Version: $Revision: 1.1 $</li>
|
||||
<li>Location: $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/doc/developmentEnvironment/phpFileConventions.html,v $</li>
|
||||
</ul>
|
||||
<h1>Scope</h1>
|
||||
This document describes the PHP script file conventions for the LiveSupport
|
||||
project. See also the generic description of the <a
|
||||
href="fileConventions.html">file conventions</a> in the LiveSupport
|
||||
project.<br>
|
||||
<h1>Introduction</h1>
|
||||
PHP scripts are text-based files containing PHP class definitions and/or commands.<br/>
|
||||
They should adhere to the <a
|
||||
href="http://pear.php.net/manual/en/standards.php">PEAR coding standards
|
||||
conventions</a>.<br>
|
||||
As text based files, they should adhere to the <a
|
||||
href="fileConventions.html#textConventions">generic text-based
|
||||
conventions</a>.<br>
|
||||
<h1>Naming</h1>
|
||||
A PHP script containing only class definition should have filename which reflects the class,
|
||||
it is implementing.
|
||||
Class names begin with a capital letter, followed by lower case letters.
|
||||
In case of a multiple word file name, the first letter of each word is
|
||||
capitalized.<br/>
|
||||
Other PHP scripts should have name starting with lowecase letter.<br/>
|
||||
PHP script files are named by the following rules:<br>
|
||||
<ul>
|
||||
<li>there are no spaces in the file name</li>
|
||||
<li>for file names containing multiple words, each additional word
|
||||
begins with a capital letter</li>
|
||||
<li>the extension of the file is <code>.php</code><br>
|
||||
</li>
|
||||
</ul>
|
||||
<h1>Structure</h1>
|
||||
PHP scripts are partitioned by using the following 80 column wide partitioning comments:<br/>
|
||||
<pre>
|
||||
/* ==================================================== name of the partition */
|
||||
</pre>
|
||||
and
|
||||
<pre>
|
||||
/* ------------------------------------------------- name of the subpartition */
|
||||
</pre>
|
||||
The file has the following mandatory structure:<br>
|
||||
<ul>
|
||||
<li>PHP starting tag <code><?php </code></li>
|
||||
<li>Header</li>
|
||||
<li>Defines ?</li>
|
||||
<li>Include files ?</li>
|
||||
<li>Code sections +</li>
|
||||
<li>PHP ending tag <code>?> </code></li>
|
||||
</ul>
|
||||
Because PHP is in-HTML embedable script language, it is possible to mix PHP and HTML code
|
||||
using PHP tags <code><?php</code> and <code>?></code>. This mixing approach is little bit
|
||||
obsolete and it is better to use pure PHP (with structure described above) and some template system to generate HTML.
|
||||
|
||||
|
||||
<h2>Header</h2>
|
||||
The header holds all information mandated by the <a
|
||||
href="fileConventions.html#header">generic guidelines</a>, but
|
||||
are enclosed in the PHP multiline comments <code>/* */</code>. Note the 80
|
||||
column wide partitioning delimiter enclosing the header.<br>
|
||||
<pre>
|
||||
/*------------------------------------------------------------------------------
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: tomas $
|
||||
Version : $Revision: 1.1 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/doc/developmentEnvironment/phpFileConventions.html,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
</pre>
|
||||
|
||||
<h2>Defines<br>
|
||||
</h2>
|
||||
This section contains all the constant defines, similar as:<br/>
|
||||
<br/>
|
||||
<code>define('CONSTAT_NAME', 10);</code><br/>
|
||||
<br/>
|
||||
|
||||
<h2>Include files<br>
|
||||
</h2>
|
||||
This section contains all the include files that the script needs
|
||||
to include.
|
||||
The include files are listed in
|
||||
a most generic to most specific order: first PEAR classes, then
|
||||
other LiveSupport module include files, and finally include files from
|
||||
the same module / product are listed.<br>
|
||||
Is much safer to use <code>include_once</code> or <code>require_once</code>, not the original versions
|
||||
of this statement.<br/>
|
||||
<br>
|
||||
|
||||
<h2>Code sections</h2>
|
||||
This sections contain class definitions, function definitions or runable PHP commands.<br/>
|
||||
|
||||
|
||||
<h1>Template</h1>
|
||||
See a generic <a href="templates/phpScriptTemplate.phps">template
|
||||
for PHP scripts</a>.
|
||||
You may freely <a href="templates/phpScriptTemplate.php.txt">download</a> and copy this
|
||||
template when starting to create a new script.<br>
|
||||
<br>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,98 @@
|
|||
<?php
|
||||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: tomas $
|
||||
Version : $Revision: 1.1 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/doc/developmentEnvironment/templates/phpScriptTemplate.php.txt,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
define('CONSTANT1', 10);
|
||||
define('CONSTANT2', 20);
|
||||
define('ERROR_CODE', 404);
|
||||
|
||||
require_once "DB.php";
|
||||
require_once "../../../othermodule/var/ClassName.php";
|
||||
require_once "LocalBaseClass.php";
|
||||
|
||||
/**
|
||||
* Example class
|
||||
*
|
||||
* Description of Example class
|
||||
*
|
||||
* @author $Author: tomas $
|
||||
* @version $Revision: 1.1 $
|
||||
* @see LocalBaseClass
|
||||
*/
|
||||
class Example extends LocalBaseClass{
|
||||
var $property1;
|
||||
var $property2;
|
||||
|
||||
/* ========================================================== constructor */
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param paramName parameter type, description
|
||||
* @return return type, description
|
||||
*/
|
||||
function Example($paramName)
|
||||
{
|
||||
parent::LocalBaseClass($paramName);
|
||||
/* commands here */
|
||||
}
|
||||
|
||||
/* ======================================================= public methods */
|
||||
/**
|
||||
* First Example method
|
||||
*
|
||||
* @param paramName parameter type, description
|
||||
* @return return type, description
|
||||
*/
|
||||
function firstExampleMethod($paramName)
|
||||
{
|
||||
/* commands here */
|
||||
return $variable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Second Example method
|
||||
*
|
||||
* @param paramName parameter type, description
|
||||
* @return return type, description
|
||||
*/
|
||||
function secondExampleMethod($paramName)
|
||||
{
|
||||
/* commands here */
|
||||
return $variable;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------- subsection */
|
||||
/* ---------------------------------------------------- redefined methods */
|
||||
|
||||
/* ==================================================== "private" methods */
|
||||
/* =============================================== test and debug methods */
|
||||
}
|
||||
|
||||
/* optional runable code here */
|
||||
?>
|
|
@ -0,0 +1,98 @@
|
|||
<?php
|
||||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: tomas $
|
||||
Version : $Revision: 1.1 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/doc/developmentEnvironment/templates/phpScriptTemplate.phps,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
define('CONSTANT1', 10);
|
||||
define('CONSTANT2', 20);
|
||||
define('ERROR_CODE', 404);
|
||||
|
||||
require_once "DB.php";
|
||||
require_once "../../../othermodule/var/ClassName.php";
|
||||
require_once "LocalBaseClass.php";
|
||||
|
||||
/**
|
||||
* Example class
|
||||
*
|
||||
* Description of Example class
|
||||
*
|
||||
* @author $Author: tomas $
|
||||
* @version $Revision: 1.1 $
|
||||
* @see LocalBaseClass
|
||||
*/
|
||||
class Example extends LocalBaseClass{
|
||||
var $property1;
|
||||
var $property2;
|
||||
|
||||
/* ========================================================== constructor */
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param paramName parameter type, description
|
||||
* @return return type, description
|
||||
*/
|
||||
function Example($paramName)
|
||||
{
|
||||
parent::LocalBaseClass($paramName);
|
||||
/* commands here */
|
||||
}
|
||||
|
||||
/* ======================================================= public methods */
|
||||
/**
|
||||
* First Example method
|
||||
*
|
||||
* @param paramName parameter type, description
|
||||
* @return return type, description
|
||||
*/
|
||||
function firstExampleMethod($paramName)
|
||||
{
|
||||
/* commands here */
|
||||
return $variable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Second Example method
|
||||
*
|
||||
* @param paramName parameter type, description
|
||||
* @return return type, description
|
||||
*/
|
||||
function secondExampleMethod($paramName)
|
||||
{
|
||||
/* commands here */
|
||||
return $variable;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------- subsection */
|
||||
/* ---------------------------------------------------- redefined methods */
|
||||
|
||||
/* ==================================================== "private" methods */
|
||||
/* =============================================== test and debug methods */
|
||||
}
|
||||
|
||||
/* optional runable code here */
|
||||
?>
|
Loading…
Reference in New Issue