cvs: presentations /slides/sdphp README-sdphp_using_tools.txt tools_PEAR_Info.xml tools_mondoregex_bare-code.xml tools_mondoregex_deploying.xml
tools_mondoregex_desc.xml tools_mondoregex_example-apidocs.xml tools_mondoregex_example-uml.xml tools_mondoregex_package-desc.xml
tools_mondoregex_screenshot.xml tools_mondoregex_title.xml tools_mondoregex_with-doc-tags.xml tools_mondoregex_with-doctags.xml tools_more-info.xml
tools_pear-naming-conventions.xml tools_pearpackager_commands.xml tools_pearpackager_desc.xml tools_pearpackager_getting-help.xml
tools_pearpackager_gtk.xml tools_pearpackager_info.xml tools_pearpackager_listing.xml tools_pearpackager_managing-packages.xml
tools_pearpackager_web.xml tools_phpdocumentor_desc.xml tools_phpdocumentor_doctags.xml tools_phpdocumentor_example.xml tools_summary.xml
tools_title.xml tools_toc.xml
| From: | Jesus M. Castagnetto | Date: | Fri, 06 Jun 2003 05:20:22 +0000 |
| Subject: | cvs: presentations /slides/sdphp README-sdphp_using_tools.txt tools_PEAR_Info.xml tools_mondoregex_bare-code.xml tools_mondoregex_deploying.xml tools_mondoregex_desc.xml tools_mondoregex_example-apidocs.xml tools_mondoregex_example-uml.xml tools_mondoregex_package-desc.xml tools_mondoregex_screenshot.xml tools_mondoregex_title.xml tools_mondoregex_with-doc-tags.xml tools_mondoregex_with-doctags.xml tools_more-info.xml tools_pear-naming-conventions.xml tools_pearpackager_commands.xml tools_pearpackager_desc.xml tools_pearpackager_getting-help.xml tools_pearpackager_gtk.xml tools_pearpackager_info.xml tools_pearpackager_listing.xml tools_pearpackager_managing-packages.xml tools_pearpackager_web.xml tools_phpdocumentor_desc.xml tools_phpdocumentor_doctags.xml tools_phpdocumentor_example.xml tools_summary.xml tools_title.xml tools_toc.xml |
||
| Groups: | php.pres | ||
| Request: | Send a blank email to pres+get-736@lists.php.net to get a copy of this message | ||
jmcastagnetto Fri Jun 6 01:20:22 2003 EDT
Added files:
/presentations/slides/sdphp README-sdphp_using_tools.txt
tools_PEAR_Info.xml
tools_mondoregex_bare-code.xml
tools_mondoregex_deploying.xml
tools_mondoregex_desc.xml
tools_mondoregex_example-apidocs.xml
tools_mondoregex_example-uml.xml
tools_mondoregex_package-desc.xml
tools_mondoregex_screenshot.xml
tools_mondoregex_title.xml
tools_mondoregex_with-doc-tags.xml
tools_mondoregex_with-doctags.xml
tools_more-info.xml
tools_pear-naming-conventions.xml
tools_pearpackager_commands.xml
tools_pearpackager_desc.xml
tools_pearpackager_getting-help.xml
tools_pearpackager_gtk.xml
tools_pearpackager_info.xml
tools_pearpackager_listing.xml
tools_pearpackager_managing-packages.xml
tools_pearpackager_web.xml
tools_phpdocumentor_desc.xml
tools_phpdocumentor_doctags.xml
tools_phpdocumentor_example.xml
tools_summary.xml tools_title.xml
tools_toc.xml
Log:
New SDPHP talk on using tools for making coding/documentation/deployment
simpler: the pear installer, phpDocumentor, vim + some plugins, Dia +
Autodia + dia2code, Umbrello + xmi2code.
Index: presentations/slides/sdphp/README-sdphp_using_tools.txt +++ presentations/slides/sdphp/README-sdphp_using_tools.txt This is a talk to show the use of some tools to help in code development. I have put the sample code, as well as the UML diagrams and uml-generated code (from dia2code and xmi2code), in the directory: ./misc/sdphp_using_tools/ Have fun and hope they are useful to you too. -- Jesus M. Castagnetto Index: presentations/slides/sdphp/tools_PEAR_Info.xml +++ presentations/slides/sdphp/tools_PEAR_Info.xml <slide title="Davey's PEAR_Info"> <example type='php' fontsize='1.5em'><![CDATA[<?php require_once 'PEAR/Info.php'; $info = new PEAR_Info(); $info->show(); ?>]]></example> <image filename='images/pear_info.png' align='center'/> </slide> Index: presentations/slides/sdphp/tools_mondoregex_bare-code.xml +++ presentations/slides/sdphp/tools_mondoregex_bare-code.xml <slide title='MondoRegex (1)'> <blurb> We will first flesh out the methods described before, and add a private method that does the heavy lifting of matching. </blurb> <example role='php' fontsize='1.5em'><![CDATA[<?php class MondoRegex { var $_reList = array; var $_matchList = array(); function MondoRegex($reList = "") { if (!empty($reList) && is_array($reList)) $this->setRegexList($reList); } function setRegexList($reList) { if (is_array($reList)) $this->_reList = $reList; } function match($inputList) { return $this->_reMatch("preg_match", $inputList); } function matchAll($inputList) { return $this->_reMatch("preg_match_all", $inputList); } function getMatches() { return $this->_matchList; } function getMatchesFor($reName) { if (in_array($reName,array_keys($this->_matchList))) { return $this->_matchList[$reName]; } else { return false; } } function getMatchKeys() { if (empty($this->_matchList)) { return false; } else { return array_keys($this->_matchList); } } function _reMatch($reFunc, $inputList) { $this->matchList = array(); if (empty($this->_reList) || !array($inputList)) return false; foreach ($this->_reList as $reName=>$reStr) foreach ($inputList as $input) if ($reFunc($reStr, $input, &$hits)) if (!empty($hits)) $this->_matchList[$reName][] = $hits; return !empty($this->_matchList); } } ?>]]></example> </slide> Index: presentations/slides/sdphp/tools_mondoregex_deploying.xml +++ presentations/slides/sdphp/tools_mondoregex_deploying.xml <slide title='Deploying MondoRegex'> <example type='shell' title='Creating the tarball' fontsize='1.5em'><![CDATA[ $ pear package-validate Validation: 0 error(s), 0 warning(s) $ pear package Analyzing MondoRegex.php Package /path/to/my/devel/dir/MondoRegex-0.1.0.tgz done $ pear install MondoRegex-0.1.0.tgz install ok: MondoRegex 0.1.0 $ php -f test.php TESTING MondoRegex Using match ... $ cp MondoRegex-0.1.0.tgz /path/to/my/server/dir/packages/ ]]></example> <example type='shell' title='... later that day, somewhere on the net' fontsize='1.5em'><![CDATA[ $ pear install http://coolphpstuff.com/packages/MondoRegex-0.1.0.tgz downloading MondoRegex-0.1.0.tgz... ...done: 1,895 bytes install ok: MondoRegex 0.1.0 ]]></example> </slide> Index: presentations/slides/sdphp/tools_mondoregex_desc.xml +++ presentations/slides/sdphp/tools_mondoregex_desc.xml <slide title='Example class'> <blurb title='The plan'> Let's write a class and then create a package definition to distribute it. Our example class will be able to apply an array of regular expressions to an array of input strings. </blurb> <blurb> We will try and follow the PEAR naming conventions, to play nice with the other packages and make the users life simpler. </blurb> <blurb fontsize='3em' align='center' effect='hide'> Meet ... MondoRegex! </blurb> <example effect='hide'><![CDATA[<?php class MondoRegex { var $_reList = array; var $_matchList = array(); function MondoRegex($reList = "") {} function setRegexList($reList) {} function match($inputList) {} function matchAll($inputList) {} function getMatches() {} function getMatchesForKey($reName) {} function getMatchKeys() {} } ?>]]> </example> </slide> Index: presentations/slides/sdphp/tools_mondoregex_example-apidocs.xml +++ presentations/slides/sdphp/tools_mondoregex_example-apidocs.xml <slide title='MondoRegex - API docs'> <example type='shell' title='Running phpDocumentor'><![CDATA[ $ phpdoc -d /path/to/my/devel/dir \ -t /path/to/my/devel/dir/apidoc \ --pear -ti 'MondoRegex' \ -o 'HTML:frames:default,XML:DocBook/peardoc2:default']]> </example> <image filename='images/api_mondoregex.png' align='center'/> </slide> Index: presentations/slides/sdphp/tools_mondoregex_example-uml.xml +++ presentations/slides/sdphp/tools_mondoregex_example-uml.xml <slide title='MondoRegex - UML'> <blurb> There are more tools than the ones for editing the code, and for generating the documentation. We can also generate (... drum roll ...) UML diagrams! </blurb> <blurb> Of course, we could use our favorite diagram drawing program (e.g. *Dia*) and write an UML diagram, but we are *lazy*, so we use automatic ways of dealing with the problem. Enter *Autodia*. </blurb> <list title='Autodia: from code to UML'> <bullet>Is a tool that can analyze your code and generate a good (although a little messy at first) UML diagram of your classes.</bullet> <blurb>It understand Java, Perl, PHP, SQL, and others (soon Python too).</blurb> <blurb>It is written in Perl, but we will not hold that against it %;-)%, because the code is quite readable and well organized.</blurb> </list> <image title='Running Autodia on MondoRegex.php' filename='images/mondoregex_uml-raw.png' align='center'/> <image title='... and after some cleaning' filename='images/mondoregex_uml.png' align='center'/> <blurb title='dia2code: from UML to code'> You can also go the other way, if you have a nice UML diagram, you can generate PHP (or Java, or Perl, etc.) with dia2code. </blurb> <blurb title='Another alternative: Umbrello and xmi2code'> *Umbrello* is a specialized tool (unlike Dia), and supports the "standard" XMI format, and the companion project *xmi2code* can produce code from your UML description. </blurb> </slide> Index: presentations/slides/sdphp/tools_mondoregex_package-desc.xml +++ presentations/slides/sdphp/tools_mondoregex_package-desc.xml <slide title='Package description'> <example title='package.xml' fontsize='1em' examplebackground='#eeeeee'><![CDATA[<?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE package SYSTEM "../package.dtd"> <package> <name>MondoRegex</name> <summary>Class to apply a list of regular expressions</summary> <description> This class applies an array of named regular expressions to an array of input strings. </description> <maintainers> <maintainer> <user>jmcastagnetto</user> <name>Jesus M. Castagnetto</name> <email>jmcastagnetto@php.net</email> <role>lead</role> </maintainer> <maintainer> <user>snipe</user> <name>Alison Gianotto</name> <email>snipe@snipe.net</email> <role>developer</role> </maintainer> </maintainers> <release> <license>PHP</license> <version>0.1.0</version> <date>2003-06-05</date> <notes>Initial release</notes> <state>beta</state> <filelist> <dir name="/" baseinstalldir="SDPHP"> <file role="php">MondoRegex.php</file> </dir> </filelist> </release> <changelog> </changelog> </package>]]> </example> </slide> Index: presentations/slides/sdphp/tools_mondoregex_screenshot.xml +++ presentations/slides/sdphp/tools_mondoregex_screenshot.xml <slide title='MondoRegex (3)'> <image title='Editing the code' filename='images/editing_mondoregex.png' align='center'/> <blurb> Gvim with some plugins to show the code structure (based on ctags), as well as on-line documentation for *is_array()*. </blurb> </slide> Index: presentations/slides/sdphp/tools_mondoregex_title.xml +++ presentations/slides/sdphp/tools_mondoregex_title.xml <slide title="Putting it all together" fontsize='3.5em'> <blurb align='center' title='MondoRegex' fontsize='4em'/> </slide> Index: presentations/slides/sdphp/tools_mondoregex_with-doc-tags.xml +++ presentations/slides/sdphp/tools_mondoregex_with-doc-tags.xml <slide title='MondoRegex (3)'> <example title='Complete version' fontsize='1em'><![CDATA[<?php /** * Class to apply an array of regular expressions * to an array of items. Supports first match only * (as in preg_match) and matching all possibilities * (as in preg_match_all), as well as retrieval of * results from a named regular expression pattern. * * Example of use: * * <pre> * require_once 'SDPHP/MondoRegex.php'; * * $reList = array ( * 'funcs" => "/function (\w+)\s?\(/", * 'assign" => "/\s+([^\s]+)\s+=\s+(.+);/", * 'varname" => "/([$]\w+[-]*[>]*\w+)/" * ); * $inputList = file("/path/to/script.php"); * $mondo = new MondoRegex($reList); * echo "Using match\n--------------\n"; * $mondo->match($inputList); * print_r($mondo->getMatches()); * echo "\nUsing match_all\n--------------\n"; * $mondo->matchAll($inputList); * print_r($mondo->getMatches()); * echo "\nGetting only the matches to the 'funcs' regular expression\n"; * echo "----------------------------------------------------------\n"; * print_r($mondo->getMatchesFor('funcs'); * </pre> * * @package SDPHP::MondoRegex * @version 0.1.0 * @copyright Jesus M. Castagnetto, 2003 * @author Jesus M. Castagnetto * * License: PHP License 2.0 or later * Last Updated: Thursday 2003-06-05 00:33:05 PDT. */ class MondoRegex {/*{{{*/ /** * List of regular expressions * * @var array * @access private */ var $_reList = array; /** * List of matches * * @var array * @access private */ var $_matchList = array(); /** * Class constructor * * @param optional array $reList associative array of regular expressions * @return MondoRegex object * @access public */ function MondoRegex($reList = "")/*{{{*/ { if (!empty($reList) && is_array($reList)) { $this->setRegexList($reList); } }/*}}}*/ /** * Sets the regular expression list * * @param optional array $reList associative array of regular expressions * @return void * @access public */ function setRegexList($reList) { if (is_array($reList)) { $this->_reList = $reList; } } /** * Do a simple matching on the input * * @param array $inputList array of strings * @return boolean true on success, false otherwise * @access public */ function match($inputList)/*{{{*/ { return $this->_reMatch("preg_match", $inputList); }/*}}}*/ /** * Perform all possible matches on the input * * @param array $inputList array of strings * @return boolean true on success, false otherwise * @access public */ function matchAll($inputList)/*{{{*/ { return $this->_reMatch("preg_match_all", $inputList); }/*}}}*/ /** * Retrieve all matches from the last operation * * @return array of matches * @access public */ function getMatches()/*{{{*/ { return $this->_matchList; }/*}}}*/ /** * Retrieve the matches for the named regular expression * * @param string $reName the name of the regular expression * @return array|false an array if the name exists, false otherwise */ function getMatchesForKey($reName)/*{{{*/ { if (in_array($reName,array_keys($this->_matchList))) { return $this->_matchList[$reName]; } else { return false; } }/*}}}*/ /** * Retrieve the named regular expressions that gave a match * * @return array|false an array of keys on success, false otherwise * @access public */ function getMatchKeys()/*{{{*/ { if (empty($this->_matchList)) { return false; } else { return array_keys($this->_matchList); } }/*}}}*/ /** * Utility function to perform the regular expression matching * * @param string $reFunc regular expression function to use * @param array $inputList array of input strings * @return boolean true on success, false otherwise * @access private */ function _reMatch($reFunc, $inputList)/*{{{*/ { $this->_matchList = array(); if (empty($this->_reList) || !array($inputList)) { return false; } foreach ($this->_reList as $reName=>$reStr) { foreach ($inputList as $input) { if ($reFunc($reStr, $input, &$hits)) { if (!empty($hits)) { $this->_matchList[$reName][] = $hits; } } } } return !empty($this->_matchList); }/*}}}*/ }/*}}}*/ ?>]]> </example> </slide> Index: presentations/slides/sdphp/tools_mondoregex_with-doctags.xml +++ presentations/slides/sdphp/tools_mondoregex_with-doctags.xml <slide title='MondoRegex (2)'> <example title='Documented version' fontsize='1em'><![CDATA[<?php /** * Class to apply an array of regular expressions * to an array of items. Supports first match only * (as in preg_match) and matching all possibilities * (as in preg_match_all), as well as retrieval of * results from a named regular expression pattern. * * Example of use: * * <pre> * require_once 'SDPHP/MondoRegex.php'; * * $reList = array ( * 'funcs" => "/function (\w+)\s?\(/", * 'assign" => "/\s+([^\s]+)\s+=\s+(.+);/", * 'varname" => "/([$]\w+[-]*[>]*\w+)/" * ); * $inputList = file("/path/to/script.php"); * $mondo = new MondoRegex($reList); * echo "Using match\n--------------\n"; * $mondo->match($inputList); * print_r($mondo->getMatches()); * echo "\nUsing match_all\n--------------\n"; * $mondo->matchAll($inputList); * print_r($mondo->getMatches()); * echo "\nGetting only the matches to the 'funcs' regular expression\n"; * echo "----------------------------------------------------------\n"; * print_r($mondo->getMatchesFor('funcs'); * </pre> * * @package SDPHP::MondoRegex * @version 0.1.0 * @copyright Jesus M. Castagnetto, 2003 * @author Jesus M. Castagnetto * * License: PHP License 2.0 or later * Last Updated: Thursday 2003-06-05 06:15:25 PDT. */ class MondoRegex {/*{{{*/ /** * List of regular expressions * * @var array * @access private */ var $_reList = array; /** * List of matches * * @var array * @access private */ var $_matchList = array(); /** * Class constructor * * @param optional array $reList associative array of regular expressions * @return MondoRegex object * @access public */ function MondoRegex($reList = "")/*{{{*/ { if (!empty($reList) && is_array($reList)) { $this->setRegexList($reList); } }/*}}}*/ /** * Sets the regular expression list * * @param optional array $reList associative array of regular expressions * @return void * @access public */ function setRegexList($reList) { if (is_array($reList)) { $this->_reList = $reList; } } /** * Do a simple matching on the input * * @param array $inputList array of strings * @return boolean true on success, false otherwise * @access public */ function match($inputList)/*{{{*/ { return $this->_reMatch("preg_match", $inputList); }/*}}}*/ /** * Perform all possible matches on the input * * @param array $inputList array of strings * @return boolean true on success, false otherwise * @access public */ function matchAll($inputList)/*{{{*/ { return $this->_reMatch("preg_match_all", $inputList); }/*}}}*/ /** * Retrieve all matches from the last operation * * @return array of matches * @access public */ function getMatches()/*{{{*/ { return $this->_matchList; }/*}}}*/ /** * Retrieve the matches for the named regular expression * * @param string $reName the name of the regular expression * @return array|false an array if the name exists, false otherwise */ function getMatchesForKey($reName)/*{{{*/ { if (in_array($reName,array_keys($this->_matchList))) { return $this->_matchList[$reName]; } else { return false; } }/*}}}*/ /** * Retrieve the named regular expressions that gave a match * * @return array|false an array of keys on success, false otherwise * @access public */ function getMatchKeys()/*{{{*/ { if (empty($this->_matchList)) { return false; } else { return array_keys($this->_matchList); } }/*}}}*/ /** * Utility function to perform the regular expression matching * * @param string $reFunc regular expression function to use * @param array $inputList array of input strings * @return boolean true on success, false otherwise * @access private */ function _reMatch($reFunc, $inputList)/*{{{*/ { $this->_matchList = array(); if (empty($this->_reList) || !array($inputList)) { return false; } foreach ($this->_reList as $reName=>$reStr) { foreach ($inputList as $input) { if ($reFunc($reStr, $input, &$hits)) { if (!empty($hits)) { $this->_matchList[$reName][] = $hits; } } } } return !empty($this->_matchList); }/*}}}*/ }/*}}}*/ ?>]]> </example> </slide> Index: presentations/slides/sdphp/tools_more-info.xml +++ presentations/slides/sdphp/tools_more-info.xml <slide title='For more information'> <link leader='This talk ' align='center' href='http://www.sdphp.net/'/> <link leader='PEAR ' align='center' href='http://pear.php.net/'/> <link leader='phpDocumentor ' align='center' href='http://www.phpdoc.org/'/> <link leader='Exhuberant ctags ' align='center' href='http://ctags.sf.net/'/> <link leader='Vim ' align='center' href='http://www.vim.org/'/> <link leader='"PHP collection" (vim plugin) ' align='center' href='http://www.vim.org/scripts/script.php?script_id=326'/> <link leader='"TagList" (vim plugin) ' align='center' href='http://www.vim.org/scripts/script.php?script_id=273'/> <link leader='Dia ' align='center' href='http://www.lysator.liu.se/~alla/dia/'/> <link leader='Autodia ' align='center' href='http://droogs.org/autodia/'/> <link leader='dia2code ' align='center' href='http://dia2code.sourceforge.net/'/> <link leader='Umbrello ' align='center' href='http://uml.sourceforge.net/'/> <link leader='umi2code ' align='center' href='http://xmi2code.sourceforge.net/'/> </slide> Index: presentations/slides/sdphp/tools_pear-naming-conventions.xml +++ presentations/slides/sdphp/tools_pear-naming-conventions.xml <slide title='Naming conventions'> <blurb> From the 'Coding Standards' section of the PEAR Manual (http://pear.php.net/manual/). </blurb> <list type='number' marginright='1em'> <bullet> Classes should be given descriptive names, e.g. *TemperatureControl*, *HTML_Table*. </bullet> <bullet> Public method and variable names should follow the 'Camel caps' (aka 'Studly caps') convention, except for the class constructor, e.g. *addRow()*, *HTML_Table()*. </bullet> <bullet> Private method and variable names should start with an underscore '*_*', e.g. *_formatBorder()*, *$this->_numRows*. </bullet> <bullet> Constants should be all uppercase and prefixed with the name of the package, e.g. define('*MATH_STATS_CUMMULATIVE*',1); </bullet> <bullet> If you need to define _global_ variables, their names should be prefixed with the package name and start with an underscore, e.g. $GLOBALS['*_PEAR_default_error_mode*'] </bullet> </list> </slide> Index: presentations/slides/sdphp/tools_pearpackager_commands.xml +++ presentations/slides/sdphp/tools_pearpackager_commands.xml <slide title='Command line manager'> <example type='shell' fontsize='1.5em'><![CDATA[ $ pear Usage: pearcmd.php [options] command [command-options] <parameters> Type "pearcmd.php help options" to list all options. Type "pearcmd.php help <command>" to get the help for the specified command. Commands: build Build an Extension From C Source clear-cache Clear XML-RPC Cache config-get Show One Setting config-help Show Information About Setting config-set Change Setting config-show Show All Settings cvsdiff Run a "cvs diff" for all files in a package cvstag Set CVS Release Tag download Download Package info Display information about a package install Install Package list List Installed Packages list-all List All Packages list-upgrades List Available Upgrades login Connects and authenticates to remote server logout Logs out from the remote server makerpm Builds an RPM spec file from a PEAR package package Build Package package-dependencies Show package dependencies package-validate Validate Package Consistency remote-info Information About Remote Packages remote-list List Remote Packages run-tests Run Regression Tests search Search remote package database shell-test Shell Script Test sign Sign a package distribution file uninstall Un-install Package upgrade Upgrade Package upgrade-all Upgrade All Packages ]]></example> </slide> Index: presentations/slides/sdphp/tools_pearpackager_desc.xml +++ presentations/slides/sdphp/tools_pearpackager_desc.xml <slide title='PEAR package manager'> <blurb> The PEAR package manager (%*pear*%) is the swiss-army tool for: </blurb> <list type='bullet'> <bullet>Installing, upgrading and uninstalling packages from PEAR, Horde, etc.</bullet> <bullet>Building PECL extensions (e.g.: apd, xmms, etc.)</bullet> <bullet>Getting information on local and remote packages.</bullet> <bullet>Managing user package list/upgrade preferences.</bullet> <bullet>Check for dependencies</bullet> <bullet>Validating and creating your own distributable packages.</bullet> <bullet>Creating RPM spec files.</bullet> <bullet>Managing PEAR CVS releases: tagging, signing, etc.</bullet> </list> <blurb> And the cool thing is that it is (most likely) already installed on your system (PHP version 4.3.0 or newer). </blurb> <blurb> It is also smart, it groks XML-RPC (like when talking to PEAR's or Horde's site), HTTP (when using a full URL), or even a local tarball on your disk. </blurb> <example type='shell' title='... and if you do not have it' fontsize='1.5em'><![CDATA[ $ wget http://pear.php.net/go-pear $ php -f go-pear (... follow the instructions ...) ]]></example> </slide> Index: presentations/slides/sdphp/tools_pearpackager_getting-help.xml +++ presentations/slides/sdphp/tools_pearpackager_getting-help.xml <slide title='Getting help'> <example type='shell' fontsize='1.5em'><![CDATA[$ pear help options Options: -v increase verbosity level (default 1) -q be quiet, decrease verbosity level -c file find user configuration in `file' -C file find system configuration in `file' -d foo=bar set user config variable `foo' to `bar' -D foo=bar set system config variable `foo' to `bar' -G start in graphical (Gtk) mode -s store user configuration -S store system configuration -u foo unset `foo' in the user configuration -h, -? display help/usage (this message) -V version information]]></example> <example type='shell' fontsize='1.5em'><![CDATA[$ pear help makerpm pearcmd.php makerpm [options] <package-file> Creates an RPM .spec file for wrapping a PEAR package inside an RPM package. Intended to be used from the SPECS directory, with the PEAR package tarball in the SOURCES directory: $ pear makerpm ../SOURCES/Net_Socket-1.0.tgz Wrote RPM spec file PEAR::Net_Geo-1.0.spec $ rpm -bb PEAR::Net_Socket-1.0.spec ... Wrote: /usr/src/redhat/RPMS/i386/PEAR::Net_Socket-1.0-1.i386.rpm Options: -t FILE, --spec-template=FILE Use FILE as RPM spec file template -p FORMAT, --rpm-pkgname=FORMAT Use FORMAT as format string for RPM package name, %s is replaced by the PEAR package name, defaults to "PEAR::%s".]]></example> <example type='shell' fontsize='1.5em'><![CDATA[$ pear config-help preferred_state Config help for preferred_state =============================== Name Type Description preferred_state set the installer will prefer releases with this state when installing packages without a version or state specified Valid set: stable beta alpha devel snapshot]]></example> </slide> Index: presentations/slides/sdphp/tools_pearpackager_gtk.xml +++ presentations/slides/sdphp/tools_pearpackager_gtk.xml <slide title='GTK manager'> <image title='... or if you like GUIs and have php-gtk' filename='images/packagemanager_gtk.png' align='center'/> <example type='shell'><![CDATA[$ pear install PEAR_FrontEnd_Gtk]]></example> </slide> Index: presentations/slides/sdphp/tools_pearpackager_info.xml +++ presentations/slides/sdphp/tools_pearpackager_info.xml <slide title='Getting information'> <example type='shell' title='Local' fontsize='1.5em'><![CDATA[$ pear info apd About apd-0.4p2 =============== Provides Package apd Summary A full-featured engine-level profiler/debugger Description APD is a full-featured profiler/debugger that is loaded as a zend_extension. It aims to be an analog of C's gprof or Perl's Devel::DProf. Release License PHP License Maintainers George Schlossnagle <george@omniti.com> (lead) Version 0.4p2 Release Date 2002-11-25 Release State stable Release Notes Fixed build for 4.3 Last Modified 2003-06-02]]></example> <example type='shell' title='Remote' fontsize='1.4em'><![CDATA[$ pear remote-info Math_Stats Package details: ================ Latest 0.9.0beta2 Installed 0.9.0beta2 Package Math_Stats License PHP Category Math Summary Classes to calculate statistical parameters Description Package to calculate statistical parameters of numerical arrays of data. The data can be in a simple numerical array, or in a cummulative numerical array. A cummulative array, has the value as the index and the number of repeats as the value for the array item, e.g. $data = array(3=>4, 2.3=>5, 1.25=>6, 0.5=>3). Nulls can be rejected, ignored or handled as zero values.]]></example> </slide> Index: presentations/slides/sdphp/tools_pearpackager_listing.xml +++ presentations/slides/sdphp/tools_pearpackager_listing.xml <slide title='Listing packages'> <example type='shell' title='Local'><![CDATA[$ pear list Installed packages: =================== Package Version State Archive_Tar 1.1 stable Auth 1.2.0 stable Auth_SASL 1.0.0 stable Benchmark 1.2.1 stable Cache_Lite 1.1 stable ...]]></example> <example type='shell' title='Local and remote'><![CDATA[$ pear list-all All packages: ============= Package Latest Local apd 0.4p2 0.4p2 bcompiler 0.4 Inline_C 0.1 mono 0.3.1 PHPDoc 0.1.0 PHPUnit 0.6.1 0.6.1 python 0.7.0 Validate 0.1.2 Var_Dump 0.3 0.3 ...]]></example> <example type='shell' title='Finding out available upgrades'><![CDATA[$ pear list-upgrades Available Upgrades (alpha): =========================== Package Version Size apd 0.4 39kB HTML_QuickForm 3.0 61kB LiveUser 0.61 57kB PhpDocumentor 1.2.0 2410kB $ pear upgrade-all (... and the magic continues ...)]]></example> </slide> Index: presentations/slides/sdphp/tools_pearpackager_managing-packages.xml +++ presentations/slides/sdphp/tools_pearpackager_managing-packages.xml <slide title='Managing packages'> <example type='shell' title='Install'><![CDATA[$ pear install PEAR_Frontend_Web downloading PEAR_Frontend_Web-0.3.tgz ... ...done: 32,821 bytes requires package `Net_UserAgent_Detect' PEAR_Frontend_Web: dependencies failed $ pear install Net_UserAgent_Detect downloading Net_UserAgent_Detect-1.0.tgz ... ...done: 7,699 bytes install ok: Net_UserAgent_Detect 1.0 $ pear install PEAR_Frontend_Web downloading PEAR_Frontend_Web-0.3.tgz ... ...done: 32,821 bytes install ok: PEAR_Frontend_Web 0.3]]></example> <example type='shell' title='Uninstall'><![CDATA[$ pear uninstall PEAR_Info uninstall ok: PEAR_Info]]></example> <example type='shell' title='Upgrade'><![CDATA[$ pear upgrade HTML_QuickForm downloading HTML_QuickForm-3.0.tgz ... ...done: 62,379 bytes upgrade ok: HTML_QuickForm 3.0]]></example> </slide> Index: presentations/slides/sdphp/tools_pearpackager_web.xml +++ presentations/slides/sdphp/tools_pearpackager_web.xml <slide title='Web manager'> <image title='... or using a good old web browser' filename='images/packagemanager_web.png' align='center'/> <example type='shell'><![CDATA[ $ pear install Net_UserAgent_Detect $ pear install PEAR_FrontEnd_Web $ ln -s /usr/local/lib/php/PEAR/WebInstaller.php \ /path/to/my/server/admindir/WebInstaller.php]]></example> </slide> Index: presentations/slides/sdphp/tools_phpdocumentor_desc.xml +++ presentations/slides/sdphp/tools_phpdocumentor_desc.xml <slide title='phpDocumentor'> <blurb title="From http://www.phpdoc.org/"> "... phpDocumentor is the most advanced automatic documentation system written for PHP, in PHP ..." </blurb> <list title='Features:'> <bullet>Uses a tokenizer-based parser which is twice as fast as its old parser</bullet> <bullet>Uses docblock templates to cut down on repetition</bullet> <bullet>Ability to parse any PHP file, regardless of documentation format</bullet> <bullet>Conforms loosely to the JavaDOC protocol, and will be familiar to Java programmers</bullet> <bullet>Documents all includes, constants, functions, static functions, classes, methods, static variables, class variables, and can document global variables and external tutorials</bullet> <bullet>Auto-linking to pre-defined PHP functions</bullet> <bullet>Output in HTML, CHM, PDF, XML DocBook formats</bullet> <bullet>Templateable with many bundled templates</bullet> <bullet>Can generate DocBook XML, using the XML:DocBook:peardoc2 templates</bullet> <bullet>Has a CSV:dia2code Converter generates output that can be used to create a UML diagram, and generate code from the diagram using Harald Fielkers dia2code project</bullet> <bullet>Automatic linking to elements in any documented package</bullet> <bullet>Documents name conflicts between packages to help avoid PHP errors</bullet> <bullet>Error/warning tracking system</bullet> <bullet>Alphabetical indexing of all elements by package and overall</bullet> <bullet>Class trees</bullet> <bullet>... and a lot more</bullet> </list> </slide> Index: presentations/slides/sdphp/tools_phpdocumentor_doctags.xml +++ presentations/slides/sdphp/tools_phpdocumentor_doctags.xml <slide title='PhpDocumentor: tags'> <table title='Regular tags' column='2' border='1' width='90%' align='center'> <cell bold='1'>Tag</cell><cell bold='1'>Description</cell> <cell>@abstract</cell><cell>indicates an abstract method</cell> <cell>@access</cell><cell>public or private</cell> <cell>@author</cell><cell>author name <author@email></cell> <cell>@copyright</cell><cell>name and date</cell> <cell>@deprecated</cell><cell>description</cell> <cell>@deprec</cell><cell>alias for deprecated</cell> <cell>@example</cell><cell>/path/to/example</cell> <cell>@exception</cell><cell>Javadoc-compatible, use as needed</cell> <cell>@global</cell><cell>type $globalvarname or description of global variable usage in a function</cell> <cell>@ignore</cell><cell>element will be ignored in documentation</cell> <cell>@param</cell><cell>type [$varname] description</cell> <cell>@return</cell><cell>type description</cell> <cell>@name</cell><cell>procpagealias or $globalvaralias</cell> <cell>@magic</cell><cell>phpdoc.de compatibility</cell> <cell>@package</cell><cell>package name</cell> <cell>@see</cell><cell>name of another element that can be documented, produces a link to it in the documentation</cell> <cell>@since</cell><cell>a version or a date</cell> <cell>@static</cell><cell>indicates a static method or variable</cell> <cell>@staticvar</cell><cell>type description of static variable usage in a function</cell> <cell>@subpackage</cell><cell>sub package name, groupings inside of a project</cell> <cell>@throws</cell><cell>Javadoc-compatible, use as needed</cell> <cell>@todo</cell><cell>phpdoc.de compatibility</cell> <cell>@var</cell><cell>type a data type for a class variable</cell> <cell>@version</cell><cell>version</cell> </table> <table title='Inline tags' column='2' border='1' width='90%' align='center'> <cell bold='1'>Tag</cell><cell bold='1'>Description</cell> <cell>@link</cell><cell>URL</cell> <cell>@source</cell><cell>display function source in the description</cell> <cell>@tutorial</cell><cell>path to the tutorial documentation</cell> <cell>@inheritdoc</cell><cell>copy documentation from the parent document block</cell> <cell>@internal</cell><cell>private information for advanced developers only</cell> </table> </slide> Index: presentations/slides/sdphp/tools_phpdocumentor_example.xml +++ presentations/slides/sdphp/tools_phpdocumentor_example.xml <slide title='Documentation example'> <example title="PHPUnit/Assert.php" fontsize="1.4em"><![CDATA[ (...) /** * A set of assert methods. * * @package PHPUnit * @author Sebastian Bergmann <sb@sebastian-bergmann.de> * Based upon JUnit, see http://www.junit.org/ for details. */ class PHPUnit_Assert { /** * @var boolean * @access private */ var $_looselyTyped = false; /** * Asserts that two variables are equal. * * @param mixed * @param mixed * @param string * @param mixed * @access public */ function assertEquals($expected, $actual, $message = '', $delta = 0) { if ((is_array($actual) && is_array($expected)) || (is_object($actual) && is_object($expected))) { if (is_array($actual) && is_array($expected)) { ksort($actual); ksort($expected); } (...)]]></example> </slide> Index: presentations/slides/sdphp/tools_summary.xml +++ presentations/slides/sdphp/tools_summary.xml <slide title='Summary'> <list title='The PEAR package manager'> <bullet>Makes installation, upgrades and uninstalls a simple tasks.</bullet> <bullet>Simplifies the packaging and deployment of code.</bullet> <bullet>Can even be used to generate RPMs.</bullet> <bullet>Has 3 different interfaces, keeps happy the GUI and command line fans.</bullet> <bullet>Is (most likely) included already in your installation. Use it.</bullet> </list> <list title='Documentation' type='darrow'> <bullet>Writing PHPDoc-style docs is simple and requires little effort</bullet> <bullet>phpDocumentor is a great, free tool. Use it.</bullet> <bullet>API documentation is useful, not only for your own development, but also for the users of your code.</bullet> </list> <blurb title='OTher Tools'> We have seen other tools along the way: </blurb> <list type='arrow'> <bullet>Vim + plugins to make PHP editing simpler.</bullet> <bullet>Dia, AutoDia and dia2code: UML diagrams, and a 'round-trip' design cycle</bullet> <bullet>Umbrello and umi2code: Another UML tool that plays well with PHP</bullet> </list> </slide> Index: presentations/slides/sdphp/tools_title.xml +++ presentations/slides/sdphp/tools_title.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide template="titlepage" fontsize='3.5em'> <title>Welcome!</title> </slide> Index: presentations/slides/sdphp/tools_toc.xml +++ presentations/slides/sdphp/tools_toc.xml <slide title='Contents'> <list title='Tools to make your (coding) life simpler' type='darrow'> <bullet>PEAR package manager: what it provides and how to use it</bullet> <bullet>PhpDocumentor: In-code documentation (PHPDoc tags)</bullet> </list> <list title='An example class' type='darrow'> <bullet>PEAR Naming conventions</bullet> <bullet>Documenting the code</bullet> <bullet>Writing a package description and deploying the package</bullet> </list> <!-- list title="Miscellaneous tools" titlesize='1.5em' type='darrow' aligntitle='center'> <bullet>Vim/Gvim, ctags, and vim plugins ("php collection", taglist.vim, etc.)</bullet> <bullet>Dia + Autodia + dia2code</bullet> <bullet>Umbrello + umi2code</bullet> </list --> <list type='bullet' marginleft='-0.5em'> <bullet>Summary</bullet> <bullet>Useful links</bullet> </list> <blurb> Along the way, we'll have some "Live demo" breaks %;-)% </blurb> </slide>
Index: presentations/slides/sdphp/README-sdphp_using_tools.txt +++ presentations/slides/sdphp/README-sdphp_using_tools.txt This is a talk to show the use of some tools to help in code development. I have put the sample code, as well as the UML diagrams and uml-generated code (from dia2code and xmi2code), in the directory: ./misc/sdphp_using_tools/ Have fun and hope they are useful to you too. -- Jesus M. Castagnetto Index: presentations/slides/sdphp/tools_PEAR_Info.xml +++ presentations/slides/sdphp/tools_PEAR_Info.xml <slide title="Davey's PEAR_Info"> <example type='php' fontsize='1.5em'><![CDATA[<?php require_once 'PEAR/Info.php'; $info = new PEAR_Info(); $info->show(); ?>]]></example> <image filename='images/pear_info.png' align='center'/> </slide> Index: presentations/slides/sdphp/tools_mondoregex_bare-code.xml +++ presentations/slides/sdphp/tools_mondoregex_bare-code.xml <slide title='MondoRegex (1)'> <blurb> We will first flesh out the methods described before, and add a private method that does the heavy lifting of matching. </blurb> <example role='php' fontsize='1.5em'><![CDATA[<?php class MondoRegex { var $_reList = array; var $_matchList = array(); function MondoRegex($reList = "") { if (!empty($reList) && is_array($reList)) $this->setRegexList($reList); } function setRegexList($reList) { if (is_array($reList)) $this->_reList = $reList; } function match($inputList) { return $this->_reMatch("preg_match", $inputList); } function matchAll($inputList) { return $this->_reMatch("preg_match_all", $inputList); } function getMatches() { return $this->_matchList; } function getMatchesFor($reName) { if (in_array($reName,array_keys($this->_matchList))) { return $this->_matchList[$reName]; } else { return false; } } function getMatchKeys() { if (empty($this->_matchList)) { return false; } else { return array_keys($this->_matchList); } } function _reMatch($reFunc, $inputList) { $this->matchList = array(); if (empty($this->_reList) || !array($inputList)) return false; foreach ($this->_reList as $reName=>$reStr) foreach ($inputList as $input) if ($reFunc($reStr, $input, &$hits)) if (!empty($hits)) $this->_matchList[$reName][] = $hits; return !empty($this->_matchList); } } ?>]]></example> </slide> Index: presentations/slides/sdphp/tools_mondoregex_deploying.xml +++ presentations/slides/sdphp/tools_mondoregex_deploying.xml <slide title='Deploying MondoRegex'> <example type='shell' title='Creating the tarball' fontsize='1.5em'><![CDATA[ $ pear package-validate Validation: 0 error(s), 0 warning(s) $ pear package Analyzing MondoRegex.php Package /path/to/my/devel/dir/MondoRegex-0.1.0.tgz done $ pear install MondoRegex-0.1.0.tgz install ok: MondoRegex 0.1.0 $ php -f test.php TESTING MondoRegex Using match ... $ cp MondoRegex-0.1.0.tgz /path/to/my/server/dir/packages/ ]]></example> <example type='shell' title='... later that day, somewhere on the net' fontsize='1.5em'><![CDATA[ $ pear install http://coolphpstuff.com/packages/MondoRegex-0.1.0.tgz downloading MondoRegex-0.1.0.tgz... ...done: 1,895 bytes install ok: MondoRegex 0.1.0 ]]></example> </slide> Index: presentations/slides/sdphp/tools_mondoregex_desc.xml +++ presentations/slides/sdphp/tools_mondoregex_desc.xml <slide title='Example class'> <blurb title='The plan'> Let's write a class and then create a package definition to distribute it. Our example class will be able to apply an array of regular expressions to an array of input strings. </blurb> <blurb> We will try and follow the PEAR naming conventions, to play nice with the other packages and make the users life simpler. </blurb> <blurb fontsize='3em' align='center' effect='hide'> Meet ... MondoRegex! </blurb> <example effect='hide'><![CDATA[<?php class MondoRegex { var $_reList = array; var $_matchList = array(); function MondoRegex($reList = "") {} function setRegexList($reList) {} function match($inputList) {} function matchAll($inputList) {} function getMatches() {} function getMatchesForKey($reName) {} function getMatchKeys() {} } ?>]]> </example> </slide> Index: presentations/slides/sdphp/tools_mondoregex_example-apidocs.xml +++ presentations/slides/sdphp/tools_mondoregex_example-apidocs.xml <slide title='MondoRegex - API docs'> <example type='shell' title='Running phpDocumentor'><![CDATA[ $ phpdoc -d /path/to/my/devel/dir \ -t /path/to/my/devel/dir/apidoc \ --pear -ti 'MondoRegex' \ -o 'HTML:frames:default,XML:DocBook/peardoc2:default']]> </example> <image filename='images/api_mondoregex.png' align='center'/> </slide> Index: presentations/slides/sdphp/tools_mondoregex_example-uml.xml +++ presentations/slides/sdphp/tools_mondoregex_example-uml.xml <slide title='MondoRegex - UML'> <blurb> There are more tools than the ones for editing the code, and for generating the documentation. We can also generate (... drum roll ...) UML diagrams! </blurb> <blurb> Of course, we could use our favorite diagram drawing program (e.g. *Dia*) and write an UML diagram, but we are *lazy*, so we use automatic ways of dealing with the problem. Enter *Autodia*. </blurb> <list title='Autodia: from code to UML'> <bullet>Is a tool that can analyze your code and generate a good (although a little messy at first) UML diagram of your classes.</bullet> <blurb>It understand Java, Perl, PHP, SQL, and others (soon Python too).</blurb> <blurb>It is written in Perl, but we will not hold that against it %;-)%, because the code is quite readable and well organized.</blurb> </list> <image title='Running Autodia on MondoRegex.php' filename='images/mondoregex_uml-raw.png' align='center'/> <image title='... and after some cleaning' filename='images/mondoregex_uml.png' align='center'/> <blurb title='dia2code: from UML to code'> You can also go the other way, if you have a nice UML diagram, you can generate PHP (or Java, or Perl, etc.) with dia2code. </blurb> <blurb title='Another alternative: Umbrello and xmi2code'> *Umbrello* is a specialized tool (unlike Dia), and supports the "standard" XMI format, and the companion project *xmi2code* can produce code from your UML description. </blurb> </slide> Index: presentations/slides/sdphp/tools_mondoregex_package-desc.xml +++ presentations/slides/sdphp/tools_mondoregex_package-desc.xml <slide title='Package description'> <example title='package.xml' fontsize='1em' examplebackground='#eeeeee'><![CDATA[<?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE package SYSTEM "../package.dtd"> <package> <name>MondoRegex</name> <summary>Class to apply a list of regular expressions</summary> <description> This class applies an array of named regular expressions to an array of input strings. </description> <maintainers> <maintainer> <user>jmcastagnetto</user> <name>Jesus M. Castagnetto</name> <email>jmcastagnetto@php.net</email> <role>lead</role> </maintainer> <maintainer> <user>snipe</user> <name>Alison Gianotto</name> <email>snipe@snipe.net</email> <role>developer</role> </maintainer> </maintainers> <release> <license>PHP</license> <version>0.1.0</version> <date>2003-06-05</date> <notes>Initial release</notes> <state>beta</state> <filelist> <dir name="/" baseinstalldir="SDPHP"> <file role="php">MondoRegex.php</file> </dir> </filelist> </release> <changelog> </changelog> </package>]]> </example> </slide> Index: presentations/slides/sdphp/tools_mondoregex_screenshot.xml +++ presentations/slides/sdphp/tools_mondoregex_screenshot.xml <slide title='MondoRegex (3)'> <image title='Editing the code' filename='images/editing_mondoregex.png' align='center'/> <blurb> Gvim with some plugins to show the code structure (based on ctags), as well as on-line documentation for *is_array()*. </blurb> </slide> Index: presentations/slides/sdphp/tools_mondoregex_title.xml +++ presentations/slides/sdphp/tools_mondoregex_title.xml <slide title="Putting it all together" fontsize='3.5em'> <blurb align='center' title='MondoRegex' fontsize='4em'/> </slide> Index: presentations/slides/sdphp/tools_mondoregex_with-doc-tags.xml +++ presentations/slides/sdphp/tools_mondoregex_with-doc-tags.xml <slide title='MondoRegex (3)'> <example title='Complete version' fontsize='1em'><![CDATA[<?php /** * Class to apply an array of regular expressions * to an array of items. Supports first match only * (as in preg_match) and matching all possibilities * (as in preg_match_all), as well as retrieval of * results from a named regular expression pattern. * * Example of use: * * <pre> * require_once 'SDPHP/MondoRegex.php'; * * $reList = array ( * 'funcs" => "/function (\w+)\s?\(/", * 'assign" => "/\s+([^\s]+)\s+=\s+(.+);/", * 'varname" => "/([$]\w+[-]*[>]*\w+)/" * ); * $inputList = file("/path/to/script.php"); * $mondo = new MondoRegex($reList); * echo "Using match\n--------------\n"; * $mondo->match($inputList); * print_r($mondo->getMatches()); * echo "\nUsing match_all\n--------------\n"; * $mondo->matchAll($inputList); * print_r($mondo->getMatches()); * echo "\nGetting only the matches to the 'funcs' regular expression\n"; * echo "----------------------------------------------------------\n"; * print_r($mondo->getMatchesFor('funcs'); * </pre> * * @package SDPHP::MondoRegex * @version 0.1.0 * @copyright Jesus M. Castagnetto, 2003 * @author Jesus M. Castagnetto * * License: PHP License 2.0 or later * Last Updated: Thursday 2003-06-05 00:33:05 PDT. */ class MondoRegex {/*{{{*/ /** * List of regular expressions * * @var array * @access private */ var $_reList = array; /** * List of matches * * @var array * @access private */ var $_matchList = array(); /** * Class constructor * * @param optional array $reList associative array of regular expressions * @return MondoRegex object * @access public */ function MondoRegex($reList = "")/*{{{*/ { if (!empty($reList) && is_array($reList)) { $this->setRegexList($reList); } }/*}}}*/ /** * Sets the regular expression list * * @param optional array $reList associative array of regular expressions * @return void * @access public */ function setRegexList($reList) { if (is_array($reList)) { $this->_reList = $reList; } } /** * Do a simple matching on the input * * @param array $inputList array of strings * @return boolean true on success, false otherwise * @access public */ function match($inputList)/*{{{*/ { return $this->_reMatch("preg_match", $inputList); }/*}}}*/ /** * Perform all possible matches on the input * * @param array $inputList array of strings * @return boolean true on success, false otherwise * @access public */ function matchAll($inputList)/*{{{*/ { return $this->_reMatch("preg_match_all", $inputList); }/*}}}*/ /** * Retrieve all matches from the last operation * * @return array of matches * @access public */ function getMatches()/*{{{*/ { return $this->_matchList; }/*}}}*/ /** * Retrieve the matches for the named regular expression * * @param string $reName the name of the regular expression * @return array|false an array if the name exists, false otherwise */ function getMatchesForKey($reName)/*{{{*/ { if (in_array($reName,array_keys($this->_matchList))) { return $this->_matchList[$reName]; } else { return false; } }/*}}}*/ /** * Retrieve the named regular expressions that gave a match * * @return array|false an array of keys on success, false otherwise * @access public */ function getMatchKeys()/*{{{*/ { if (empty($this->_matchList)) { return false; } else { return array_keys($this->_matchList); } }/*}}}*/ /** * Utility function to perform the regular expression matching * * @param string $reFunc regular expression function to use * @param array $inputList array of input strings * @return boolean true on success, false otherwise * @access private */ function _reMatch($reFunc, $inputList)/*{{{*/ { $this->_matchList = array(); if (empty($this->_reList) || !array($inputList)) { return false; } foreach ($this->_reList as $reName=>$reStr) { foreach ($inputList as $input) { if ($reFunc($reStr, $input, &$hits)) { if (!empty($hits)) { $this->_matchList[$reName][] = $hits; } } } } return !empty($this->_matchList); }/*}}}*/ }/*}}}*/ ?>]]> </example> </slide> Index: presentations/slides/sdphp/tools_mondoregex_with-doctags.xml +++ presentations/slides/sdphp/tools_mondoregex_with-doctags.xml <slide title='MondoRegex (2)'> <example title='Documented version' fontsize='1em'><![CDATA[<?php /** * Class to apply an array of regular expressions * to an array of items. Supports first match only * (as in preg_match) and matching all possibilities * (as in preg_match_all), as well as retrieval of * results from a named regular expression pattern. * * Example of use: * * <pre> * require_once 'SDPHP/MondoRegex.php'; * * $reList = array ( * 'funcs" => "/function (\w+)\s?\(/", * 'assign" => "/\s+([^\s]+)\s+=\s+(.+);/", * 'varname" => "/([$]\w+[-]*[>]*\w+)/" * ); * $inputList = file("/path/to/script.php"); * $mondo = new MondoRegex($reList); * echo "Using match\n--------------\n"; * $mondo->match($inputList); * print_r($mondo->getMatches()); * echo "\nUsing match_all\n--------------\n"; * $mondo->matchAll($inputList); * print_r($mondo->getMatches()); * echo "\nGetting only the matches to the 'funcs' regular expression\n"; * echo "----------------------------------------------------------\n"; * print_r($mondo->getMatchesFor('funcs'); * </pre> * * @package SDPHP::MondoRegex * @version 0.1.0 * @copyright Jesus M. Castagnetto, 2003 * @author Jesus M. Castagnetto * * License: PHP License 2.0 or later * Last Updated: Thursday 2003-06-05 06:15:25 PDT. */ class MondoRegex {/*{{{*/ /** * List of regular expressions * * @var array * @access private */ var $_reList = array; /** * List of matches * * @var array * @access private */ var $_matchList = array(); /** * Class constructor * * @param optional array $reList associative array of regular expressions * @return MondoRegex object * @access public */ function MondoRegex($reList = "")/*{{{*/ { if (!empty($reList) && is_array($reList)) { $this->setRegexList($reList); } }/*}}}*/ /** * Sets the regular expression list * * @param optional array $reList associative array of regular expressions * @return void * @access public */ function setRegexList($reList) { if (is_array($reList)) { $this->_reList = $reList; } } /** * Do a simple matching on the input * * @param array $inputList array of strings * @return boolean true on success, false otherwise * @access public */ function match($inputList)/*{{{*/ { return $this->_reMatch("preg_match", $inputList); }/*}}}*/ /** * Perform all possible matches on the input * * @param array $inputList array of strings * @return boolean true on success, false otherwise * @access public */ function matchAll($inputList)/*{{{*/ { return $this->_reMatch("preg_match_all", $inputList); }/*}}}*/ /** * Retrieve all matches from the last operation * * @return array of matches * @access public */ function getMatches()/*{{{*/ { return $this->_matchList; }/*}}}*/ /** * Retrieve the matches for the named regular expression * * @param string $reName the name of the regular expression * @return array|false an array if the name exists, false otherwise */ function getMatchesForKey($reName)/*{{{*/ { if (in_array($reName,array_keys($this->_matchList))) { return $this->_matchList[$reName]; } else { return false; } }/*}}}*/ /** * Retrieve the named regular expressions that gave a match * * @return array|false an array of keys on success, false otherwise * @access public */ function getMatchKeys()/*{{{*/ { if (empty($this->_matchList)) { return false; } else { return array_keys($this->_matchList); } }/*}}}*/ /** * Utility function to perform the regular expression matching * * @param string $reFunc regular expression function to use * @param array $inputList array of input strings * @return boolean true on success, false otherwise * @access private */ function _reMatch($reFunc, $inputList)/*{{{*/ { $this->_matchList = array(); if (empty($this->_reList) || !array($inputList)) { return false; } foreach ($this->_reList as $reName=>$reStr) { foreach ($inputList as $input) { if ($reFunc($reStr, $input, &$hits)) { if (!empty($hits)) { $this->_matchList[$reName][] = $hits; } } } } return !empty($this->_matchList); }/*}}}*/ }/*}}}*/ ?>]]> </example> </slide> Index: presentations/slides/sdphp/tools_more-info.xml +++ presentations/slides/sdphp/tools_more-info.xml <slide title='For more information'> <link leader='This talk ' align='center' href='http://www.sdphp.net/'/> <link leader='PEAR ' align='center' href='http://pear.php.net/'/> <link leader='phpDocumentor ' align='center' href='http://www.phpdoc.org/'/> <link leader='Exhuberant ctags ' align='center' href='http://ctags.sf.net/'/> <link leader='Vim ' align='center' href='http://www.vim.org/'/> <link leader='"PHP collection" (vim plugin) ' align='center' href='http://www.vim.org/scripts/script.php?script_id=326'/> <link leader='"TagList" (vim plugin) ' align='center' href='http://www.vim.org/scripts/script.php?script_id=273'/> <link leader='Dia ' align='center' href='http://www.lysator.liu.se/~alla/dia/'/> <link leader='Autodia ' align='center' href='http://droogs.org/autodia/'/> <link leader='dia2code ' align='center' href='http://dia2code.sourceforge.net/'/> <link leader='Umbrello ' align='center' href='http://uml.sourceforge.net/'/> <link leader='umi2code ' align='center' href='http://xmi2code.sourceforge.net/'/> </slide> Index: presentations/slides/sdphp/tools_pear-naming-conventions.xml +++ presentations/slides/sdphp/tools_pear-naming-conventions.xml <slide title='Naming conventions'> <blurb> From the 'Coding Standards' section of the PEAR Manual (http://pear.php.net/manual/). </blurb> <list type='number' marginright='1em'> <bullet> Classes should be given descriptive names, e.g. *TemperatureControl*, *HTML_Table*. </bullet> <bullet> Public method and variable names should follow the 'Camel caps' (aka 'Studly caps') convention, except for the class constructor, e.g. *addRow()*, *HTML_Table()*. </bullet> <bullet> Private method and variable names should start with an underscore '*_*', e.g. *_formatBorder()*, *$this->_numRows*. </bullet> <bullet> Constants should be all uppercase and prefixed with the name of the package, e.g. define('*MATH_STATS_CUMMULATIVE*',1); </bullet> <bullet> If you need to define _global_ variables, their names should be prefixed with the package name and start with an underscore, e.g. $GLOBALS['*_PEAR_default_error_mode*'] </bullet> </list> </slide> Index: presentations/slides/sdphp/tools_pearpackager_commands.xml +++ presentations/slides/sdphp/tools_pearpackager_commands.xml <slide title='Command line manager'> <example type='shell' fontsize='1.5em'><![CDATA[ $ pear Usage: pearcmd.php [options] command [command-options] <parameters> Type "pearcmd.php help options" to list all options. Type "pearcmd.php help <command>" to get the help for the specified command. Commands: build Build an Extension From C Source clear-cache Clear XML-RPC Cache config-get Show One Setting config-help Show Information About Setting config-set Change Setting config-show Show All Settings cvsdiff Run a "cvs diff" for all files in a package cvstag Set CVS Release Tag download Download Package info Display information about a package install Install Package list List Installed Packages list-all List All Packages list-upgrades List Available Upgrades login Connects and authenticates to remote server logout Logs out from the remote server makerpm Builds an RPM spec file from a PEAR package package Build Package package-dependencies Show package dependencies package-validate Validate Package Consistency remote-info Information About Remote Packages remote-list List Remote Packages run-tests Run Regression Tests search Search remote package database shell-test Shell Script Test sign Sign a package distribution file uninstall Un-install Package upgrade Upgrade Package upgrade-all Upgrade All Packages ]]></example> </slide> Index: presentations/slides/sdphp/tools_pearpackager_desc.xml +++ presentations/slides/sdphp/tools_pearpackager_desc.xml <slide title='PEAR package manager'> <blurb> The PEAR package manager (%*pear*%) is the swiss-army tool for: </blurb> <list type='bullet'> <bullet>Installing, upgrading and uninstalling packages from PEAR, Horde, etc.</bullet> <bullet>Building PECL extensions (e.g.: apd, xmms, etc.)</bullet> <bullet>Getting information on local and remote packages.</bullet> <bullet>Managing user package list/upgrade preferences.</bullet> <bullet>Check for dependencies</bullet> <bullet>Validating and creating your own distributable packages.</bullet> <bullet>Creating RPM spec files.</bullet> <bullet>Managing PEAR CVS releases: tagging, signing, etc.</bullet> </list> <blurb> And the cool thing is that it is (most likely) already installed on your system (PHP version 4.3.0 or newer). </blurb> <blurb> It is also smart, it groks XML-RPC (like when talking to PEAR's or Horde's site), HTTP (when using a full URL), or even a local tarball on your disk. </blurb> <example type='shell' title='... and if you do not have it' fontsize='1.5em'><![CDATA[ $ wget http://pear.php.net/go-pear $ php -f go-pear (... follow the instructions ...) ]]></example> </slide> Index: presentations/slides/sdphp/tools_pearpackager_getting-help.xml +++ presentations/slides/sdphp/tools_pearpackager_getting-help.xml <slide title='Getting help'> <example type='shell' fontsize='1.5em'><![CDATA[$ pear help options Options: -v increase verbosity level (default 1) -q be quiet, decrease verbosity level -c file find user configuration in `file' -C file find system configuration in `file' -d foo=bar set user config variable `foo' to `bar' -D foo=bar set system config variable `foo' to `bar' -G start in graphical (Gtk) mode -s store user configuration -S store system configuration -u foo unset `foo' in the user configuration -h, -? display help/usage (this message) -V version information]]></example> <example type='shell' fontsize='1.5em'><![CDATA[$ pear help makerpm pearcmd.php makerpm [options] <package-file> Creates an RPM .spec file for wrapping a PEAR package inside an RPM package. Intended to be used from the SPECS directory, with the PEAR package tarball in the SOURCES directory: $ pear makerpm ../SOURCES/Net_Socket-1.0.tgz Wrote RPM spec file PEAR::Net_Geo-1.0.spec $ rpm -bb PEAR::Net_Socket-1.0.spec ... Wrote: /usr/src/redhat/RPMS/i386/PEAR::Net_Socket-1.0-1.i386.rpm Options: -t FILE, --spec-template=FILE Use FILE as RPM spec file template -p FORMAT, --rpm-pkgname=FORMAT Use FORMAT as format string for RPM package name, %s is replaced by the PEAR package name, defaults to "PEAR::%s".]]></example> <example type='shell' fontsize='1.5em'><![CDATA[$ pear config-help preferred_state Config help for preferred_state =============================== Name Type Description preferred_state set the installer will prefer releases with this state when installing packages without a version or state specified Valid set: stable beta alpha devel snapshot]]></example> </slide> Index: presentations/slides/sdphp/tools_pearpackager_gtk.xml +++ presentations/slides/sdphp/tools_pearpackager_gtk.xml <slide title='GTK manager'> <image title='... or if you like GUIs and have php-gtk' filename='images/packagemanager_gtk.png' align='center'/> <example type='shell'><![CDATA[$ pear install PEAR_FrontEnd_Gtk]]></example> </slide> Index: presentations/slides/sdphp/tools_pearpackager_info.xml +++ presentations/slides/sdphp/tools_pearpackager_info.xml <slide title='Getting information'> <example type='shell' title='Local' fontsize='1.5em'><![CDATA[$ pear info apd About apd-0.4p2 =============== Provides Package apd Summary A full-featured engine-level profiler/debugger Description APD is a full-featured profiler/debugger that is loaded as a zend_extension. It aims to be an analog of C's gprof or Perl's Devel::DProf. Release License PHP License Maintainers George Schlossnagle <george@omniti.com> (lead) Version 0.4p2 Release Date 2002-11-25 Release State stable Release Notes Fixed build for 4.3 Last Modified 2003-06-02]]></example> <example type='shell' title='Remote' fontsize='1.4em'><![CDATA[$ pear remote-info Math_Stats Package details: ================ Latest 0.9.0beta2 Installed 0.9.0beta2 Package Math_Stats License PHP Category Math Summary Classes to calculate statistical parameters Description Package to calculate statistical parameters of numerical arrays of data. The data can be in a simple numerical array, or in a cummulative numerical array. A cummulative array, has the value as the index and the number of repeats as the value for the array item, e.g. $data = array(3=>4, 2.3=>5, 1.25=>6, 0.5=>3). Nulls can be rejected, ignored or handled as zero values.]]></example> </slide> Index: presentations/slides/sdphp/tools_pearpackager_listing.xml +++ presentations/slides/sdphp/tools_pearpackager_listing.xml <slide title='Listing packages'> <example type='shell' title='Local'><![CDATA[$ pear list Installed packages: =================== Package Version State Archive_Tar 1.1 stable Auth 1.2.0 stable Auth_SASL 1.0.0 stable Benchmark 1.2.1 stable Cache_Lite 1.1 stable ...]]></example> <example type='shell' title='Local and remote'><![CDATA[$ pear list-all All packages: ============= Package Latest Local apd 0.4p2 0.4p2 bcompiler 0.4 Inline_C 0.1 mono 0.3.1 PHPDoc 0.1.0 PHPUnit 0.6.1 0.6.1 python 0.7.0 Validate 0.1.2 Var_Dump 0.3 0.3 ...]]></example> <example type='shell' title='Finding out available upgrades'><![CDATA[$ pear list-upgrades Available Upgrades (alpha): =========================== Package Version Size apd 0.4 39kB HTML_QuickForm 3.0 61kB LiveUser 0.61 57kB PhpDocumentor 1.2.0 2410kB $ pear upgrade-all (... and the magic continues ...)]]></example> </slide> Index: presentations/slides/sdphp/tools_pearpackager_managing-packages.xml +++ presentations/slides/sdphp/tools_pearpackager_managing-packages.xml <slide title='Managing packages'> <example type='shell' title='Install'><![CDATA[$ pear install PEAR_Frontend_Web downloading PEAR_Frontend_Web-0.3.tgz ... ...done: 32,821 bytes requires package `Net_UserAgent_Detect' PEAR_Frontend_Web: dependencies failed $ pear install Net_UserAgent_Detect downloading Net_UserAgent_Detect-1.0.tgz ... ...done: 7,699 bytes install ok: Net_UserAgent_Detect 1.0 $ pear install PEAR_Frontend_Web downloading PEAR_Frontend_Web-0.3.tgz ... ...done: 32,821 bytes install ok: PEAR_Frontend_Web 0.3]]></example> <example type='shell' title='Uninstall'><![CDATA[$ pear uninstall PEAR_Info uninstall ok: PEAR_Info]]></example> <example type='shell' title='Upgrade'><![CDATA[$ pear upgrade HTML_QuickForm downloading HTML_QuickForm-3.0.tgz ... ...done: 62,379 bytes upgrade ok: HTML_QuickForm 3.0]]></example> </slide> Index: presentations/slides/sdphp/tools_pearpackager_web.xml +++ presentations/slides/sdphp/tools_pearpackager_web.xml <slide title='Web manager'> <image title='... or using a good old web browser' filename='images/packagemanager_web.png' align='center'/> <example type='shell'><![CDATA[ $ pear install Net_UserAgent_Detect $ pear install PEAR_FrontEnd_Web $ ln -s /usr/local/lib/php/PEAR/WebInstaller.php \ /path/to/my/server/admindir/WebInstaller.php]]></example> </slide> Index: presentations/slides/sdphp/tools_phpdocumentor_desc.xml +++ presentations/slides/sdphp/tools_phpdocumentor_desc.xml <slide title='phpDocumentor'> <blurb title="From http://www.phpdoc.org/"> "... phpDocumentor is the most advanced automatic documentation system written for PHP, in PHP ..." </blurb> <list title='Features:'> <bullet>Uses a tokenizer-based parser which is twice as fast as its old parser</bullet> <bullet>Uses docblock templates to cut down on repetition</bullet> <bullet>Ability to parse any PHP file, regardless of documentation format</bullet> <bullet>Conforms loosely to the JavaDOC protocol, and will be familiar to Java programmers</bullet> <bullet>Documents all includes, constants, functions, static functions, classes, methods, static variables, class variables, and can document global variables and external tutorials</bullet> <bullet>Auto-linking to pre-defined PHP functions</bullet> <bullet>Output in HTML, CHM, PDF, XML DocBook formats</bullet> <bullet>Templateable with many bundled templates</bullet> <bullet>Can generate DocBook XML, using the XML:DocBook:peardoc2 templates</bullet> <bullet>Has a CSV:dia2code Converter generates output that can be used to create a UML diagram, and generate code from the diagram using Harald Fielkers dia2code project</bullet> <bullet>Automatic linking to elements in any documented package</bullet> <bullet>Documents name conflicts between packages to help avoid PHP errors</bullet> <bullet>Error/warning tracking system</bullet> <bullet>Alphabetical indexing of all elements by package and overall</bullet> <bullet>Class trees</bullet> <bullet>... and a lot more</bullet> </list> </slide> Index: presentations/slides/sdphp/tools_phpdocumentor_doctags.xml +++ presentations/slides/sdphp/tools_phpdocumentor_doctags.xml <slide title='PhpDocumentor: tags'> <table title='Regular tags' column='2' border='1' width='90%' align='center'> <cell bold='1'>Tag</cell><cell bold='1'>Description</cell> <cell>@abstract</cell><cell>indicates an abstract method</cell> <cell>@access</cell><cell>public or private</cell> <cell>@author</cell><cell>author name <author@email></cell> <cell>@copyright</cell><cell>name and date</cell> <cell>@deprecated</cell><cell>description</cell> <cell>@deprec</cell><cell>alias for deprecated</cell> <cell>@example</cell><cell>/path/to/example</cell> <cell>@exception</cell><cell>Javadoc-compatible, use as needed</cell> <cell>@global</cell><cell>type $globalvarname or description of global variable usage in a function</cell> <cell>@ignore</cell><cell>element will be ignored in documentation</cell> <cell>@param</cell><cell>type [$varname] description</cell> <cell>@return</cell><cell>type description</cell> <cell>@name</cell><cell>procpagealias or $globalvaralias</cell> <cell>@magic</cell><cell>phpdoc.de compatibility</cell> <cell>@package</cell><cell>package name</cell> <cell>@see</cell><cell>name of another element that can be documented, produces a link to it in the documentation</cell> <cell>@since</cell><cell>a version or a date</cell> <cell>@static</cell><cell>indicates a static method or variable</cell> <cell>@staticvar</cell><cell>type description of static variable usage in a function</cell> <cell>@subpackage</cell><cell>sub package name, groupings inside of a project</cell> <cell>@throws</cell><cell>Javadoc-compatible, use as needed</cell> <cell>@todo</cell><cell>phpdoc.de compatibility</cell> <cell>@var</cell><cell>type a data type for a class variable</cell> <cell>@version</cell><cell>version</cell> </table> <table title='Inline tags' column='2' border='1' width='90%' align='center'> <cell bold='1'>Tag</cell><cell bold='1'>Description</cell> <cell>@link</cell><cell>URL</cell> <cell>@source</cell><cell>display function source in the description</cell> <cell>@tutorial</cell><cell>path to the tutorial documentation</cell> <cell>@inheritdoc</cell><cell>copy documentation from the parent document block</cell> <cell>@internal</cell><cell>private information for advanced developers only</cell> </table> </slide> Index: presentations/slides/sdphp/tools_phpdocumentor_example.xml +++ presentations/slides/sdphp/tools_phpdocumentor_example.xml <slide title='Documentation example'> <example title="PHPUnit/Assert.php" fontsize="1.4em"><![CDATA[ (...) /** * A set of assert methods. * * @package PHPUnit * @author Sebastian Bergmann <sb@sebastian-bergmann.de> * Based upon JUnit, see http://www.junit.org/ for details. */ class PHPUnit_Assert { /** * @var boolean * @access private */ var $_looselyTyped = false; /** * Asserts that two variables are equal. * * @param mixed * @param mixed * @param string * @param mixed * @access public */ function assertEquals($expected, $actual, $message = '', $delta = 0) { if ((is_array($actual) && is_array($expected)) || (is_object($actual) && is_object($expected))) { if (is_array($actual) && is_array($expected)) { ksort($actual); ksort($expected); } (...)]]></example> </slide> Index: presentations/slides/sdphp/tools_summary.xml +++ presentations/slides/sdphp/tools_summary.xml <slide title='Summary'> <list title='The PEAR package manager'> <bullet>Makes installation, upgrades and uninstalls a simple tasks.</bullet> <bullet>Simplifies the packaging and deployment of code.</bullet> <bullet>Can even be used to generate RPMs.</bullet> <bullet>Has 3 different interfaces, keeps happy the GUI and command line fans.</bullet> <bullet>Is (most likely) included already in your installation. Use it.</bullet> </list> <list title='Documentation' type='darrow'> <bullet>Writing PHPDoc-style docs is simple and requires little effort</bullet> <bullet>phpDocumentor is a great, free tool. Use it.</bullet> <bullet>API documentation is useful, not only for your own development, but also for the users of your code.</bullet> </list> <blurb title='OTher Tools'> We have seen other tools along the way: </blurb> <list type='arrow'> <bullet>Vim + plugins to make PHP editing simpler.</bullet> <bullet>Dia, AutoDia and dia2code: UML diagrams, and a 'round-trip' design cycle</bullet> <bullet>Umbrello and umi2code: Another UML tool that plays well with PHP</bullet> </list> </slide> Index: presentations/slides/sdphp/tools_title.xml +++ presentations/slides/sdphp/tools_title.xml <?xml version="1.0" encoding="ISO-8859-1"?> <slide template="titlepage" fontsize='3.5em'> <title>Welcome!</title> </slide> Index: presentations/slides/sdphp/tools_toc.xml +++ presentations/slides/sdphp/tools_toc.xml <slide title='Contents'> <list title='Tools to make your (coding) life simpler' type='darrow'> <bullet>PEAR package manager: what it provides and how to use it</bullet> <bullet>PhpDocumentor: In-code documentation (PHPDoc tags)</bullet> </list> <list title='An example class' type='darrow'> <bullet>PEAR Naming conventions</bullet> <bullet>Documenting the code</bullet> <bullet>Writing a package description and deploying the package</bullet> </list> <!-- list title="Miscellaneous tools" titlesize='1.5em' type='darrow' aligntitle='center'> <bullet>Vim/Gvim, ctags, and vim plugins ("php collection", taglist.vim, etc.)</bullet> <bullet>Dia + Autodia + dia2code</bullet> <bullet>Umbrello + umi2code</bullet> </list --> <list type='bullet' marginleft='-0.5em'> <bullet>Summary</bullet> <bullet>Useful links</bullet> </list> <blurb> Along the way, we'll have some "Live demo" breaks %;-)% </blurb> </slide>