cvs: presentations / php-weekender.xml /slides/php-weekender agenda.xml debugging-agenda.xml debugging-common-pitfalls.xml debugging-external-apd.xml
debugging-external-dbg.xml debugging-external-overview.xml debugging-external-xdebug.xml debugging-external-zend.xml debugging-intro.xml
debugging-php-1.xml debugging-php-2.xml debugging-php-3.xml debugging-strategies.xml debugging-xdebug-configuration.xml debugging-xdebug-error.jpg
debugging-xdebug-installing.xml debugging-xdebug-overview.xml debugging-xdebug-using-1.php debugging-xdebug-using-1.xml debugging-xdebug-using-2.xml
objects-abstract.xml objects-agenda.xml objects-comparision.xml objects-exceptions.xml objects-interfaces.xml objects-intro.xml objects-scope.xml
objects-static.xml title.xml
| From: | Tobias Schlitt | Date: | Sat, 07 Oct 2006 15:48:50 +0000 |
| Subject: | cvs: presentations / php-weekender.xml /slides/php-weekender agenda.xml debugging-agenda.xml debugging-common-pitfalls.xml debugging-external-apd.xml debugging-external-dbg.xml debugging-external-overview.xml debugging-external-xdebug.xml debugging-external-zend.xml debugging-intro.xml debugging-php-1.xml debugging-php-2.xml debugging-php-3.xml debugging-strategies.xml debugging-xdebug-configuration.xml debugging-xdebug-error.jpg debugging-xdebug-installing.xml debugging-xdebug-overview.xml debugging-xdebug-using-1.php debugging-xdebug-using-1.xml debugging-xdebug-using-2.xml objects-abstract.xml objects-agenda.xml objects-comparision.xml objects-exceptions.xml objects-interfaces.xml objects-intro.xml objects-scope.xml objects-static.xml title.xml |
||
| Groups: | php.pres | ||
| Request: | Send a blank email to pres+get-1346@lists.php.net to get a copy of this message | ||
toby Sat Oct 7 15:48:50 2006 UTC
Added files:
/presentations php-weekender.xml
/presentations/slides/php-weekender agenda.xml debugging-agenda.xml
debugging-common-pitfalls.xml
debugging-external-apd.xml
debugging-external-dbg.xml
debugging-external-overview.xml
debugging-external-xdebug.xml
debugging-external-zend.xml
debugging-intro.xml
debugging-php-1.xml
debugging-php-2.xml
debugging-php-3.xml
debugging-strategies.xml
debugging-xdebug-configuration.xml
debugging-xdebug-error.jpg
debugging-xdebug-installing.xml
debugging-xdebug-overview.xml
debugging-xdebug-using-1.php
debugging-xdebug-using-1.xml
debugging-xdebug-using-2.xml
objects-abstract.xml
objects-agenda.xml
objects-comparision.xml
objects-exceptions.xml
objects-interfaces.xml
objects-intro.xml
objects-scope.xml
objects-static.xml title.xml
Log:
- Added talk for PHP Weekender tomorrow.
http://cvs.php.net/viewvc.cgi/presentations/php-weekender.xml?view=markup&rev=1.1 Index: presentations/php-weekender.xml +++ presentations/php-weekender.xml <?xml version="1.0" encoding="iso-8859-1"?> <presentation template="css" navmode="html" navbarbackground="#4373b4" navbartopiclinks="0" navColor="#f1fbff" logo1="" stylesheet="presentations/slides/php-best-practices/talk.css" backgroundfixed="1" > <topic>PHP</topic> <title>PHP Weekender - PHP best practices</title> <event>PHP Weekender</event> <location>Dortmund, Germany</location> <date>October 8th, 2006</date> <speaker>Tobias Schlitt & Kore Nordmann</speaker> <email>ts@ez.no & kn@ez.no</email> <!-- Intro --> <slide>slides/php-weekender/title.xml</slide> <slide>slides/php-best-practices/aboutme-kore.xml</slide> <slide>slides/php-best-practices/aboutme-toby.xml</slide> <slide>slides/php-weekender/agenda.xml</slide> <!-- About this talk --> <slide>slides/php-best-practices/about.xml</slide> <!-- General --> <slide>slides/php-best-practices/general-intro.xml</slide> <slide>slides/php-best-practices/general-agenda.xml</slide> <slide>slides/php-best-practices/general-typesafe1.xml</slide> <slide>slides/php-best-practices/general-typesafe2.xml</slide> <slide>slides/php-best-practices/general-typesafe2.xml</slide> <slide>slides/php-best-practices/general-shortopen.xml</slide> <slide>slides/php-best-practices/general-e_strict.xml</slide> <slide>slides/php-best-practices/general-exceptions.xml</slide> <slide>slides/php-best-practices/general-debugging1.xml</slide> <slide>slides/php-best-practices/general-debugging2.xml</slide> <slide>slides/php-best-practices/general-codingstandard.xml</slide> <slide>slides/php-best-practices/general-documentation.xml</slide> <!-- OOP --> <slide>slides/php-best-practices/objects-intro.xml</slide> <slide>slides/php-best-practices/objects-agenda.xml</slide> <slide>slides/php-best-practices/objects-comparision.xml</slide> <slide>slides/php-best-practices/objects-scope.xml</slide> <slide>slides/php-best-practices/objects-static.xml</slide> <slide>slides/php-best-practices/objects-exceptions.xml</slide> <slide>slides/php-best-practices/objects-abstract.xml</slide> <slide>slides/php-best-practices/objects-interfaces.xml</slide> <!-- Debugging --> <slide>slides/php-weekender/debugging-intro.xml</slide> <slide>slides/php-weekender/debugging-agenda.xml</slide> <slide>slides/php-weekender/debugging-strategies.xml</slide> <slide>slides/php-weekender/debugging-php-1.xml</slide> <slide>slides/php-weekender/debugging-php-2.xml</slide> <slide>slides/php-weekender/debugging-php-3.xml</slide> <slide>slides/php-weekender/debugging-external-overview.xml</slide> <slide>slides/php-weekender/debugging-external-zend.xml</slide> <slide>slides/php-weekender/debugging-external-dbg.xml</slide> <slide>slides/php-weekender/debugging-external-apd.xml</slide> <slide>slides/php-weekender/debugging-external-xdebug.xml</slide> <slide>slides/xdebug/how-to-install.xml</slide> <slide>slides/xdebug/how-to-install2.xml</slide> <slide>slides/xdebug/how-to-install-win.xml</slide> <slide>slides/xdebug/why-crash.xml</slide> <!-- max nesting, function trace --> <slide>slides/xdebug/where-error.xml</slide> <slide>slides/xdebug/debug-req-vars.xml</slide> <slide>slides/xdebug/xdebug-var-dump.xml</slide> <slide>slides/xdebug/how-many-functions.xml</slide> <slide>slides/xdebug/wtf-happens.xml</slide> <slide>slides/xdebug/which-code-do-i-use.xml</slide> <slide>slides/xdebug/profiling.xml</slide> <slide>slides/xdebug/analyse-running-script.xml</slide> <!-- Security --> <slide>slides/php-best-practices/security-intro.xml</slide> <slide>slides/php-best-practices/security-agenda.xml</slide> <slide>slides/php-best-practices/security-variables_1.xml</slide> <slide>slides/php-best-practices/security-variables_2.xml</slide> <slide>slides/php-best-practices/security-sql.xml</slide> <slide>slides/php-best-practices/security-input.xml</slide> <slide>slides/php-best-practices/security-xss.xml</slide> <slide>slides/php-best-practices/security-obscurity.xml</slide> <slide>slides/php-best-practices/security-permissions.xml</slide> <slide>slides/php-best-practices/security-configuration-1.xml</slide> <slide>slides/php-best-practices/security-configuration-2.xml</slide> <slide>slides/php-best-practices/security-cookies.xml</slide> <!-- Performance --> <slide>slides/php-best-practices/performance-intro.xml</slide> <slide>slides/php-best-practices/performance-agenda.xml</slide> <slide>slides/php-best-practices/performance-cvsphp.xml</slide> <slide>slides/php-best-practices/performance-simple.xml</slide> <slide>slides/php-best-practices/performance-oo.xml</slide> <slide>slides/php-best-practices/performance-caching1.xml</slide> <slide>slides/php-best-practices/performance-caching2.xml</slide> <slide>slides/php-best-practices/performance-regex.xml</slide> <slide>slides/php-best-practices/performance-opcodecache1.xml</slide> <slide>slides/php-best-practices/performance-opcodecache2.xml</slide> <slide>slides/php-best-practices/performance-profiling.xml</slide> <slide>slides/php-best-practices/performance-mod_gzip.xml</slide> <!-- Open part --> <slide>slides/php-best-practices/open-intro.xml</slide> <slide>slides/php-best-practices/end.xml</slide> </presentation> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/agenda.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/agenda.xml +++ presentations/slides/php-weekender/agenda.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="6em"> <title>Agenda</title> <list> <bullet>About this talk</bullet> <bullet>General dos and don'ts</bullet> <bullet>OOP in PHP</bullet> <bullet>Debugging</bullet> <bullet>Security</bullet> <bullet>Performance</bullet> <bullet>Open part</bullet> </list> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-agenda.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-agenda.xml +++ presentations/slides/php-weekender/debugging-agenda.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - Agenda</title> <list> <bullet>Debugging strategies</bullet> <bullet>PHP internal debugging methods</bullet> <bullet>Overview on external debuggers</bullet> <bullet>Xdebug - A PHP debugger</bullet> <bullet>Common pitfalls</bullet> </list> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-common-pitfalls.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-common-pitfalls.xml +++ presentations/slides/php-weekender/debugging-common-pitfalls.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - Common pitfalls</title> <blurb>The issue: There exists no bug-free code!</blurb> <blurb>The solution: Debugging is needed.</blurb> <list> <bullet>echo and die</bullet> <bullet>var_dump and print_r</bullet> <bullet>Using an external debugger</bullet> </list> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-external-apd.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-external-apd.xml +++ presentations/slides/php-weekender/debugging-external-apd.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - External</title> <blurb>APD is an open cource debugger by George Schlossnagel</blurb> <list> <bullet>Not maintained since 2004</bullet> <bullet>http://pecl.php.net/package/apd</bullet> </list> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-external-dbg.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-external-dbg.xml +++ presentations/slides/php-weekender/debugging-external-dbg.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - External</title> <blurb>DBG is a commercial debgugger by Dmitri Dmitrienko</blurb> <list> <bullet>Reduced version for free</bullet> <bullet>Provides standard debugging features (break-points, watches,...)</bullet> <bullet>Commercial version has even advanced features and security addons</bullet> <bullet>http://dd.cron.ru/dbg/</bullet> </list> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-external-overview.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-external-overview.xml +++ presentations/slides/php-weekender/debugging-external-overview.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - External</title> <blurb>The issue: PHP offers some small debugging facilities, but...</blurb> <blurb>The solution: ...an external debugger</blurb> <list> <bullet>Zend Studio (commercial)</bullet> <bullet>DBG (half-commercial)</bullet> <bullet>APD (open source)</bullet> <bullet>Xdebug (open source)</bullet> </list> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-external-xdebug.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-external-xdebug.xml +++ presentations/slides/php-weekender/debugging-external-xdebug.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - External</title> <blurb>Xdebug is an open source debugger by Derick Rethans</blurb> <list> <bullet>Actually version 2.0 short before stable release</bullet> <bullet>Provides advances internal PHP functions</bullet> <bullet>Allows tracing</bullet> <bullet>Intergrated profiler</bullet> <bullet>Supports the common GDB and DBGp protocolls for remote communication</bullet> <bullet>No remote IDE supports it, yet (AFAIK)</bullet> <bullet>http://xdebug.org/</bullet> </list> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-external-zend.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-external-zend.xml +++ presentations/slides/php-weekender/debugging-external-zend.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - External</title> <blurb>Zend Studio is a commercial PHP IDE by Zend</blurb> <list> <bullet>Uses Java (cross-platform but slow)</bullet> <bullet>Real IDE features (break-points, documenting, ...)</bullet> <bullet>Can do remote debugging</bullet> <bullet>Will not be developed further, but be made an Eclipse extension</bullet> <bullet>http://www.zend.com/de/products/zend_studio</bullet> </list> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-intro.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-intro.xml +++ presentations/slides/php-weekender/debugging-intro.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - About this section</title> <blurb>What will I learn here?</blurb> <list> <bullet>Debugging with PHP itself</bullet> <bullet>External tools</bullet> </list> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-php-1.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-php-1.xml +++ presentations/slides/php-weekender/debugging-php-1.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - PHP internal</title> <blurb>The simplest way of debugging is adding echo or die calls to your code.</blurb> <blurb>Pros</blurb> <list> <bullet>Easy to add to your code</bullet> <bullet>Fast way to check simple issues</bullet> </list> <blurb>Cons</blurb> <list> <bullet>No environment information</bullet> <bullet>Complex issues need lots of debugging code</bullet> <bullet>No type information for echoed variables</bullet> <bullet>Hard to display complete objects/arrays</bullet> </list> <example result="1"><![CDATA[<?php function foo() { echo "Foo has been called!<br />"; } function bar() { die("Bar has been called!<br />"); } for ($i = 0; $i < 3; $i++) foo(); for ($i = 0; $i < 3; $i++) bar(); ?>]]></example> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-php-2.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-php-2.xml +++ presentations/slides/php-weekender/debugging-php-2.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - PHP internal</title> <blurb>var_dump is your friend! Forget about print_r!</blurb> <blurb>We'll see in a bit, why!</blurb> <blurb>Pros</blurb> <list> <bullet>Easy to add to your code</bullet> <bullet>Fast way to check simple issues</bullet> <bullet>Gives detailed information on dumped variable</bullet> <bullet>Can also view complete objects/arrays</bullet> <bullet>Also provides type information</bullet> </list> <blurb>Cons</blurb> <list> <bullet>No environment information</bullet> <bullet>Complex issues need lots of debugging code</bullet> <bullet>Dumping lots of variables gives lots of code</bullet> </list> <example result="1"><![CDATA[<?php class Foo { private $foo = "abc"; protected $bar = 100; public $baz = "100"; } echo "<pre>"; print_r( new Foo() ); var_dump(new Foo() ); var_dump( array( 1, 2, "foo" => "bar" ) ); echo "</pre>"; ?>]]></example> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-php-3.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-php-3.xml +++ presentations/slides/php-weekender/debugging-php-3.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - PHP internal</title> <blurb>debug_backtrace gives you a context</blurb> <blurb>Pros</blurb> <list> <bullet>Easy to add to your code</bullet> <bullet>Shows you call traces</bullet> <bullet>Gives detailed environment info</bullet> </list> <blurb>Cons</blurb> <list> <bullet>Can produce huge masses of output</bullet> </list> <example result="1"><![CDATA[<?php class Foo { public function __construct( $foo ) { $this->init( $foo, 23 ); } public function init( $foo, $bar ) { echo "Here is $foo, $bar<br/>"; var_dump( debug_backtrace() ); } } echo "<pre>"; $foo = new Foo(); echo "</pre>"; ?>]]></example> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-strategies.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-strategies.xml +++ presentations/slides/php-weekender/debugging-strategies.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - Strategies</title> <blurb>The issue: There exists no bug-free code!</blurb> <blurb>The solution: Debugging is needed.</blurb> <list> <bullet>echo and die</bullet> <bullet>var_dump and print_r</bullet> <bullet>debug_backtrace</bullet> <bullet>Using an external debugger</bullet> </list> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-xdebug-configuration.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-xdebug-configuration.xml +++ presentations/slides/php-weekender/debugging-xdebug-configuration.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - Xdebug</title> <blurb>Xdebug is configured from the php.ini</blurb> <blurb>Important setings are (standard values shown):</blurb> <list> <bullet>xdebug.auto_trace="off"</bullet> <bullet>xdebug.collect_includes="on"</bullet> <bullet>xdebug.collect_params="off"</bullet> <bullet>xdebug.collect_return="off"</bullet> <bullet>xdebug.default_enable="on"</bullet> <bullet>xdebug.show_local_vars=0</bullet> <bullet>xdebug.max_nesting_level=64</bullet> </list> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-xdebug-installing.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-xdebug-installing.xml +++ presentations/slides/php-weekender/debugging-xdebug-installing.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - Xdebug</title> <blurb>Installing Xdebug is easy</blurb> <blurb>For Windows:</blurb> <list> <bullet>Download the latest Xdebug binary from http://xdebug.org</bullet> <bullet>Extract the DLL and put it into your PHP directory</bullet> <bullet>Add the following line to your php.ini</bullet> <bullet>zend_extension_ts="c:/your/php/path/xdebugXXX.dll"</bullet> </list> <blurb>For *nix:</blurb> <list> <bullet>$ pear install pecl/xdbug-beta</bullet> <bullet>Add the following line to your php.ini</bullet> <bullet>zend_extension="/your/path/to/modules/xdebug.so"</bullet> </list> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-xdebug-overview.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-xdebug-overview.xml +++ presentations/slides/php-weekender/debugging-xdebug-overview.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - Xdebug</title> <blurb>If you have xdebug.default_enable="on", you already have something cool:</blurb> <list> <bullet>Installing Xdebug</bullet> <bullet>Using Xdebug</bullet> </list> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-xdebug-using-1.php?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-xdebug-using-1.php +++ presentations/slides/php-weekender/debugging-xdebug-using-1.php <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - Xdebug</title> <blurb></blurb> <blurb>Important setings are (standard values shown):</blurb> <list> <bullet>xdebug.auto_trace="off"</bullet> <bullet>xdebug.collect_includes="on"</bullet> <bullet>xdebug.collect_params="off"</bullet> <bullet>xdebug.collect_return="off"</bullet> <bullet>xdebug.default_enable="on"</bullet> <bullet>xdebug.show_local_vars=0</bullet> <bullet>xdebug.max_nesting_level=64</bullet> </list> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-xdebug-using-1.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-xdebug-using-1.xml +++ presentations/slides/php-weekender/debugging-xdebug-using-1.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - Xdebug</title> <blurb>If you have xdebug.default_enable="on", you already have something cool:</blurb> <image filename="debugging-xdebug-error.jpg" align="center" /> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-xdebug-using-2.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-xdebug-using-2.xml +++ presentations/slides/php-weekender/debugging-xdebug-using-2.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - Xdebug</title> <blurb>Enabling / disabling on the fly:</blurb> <list> <bullet>xdebug_enable()</bullet> <bullet>xdebug_disable()</bullet> <bullet>xdebug_is_enabled()</bullet> </list> <blurb>Tracing:</blurb> <list> <bullet>xdebug_start/stop_trace()</bullet> <bullet>xdebug_get/dump_function_trace()</bullet> <bullet>autotrace: xdebug_get_trace_file()</bullet> <bullet> </list> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/objects-abstract.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/objects-abstract.xml +++ presentations/slides/php-weekender/objects-abstract.xml objects-agenda.xml <slide fontsize="3em"> <title>Objects - Agenda</title> <list> <bullet>Comparision to PHP 4</bullet> <bullet>Scope model</bullet> <bullet>Static</bullet> <bullet>Exceptions</bullet> <bullet>Abstract</bullet> <bullet>Interfaces</bullet> <bullet>SPL</bullet> </list> </slide> <slide fontsize="3em"> <title>Objects - Comparision with PHP 4</title> <blurb>The issue: In PHP 4 object orientation was a mess</blurb> <example result="0"><![CDATA[<?php // To reference an object $object1 = &$object2; function &return_reference( &$object_to_modify ) { // Code } ?>]]></example> <blurb>Everything was copied by default, to reference variables you needed &.</blurb> <blurb>No interfaces, no abstract, no static, no scope model for methods and properties.</blurb> <blurb>The solution: Always use PHP 5</blurb> <example result="1"><![CDATA[<?php $object1 = new stdClass(); $object2 = clone $object1; var_dump( ( $object1 === $object2) ); ?>]]></example> </slide> <slide fontsize="3em"> <title>Objects - Exceptions</title> <blurb>The issue: Exceptions are needed for error handling</blurb> <example result="1"><![CDATA[<?php class CouldNotConnectException extends exception { public function __construct( $server ) { parent::__construct( "Could not connect to server <$server>." ); } } class ExceptionExample { public function connectToServer( $server ) { if ( !($c = @fsockopen( $server, 80, $errno, $errstr, 0.1 ) ) ) { throw new CouldNotConnectException( $server ); } } } $object = new ExceptionExample(); try { $object->connectToServer( 'unavailable' ); } catch ( CouldNotConnectException $e ) { echo 'Cought: ', $e, "\n"; } catch ( Exception $e ) { // Cought another exception } ?>]]></example> <blurb>Exceptions bubble through your code until catched.</blurb> <blurb>Exceptions result in a Fatal Error, if not catched properly.</blurb> </slide> <slide fontsize="3em"> <title>Objects - Interfaces</title> <blurb>The issue: Enforce users to respect method signatures in a class.</blurb> <blurb>Multiple interfaces may be implemented by one class.</blurb> <example result="0"><![CDATA[<?php class RandomClass implements Countable, Iterator { // You need to define all methods requested by the interfaces } ?>]]></example> </slide> <slide fontsize="3em"> <title>Objects - About this section</title> <blurb>What will I learn here?</blurb> <list> <bullet>Objects orientated features in PHP 5</bullet> <bullet>One more reason not to use PHP 4 any more</bullet> <bullet>PHP is ready for object orientated designes</bullet> </list> </slide> <slide fontsize="3em"> <title>Objects - Scope model</title> <blurb>The issue: Prevent user from accessing private object values.</blurb> <example result="1"><![CDATA[<?php class ScopeModel { private $private; protected $protected; public $public = 'public'; public function __construct() { // All properties can be accessed inside class $this->private = 'private'; $this->protected = 'protected'; } } $object = new ScopeModel(); echo $object->public, "\n"; // Would result in a fatal Error // echo $object->private, "\n"; // echo $object->protected, "\n"; ?>]]></example> <blurb>Protected properties and methods can not be accessed by inherited classes.</blurb> </slide> <slide fontsize="3em"> <title>Objects - Static properties and methods</title> <blurb>The issue: Implementing singleton pattern</blurb> <example result="1"><![CDATA[<?php class Singleton { private static $instance; public static $static = 42; public $property; private function __construct() { $this->property = microtime(); } public static function getInstance() { if (!isset(self::$instance)) { self::$instance = new Singleton(); } return self::$instance; } } var_dump( Singleton::getInstance() ); var_dump( Singleton::getInstance() ); ?>]]></example> <blurb>PHP 4 could only simulate a singleton with global variables.</blurb> <blurb>Static properties may be accessed without a class instance.</blurb> <example result="1"><![CDATA[<?php var_dump( Singleton::$static ); ?>]]></example> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/objects-agenda.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/objects-agenda.xml +++ presentations/slides/php-weekender/objects-agenda.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Objects - Agenda</title> <list> <bullet>Comparision to PHP 4</bullet> <bullet>Scope model</bullet> <bullet>Static</bullet> <bullet>Exceptions</bullet> <bullet>Abstract</bullet> <bullet>Interfaces</bullet> <bullet>SPL</bullet> </list> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/objects-comparision.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/objects-comparision.xml +++ presentations/slides/php-weekender/objects-comparision.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Objects - Comparision with PHP 4</title> <blurb>The issue: In PHP 4 object orientation was a mess</blurb> <example result="0"><![CDATA[<?php // To reference an object $object1 = &$object2; function &return_reference( &$object_to_modify ) { // Code } ?>]]></example> <blurb>Everything was copied by default, to reference variables you needed &.</blurb> <blurb>No interfaces, no abstract, no static, no scope model for methods and properties.</blurb> <blurb>The solution: Always use PHP 5</blurb> <example result="1"><![CDATA[<?php $object1 = new stdClass(); $object2 = clone $object1; var_dump( ( $object1 === $object2) ); ?>]]></example> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/objects-exceptions.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/objects-exceptions.xml +++ presentations/slides/php-weekender/objects-exceptions.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Objects - Exceptions</title> <blurb>The issue: Exceptions are needed for error handling</blurb> <example result="1"><![CDATA[<?php class CouldNotConnectException extends exception { public function __construct( $server ) { parent::__construct( "Could not connect to server <$server>." ); } } class ExceptionExample { public function connectToServer( $server ) { if ( !($c = @fsockopen( $server, 80, $errno, $errstr, 0.1 ) ) ) { throw new CouldNotConnectException( $server ); } } } $object = new ExceptionExample(); try { $object->connectToServer( 'unavailable' ); } catch ( CouldNotConnectException $e ) { echo 'Cought: ', $e, "\n"; } catch ( Exception $e ) { // Cought another exception } ?>]]></example> <blurb>Exceptions bubble through your code until catched.</blurb> <blurb>Exceptions result in a Fatal Error, if not catched properly.</blurb> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/objects-interfaces.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/objects-interfaces.xml +++ presentations/slides/php-weekender/objects-interfaces.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Objects - Interfaces</title> <blurb>The issue: Enforce users to respect method signatures in a class.</blurb> <blurb>Multiple interfaces may be implemented by one class.</blurb> <example result="0"><![CDATA[<?php class RandomClass implements Countable, Iterator { // You need to define all methods requested by the interfaces } ?>]]></example> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/objects-intro.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/objects-intro.xml +++ presentations/slides/php-weekender/objects-intro.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Objects - About this section</title> <blurb>What will I learn here?</blurb> <list> <bullet>Objects orientated features in PHP 5</bullet> <bullet>One more reason not to use PHP 4 any more</bullet> <bullet>PHP is ready for object orientated designes</bullet> </list> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/objects-scope.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/objects-scope.xml +++ presentations/slides/php-weekender/objects-scope.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Objects - Scope model</title> <blurb>The issue: Prevent user from accessing private object values.</blurb> <example result="1"><![CDATA[<?php class ScopeModel { private $private; protected $protected; public $public = 'public'; public function __construct() { // All properties can be accessed inside class $this->private = 'private'; $this->protected = 'protected'; } } $object = new ScopeModel(); echo $object->public, "\n"; // Would result in a fatal Error // echo $object->private, "\n"; // echo $object->protected, "\n"; ?>]]></example> <blurb>Protected properties and methods can not be accessed by inherited classes.</blurb> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/objects-static.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/objects-static.xml +++ presentations/slides/php-weekender/objects-static.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Objects - Static properties and methods</title> <blurb>The issue: Implementing singleton pattern</blurb> <example result="1"><![CDATA[<?php class Singleton { private static $instance; public static $static = 42; public $property; private function __construct() { $this->property = microtime(); } public static function getInstance() { if (!isset(self::$instance)) { self::$instance = new Singleton(); } return self::$instance; } } var_dump( Singleton::getInstance() ); var_dump( Singleton::getInstance() ); ?>]]></example> <blurb>PHP 4 could only simulate a singleton with global variables.</blurb> <blurb>Static properties may be accessed without a class instance.</blurb> <example result="1"><![CDATA[<?php var_dump( Singleton::$static ); ?>]]></example> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/title.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/title.xml +++ presentations/slides/php-weekender/title.xml <slide fontsize="3.5em"> <title>Welcome!</title> <break lines="3"/> <blurb class="event">PHP Weekender</blurb> <break/> <blurb class="event">PHP Best Practices</blurb> <break/> <blurb class="event-date">PHP Weekender, Dortmund, Germany</blurb> <break/> <blurb class="event-presenter">Kore Nordmann - &lt;kn@ez.no&gt;</blurb> <break/> <blurb class="event-presenter">Tobias Schlitt - &lt;ts@ez.no&gt;</blurb> </slide>
http://cvs.php.net/viewvc.cgi/presentations/php-weekender.xml?view=markup&rev=1.1 Index: presentations/php-weekender.xml +++ presentations/php-weekender.xml <?xml version="1.0" encoding="iso-8859-1"?> <presentation template="css" navmode="html" navbarbackground="#4373b4" navbartopiclinks="0" navColor="#f1fbff" logo1="" stylesheet="presentations/slides/php-best-practices/talk.css" backgroundfixed="1" > <topic>PHP</topic> <title>PHP Weekender - PHP best practices</title> <event>PHP Weekender</event> <location>Dortmund, Germany</location> <date>October 8th, 2006</date> <speaker>Tobias Schlitt & Kore Nordmann</speaker> <email>ts@ez.no & kn@ez.no</email> <!-- Intro --> <slide>slides/php-weekender/title.xml</slide> <slide>slides/php-best-practices/aboutme-kore.xml</slide> <slide>slides/php-best-practices/aboutme-toby.xml</slide> <slide>slides/php-weekender/agenda.xml</slide> <!-- About this talk --> <slide>slides/php-best-practices/about.xml</slide> <!-- General --> <slide>slides/php-best-practices/general-intro.xml</slide> <slide>slides/php-best-practices/general-agenda.xml</slide> <slide>slides/php-best-practices/general-typesafe1.xml</slide> <slide>slides/php-best-practices/general-typesafe2.xml</slide> <slide>slides/php-best-practices/general-typesafe2.xml</slide> <slide>slides/php-best-practices/general-shortopen.xml</slide> <slide>slides/php-best-practices/general-e_strict.xml</slide> <slide>slides/php-best-practices/general-exceptions.xml</slide> <slide>slides/php-best-practices/general-debugging1.xml</slide> <slide>slides/php-best-practices/general-debugging2.xml</slide> <slide>slides/php-best-practices/general-codingstandard.xml</slide> <slide>slides/php-best-practices/general-documentation.xml</slide> <!-- OOP --> <slide>slides/php-best-practices/objects-intro.xml</slide> <slide>slides/php-best-practices/objects-agenda.xml</slide> <slide>slides/php-best-practices/objects-comparision.xml</slide> <slide>slides/php-best-practices/objects-scope.xml</slide> <slide>slides/php-best-practices/objects-static.xml</slide> <slide>slides/php-best-practices/objects-exceptions.xml</slide> <slide>slides/php-best-practices/objects-abstract.xml</slide> <slide>slides/php-best-practices/objects-interfaces.xml</slide> <!-- Debugging --> <slide>slides/php-weekender/debugging-intro.xml</slide> <slide>slides/php-weekender/debugging-agenda.xml</slide> <slide>slides/php-weekender/debugging-strategies.xml</slide> <slide>slides/php-weekender/debugging-php-1.xml</slide> <slide>slides/php-weekender/debugging-php-2.xml</slide> <slide>slides/php-weekender/debugging-php-3.xml</slide> <slide>slides/php-weekender/debugging-external-overview.xml</slide> <slide>slides/php-weekender/debugging-external-zend.xml</slide> <slide>slides/php-weekender/debugging-external-dbg.xml</slide> <slide>slides/php-weekender/debugging-external-apd.xml</slide> <slide>slides/php-weekender/debugging-external-xdebug.xml</slide> <slide>slides/xdebug/how-to-install.xml</slide> <slide>slides/xdebug/how-to-install2.xml</slide> <slide>slides/xdebug/how-to-install-win.xml</slide> <slide>slides/xdebug/why-crash.xml</slide> <!-- max nesting, function trace --> <slide>slides/xdebug/where-error.xml</slide> <slide>slides/xdebug/debug-req-vars.xml</slide> <slide>slides/xdebug/xdebug-var-dump.xml</slide> <slide>slides/xdebug/how-many-functions.xml</slide> <slide>slides/xdebug/wtf-happens.xml</slide> <slide>slides/xdebug/which-code-do-i-use.xml</slide> <slide>slides/xdebug/profiling.xml</slide> <slide>slides/xdebug/analyse-running-script.xml</slide> <!-- Security --> <slide>slides/php-best-practices/security-intro.xml</slide> <slide>slides/php-best-practices/security-agenda.xml</slide> <slide>slides/php-best-practices/security-variables_1.xml</slide> <slide>slides/php-best-practices/security-variables_2.xml</slide> <slide>slides/php-best-practices/security-sql.xml</slide> <slide>slides/php-best-practices/security-input.xml</slide> <slide>slides/php-best-practices/security-xss.xml</slide> <slide>slides/php-best-practices/security-obscurity.xml</slide> <slide>slides/php-best-practices/security-permissions.xml</slide> <slide>slides/php-best-practices/security-configuration-1.xml</slide> <slide>slides/php-best-practices/security-configuration-2.xml</slide> <slide>slides/php-best-practices/security-cookies.xml</slide> <!-- Performance --> <slide>slides/php-best-practices/performance-intro.xml</slide> <slide>slides/php-best-practices/performance-agenda.xml</slide> <slide>slides/php-best-practices/performance-cvsphp.xml</slide> <slide>slides/php-best-practices/performance-simple.xml</slide> <slide>slides/php-best-practices/performance-oo.xml</slide> <slide>slides/php-best-practices/performance-caching1.xml</slide> <slide>slides/php-best-practices/performance-caching2.xml</slide> <slide>slides/php-best-practices/performance-regex.xml</slide> <slide>slides/php-best-practices/performance-opcodecache1.xml</slide> <slide>slides/php-best-practices/performance-opcodecache2.xml</slide> <slide>slides/php-best-practices/performance-profiling.xml</slide> <slide>slides/php-best-practices/performance-mod_gzip.xml</slide> <!-- Open part --> <slide>slides/php-best-practices/open-intro.xml</slide> <slide>slides/php-best-practices/end.xml</slide> </presentation> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/agenda.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/agenda.xml +++ presentations/slides/php-weekender/agenda.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="6em"> <title>Agenda</title> <list> <bullet>About this talk</bullet> <bullet>General dos and don'ts</bullet> <bullet>OOP in PHP</bullet> <bullet>Debugging</bullet> <bullet>Security</bullet> <bullet>Performance</bullet> <bullet>Open part</bullet> </list> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-agenda.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-agenda.xml +++ presentations/slides/php-weekender/debugging-agenda.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - Agenda</title> <list> <bullet>Debugging strategies</bullet> <bullet>PHP internal debugging methods</bullet> <bullet>Overview on external debuggers</bullet> <bullet>Xdebug - A PHP debugger</bullet> <bullet>Common pitfalls</bullet> </list> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-common-pitfalls.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-common-pitfalls.xml +++ presentations/slides/php-weekender/debugging-common-pitfalls.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - Common pitfalls</title> <blurb>The issue: There exists no bug-free code!</blurb> <blurb>The solution: Debugging is needed.</blurb> <list> <bullet>echo and die</bullet> <bullet>var_dump and print_r</bullet> <bullet>Using an external debugger</bullet> </list> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-external-apd.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-external-apd.xml +++ presentations/slides/php-weekender/debugging-external-apd.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - External</title> <blurb>APD is an open cource debugger by George Schlossnagel</blurb> <list> <bullet>Not maintained since 2004</bullet> <bullet>http://pecl.php.net/package/apd</bullet> </list> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-external-dbg.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-external-dbg.xml +++ presentations/slides/php-weekender/debugging-external-dbg.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - External</title> <blurb>DBG is a commercial debgugger by Dmitri Dmitrienko</blurb> <list> <bullet>Reduced version for free</bullet> <bullet>Provides standard debugging features (break-points, watches,...)</bullet> <bullet>Commercial version has even advanced features and security addons</bullet> <bullet>http://dd.cron.ru/dbg/</bullet> </list> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-external-overview.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-external-overview.xml +++ presentations/slides/php-weekender/debugging-external-overview.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - External</title> <blurb>The issue: PHP offers some small debugging facilities, but...</blurb> <blurb>The solution: ...an external debugger</blurb> <list> <bullet>Zend Studio (commercial)</bullet> <bullet>DBG (half-commercial)</bullet> <bullet>APD (open source)</bullet> <bullet>Xdebug (open source)</bullet> </list> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-external-xdebug.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-external-xdebug.xml +++ presentations/slides/php-weekender/debugging-external-xdebug.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - External</title> <blurb>Xdebug is an open source debugger by Derick Rethans</blurb> <list> <bullet>Actually version 2.0 short before stable release</bullet> <bullet>Provides advances internal PHP functions</bullet> <bullet>Allows tracing</bullet> <bullet>Intergrated profiler</bullet> <bullet>Supports the common GDB and DBGp protocolls for remote communication</bullet> <bullet>No remote IDE supports it, yet (AFAIK)</bullet> <bullet>http://xdebug.org/</bullet> </list> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-external-zend.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-external-zend.xml +++ presentations/slides/php-weekender/debugging-external-zend.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - External</title> <blurb>Zend Studio is a commercial PHP IDE by Zend</blurb> <list> <bullet>Uses Java (cross-platform but slow)</bullet> <bullet>Real IDE features (break-points, documenting, ...)</bullet> <bullet>Can do remote debugging</bullet> <bullet>Will not be developed further, but be made an Eclipse extension</bullet> <bullet>http://www.zend.com/de/products/zend_studio</bullet> </list> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-intro.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-intro.xml +++ presentations/slides/php-weekender/debugging-intro.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - About this section</title> <blurb>What will I learn here?</blurb> <list> <bullet>Debugging with PHP itself</bullet> <bullet>External tools</bullet> </list> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-php-1.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-php-1.xml +++ presentations/slides/php-weekender/debugging-php-1.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - PHP internal</title> <blurb>The simplest way of debugging is adding echo or die calls to your code.</blurb> <blurb>Pros</blurb> <list> <bullet>Easy to add to your code</bullet> <bullet>Fast way to check simple issues</bullet> </list> <blurb>Cons</blurb> <list> <bullet>No environment information</bullet> <bullet>Complex issues need lots of debugging code</bullet> <bullet>No type information for echoed variables</bullet> <bullet>Hard to display complete objects/arrays</bullet> </list> <example result="1"><![CDATA[<?php function foo() { echo "Foo has been called!<br />"; } function bar() { die("Bar has been called!<br />"); } for ($i = 0; $i < 3; $i++) foo(); for ($i = 0; $i < 3; $i++) bar(); ?>]]></example> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-php-2.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-php-2.xml +++ presentations/slides/php-weekender/debugging-php-2.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - PHP internal</title> <blurb>var_dump is your friend! Forget about print_r!</blurb> <blurb>We'll see in a bit, why!</blurb> <blurb>Pros</blurb> <list> <bullet>Easy to add to your code</bullet> <bullet>Fast way to check simple issues</bullet> <bullet>Gives detailed information on dumped variable</bullet> <bullet>Can also view complete objects/arrays</bullet> <bullet>Also provides type information</bullet> </list> <blurb>Cons</blurb> <list> <bullet>No environment information</bullet> <bullet>Complex issues need lots of debugging code</bullet> <bullet>Dumping lots of variables gives lots of code</bullet> </list> <example result="1"><![CDATA[<?php class Foo { private $foo = "abc"; protected $bar = 100; public $baz = "100"; } echo "<pre>"; print_r( new Foo() ); var_dump(new Foo() ); var_dump( array( 1, 2, "foo" => "bar" ) ); echo "</pre>"; ?>]]></example> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-php-3.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-php-3.xml +++ presentations/slides/php-weekender/debugging-php-3.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - PHP internal</title> <blurb>debug_backtrace gives you a context</blurb> <blurb>Pros</blurb> <list> <bullet>Easy to add to your code</bullet> <bullet>Shows you call traces</bullet> <bullet>Gives detailed environment info</bullet> </list> <blurb>Cons</blurb> <list> <bullet>Can produce huge masses of output</bullet> </list> <example result="1"><![CDATA[<?php class Foo { public function __construct( $foo ) { $this->init( $foo, 23 ); } public function init( $foo, $bar ) { echo "Here is $foo, $bar<br/>"; var_dump( debug_backtrace() ); } } echo "<pre>"; $foo = new Foo(); echo "</pre>"; ?>]]></example> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-strategies.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-strategies.xml +++ presentations/slides/php-weekender/debugging-strategies.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - Strategies</title> <blurb>The issue: There exists no bug-free code!</blurb> <blurb>The solution: Debugging is needed.</blurb> <list> <bullet>echo and die</bullet> <bullet>var_dump and print_r</bullet> <bullet>debug_backtrace</bullet> <bullet>Using an external debugger</bullet> </list> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-xdebug-configuration.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-xdebug-configuration.xml +++ presentations/slides/php-weekender/debugging-xdebug-configuration.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - Xdebug</title> <blurb>Xdebug is configured from the php.ini</blurb> <blurb>Important setings are (standard values shown):</blurb> <list> <bullet>xdebug.auto_trace="off"</bullet> <bullet>xdebug.collect_includes="on"</bullet> <bullet>xdebug.collect_params="off"</bullet> <bullet>xdebug.collect_return="off"</bullet> <bullet>xdebug.default_enable="on"</bullet> <bullet>xdebug.show_local_vars=0</bullet> <bullet>xdebug.max_nesting_level=64</bullet> </list> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-xdebug-installing.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-xdebug-installing.xml +++ presentations/slides/php-weekender/debugging-xdebug-installing.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - Xdebug</title> <blurb>Installing Xdebug is easy</blurb> <blurb>For Windows:</blurb> <list> <bullet>Download the latest Xdebug binary from http://xdebug.org</bullet> <bullet>Extract the DLL and put it into your PHP directory</bullet> <bullet>Add the following line to your php.ini</bullet> <bullet>zend_extension_ts="c:/your/php/path/xdebugXXX.dll"</bullet> </list> <blurb>For *nix:</blurb> <list> <bullet>$ pear install pecl/xdbug-beta</bullet> <bullet>Add the following line to your php.ini</bullet> <bullet>zend_extension="/your/path/to/modules/xdebug.so"</bullet> </list> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-xdebug-overview.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-xdebug-overview.xml +++ presentations/slides/php-weekender/debugging-xdebug-overview.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - Xdebug</title> <blurb>If you have xdebug.default_enable="on", you already have something cool:</blurb> <list> <bullet>Installing Xdebug</bullet> <bullet>Using Xdebug</bullet> </list> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-xdebug-using-1.php?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-xdebug-using-1.php +++ presentations/slides/php-weekender/debugging-xdebug-using-1.php <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - Xdebug</title> <blurb></blurb> <blurb>Important setings are (standard values shown):</blurb> <list> <bullet>xdebug.auto_trace="off"</bullet> <bullet>xdebug.collect_includes="on"</bullet> <bullet>xdebug.collect_params="off"</bullet> <bullet>xdebug.collect_return="off"</bullet> <bullet>xdebug.default_enable="on"</bullet> <bullet>xdebug.show_local_vars=0</bullet> <bullet>xdebug.max_nesting_level=64</bullet> </list> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-xdebug-using-1.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-xdebug-using-1.xml +++ presentations/slides/php-weekender/debugging-xdebug-using-1.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - Xdebug</title> <blurb>If you have xdebug.default_enable="on", you already have something cool:</blurb> <image filename="debugging-xdebug-error.jpg" align="center" /> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/debugging-xdebug-using-2.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/debugging-xdebug-using-2.xml +++ presentations/slides/php-weekender/debugging-xdebug-using-2.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Debugging - Xdebug</title> <blurb>Enabling / disabling on the fly:</blurb> <list> <bullet>xdebug_enable()</bullet> <bullet>xdebug_disable()</bullet> <bullet>xdebug_is_enabled()</bullet> </list> <blurb>Tracing:</blurb> <list> <bullet>xdebug_start/stop_trace()</bullet> <bullet>xdebug_get/dump_function_trace()</bullet> <bullet>autotrace: xdebug_get_trace_file()</bullet> <bullet> </list> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/objects-abstract.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/objects-abstract.xml +++ presentations/slides/php-weekender/objects-abstract.xml objects-agenda.xml <slide fontsize="3em"> <title>Objects - Agenda</title> <list> <bullet>Comparision to PHP 4</bullet> <bullet>Scope model</bullet> <bullet>Static</bullet> <bullet>Exceptions</bullet> <bullet>Abstract</bullet> <bullet>Interfaces</bullet> <bullet>SPL</bullet> </list> </slide> <slide fontsize="3em"> <title>Objects - Comparision with PHP 4</title> <blurb>The issue: In PHP 4 object orientation was a mess</blurb> <example result="0"><![CDATA[<?php // To reference an object $object1 = &$object2; function &return_reference( &$object_to_modify ) { // Code } ?>]]></example> <blurb>Everything was copied by default, to reference variables you needed &.</blurb> <blurb>No interfaces, no abstract, no static, no scope model for methods and properties.</blurb> <blurb>The solution: Always use PHP 5</blurb> <example result="1"><![CDATA[<?php $object1 = new stdClass(); $object2 = clone $object1; var_dump( ( $object1 === $object2) ); ?>]]></example> </slide> <slide fontsize="3em"> <title>Objects - Exceptions</title> <blurb>The issue: Exceptions are needed for error handling</blurb> <example result="1"><![CDATA[<?php class CouldNotConnectException extends exception { public function __construct( $server ) { parent::__construct( "Could not connect to server <$server>." ); } } class ExceptionExample { public function connectToServer( $server ) { if ( !($c = @fsockopen( $server, 80, $errno, $errstr, 0.1 ) ) ) { throw new CouldNotConnectException( $server ); } } } $object = new ExceptionExample(); try { $object->connectToServer( 'unavailable' ); } catch ( CouldNotConnectException $e ) { echo 'Cought: ', $e, "\n"; } catch ( Exception $e ) { // Cought another exception } ?>]]></example> <blurb>Exceptions bubble through your code until catched.</blurb> <blurb>Exceptions result in a Fatal Error, if not catched properly.</blurb> </slide> <slide fontsize="3em"> <title>Objects - Interfaces</title> <blurb>The issue: Enforce users to respect method signatures in a class.</blurb> <blurb>Multiple interfaces may be implemented by one class.</blurb> <example result="0"><![CDATA[<?php class RandomClass implements Countable, Iterator { // You need to define all methods requested by the interfaces } ?>]]></example> </slide> <slide fontsize="3em"> <title>Objects - About this section</title> <blurb>What will I learn here?</blurb> <list> <bullet>Objects orientated features in PHP 5</bullet> <bullet>One more reason not to use PHP 4 any more</bullet> <bullet>PHP is ready for object orientated designes</bullet> </list> </slide> <slide fontsize="3em"> <title>Objects - Scope model</title> <blurb>The issue: Prevent user from accessing private object values.</blurb> <example result="1"><![CDATA[<?php class ScopeModel { private $private; protected $protected; public $public = 'public'; public function __construct() { // All properties can be accessed inside class $this->private = 'private'; $this->protected = 'protected'; } } $object = new ScopeModel(); echo $object->public, "\n"; // Would result in a fatal Error // echo $object->private, "\n"; // echo $object->protected, "\n"; ?>]]></example> <blurb>Protected properties and methods can not be accessed by inherited classes.</blurb> </slide> <slide fontsize="3em"> <title>Objects - Static properties and methods</title> <blurb>The issue: Implementing singleton pattern</blurb> <example result="1"><![CDATA[<?php class Singleton { private static $instance; public static $static = 42; public $property; private function __construct() { $this->property = microtime(); } public static function getInstance() { if (!isset(self::$instance)) { self::$instance = new Singleton(); } return self::$instance; } } var_dump( Singleton::getInstance() ); var_dump( Singleton::getInstance() ); ?>]]></example> <blurb>PHP 4 could only simulate a singleton with global variables.</blurb> <blurb>Static properties may be accessed without a class instance.</blurb> <example result="1"><![CDATA[<?php var_dump( Singleton::$static ); ?>]]></example> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/objects-agenda.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/objects-agenda.xml +++ presentations/slides/php-weekender/objects-agenda.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Objects - Agenda</title> <list> <bullet>Comparision to PHP 4</bullet> <bullet>Scope model</bullet> <bullet>Static</bullet> <bullet>Exceptions</bullet> <bullet>Abstract</bullet> <bullet>Interfaces</bullet> <bullet>SPL</bullet> </list> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/objects-comparision.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/objects-comparision.xml +++ presentations/slides/php-weekender/objects-comparision.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Objects - Comparision with PHP 4</title> <blurb>The issue: In PHP 4 object orientation was a mess</blurb> <example result="0"><![CDATA[<?php // To reference an object $object1 = &$object2; function &return_reference( &$object_to_modify ) { // Code } ?>]]></example> <blurb>Everything was copied by default, to reference variables you needed &.</blurb> <blurb>No interfaces, no abstract, no static, no scope model for methods and properties.</blurb> <blurb>The solution: Always use PHP 5</blurb> <example result="1"><![CDATA[<?php $object1 = new stdClass(); $object2 = clone $object1; var_dump( ( $object1 === $object2) ); ?>]]></example> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/objects-exceptions.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/objects-exceptions.xml +++ presentations/slides/php-weekender/objects-exceptions.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Objects - Exceptions</title> <blurb>The issue: Exceptions are needed for error handling</blurb> <example result="1"><![CDATA[<?php class CouldNotConnectException extends exception { public function __construct( $server ) { parent::__construct( "Could not connect to server <$server>." ); } } class ExceptionExample { public function connectToServer( $server ) { if ( !($c = @fsockopen( $server, 80, $errno, $errstr, 0.1 ) ) ) { throw new CouldNotConnectException( $server ); } } } $object = new ExceptionExample(); try { $object->connectToServer( 'unavailable' ); } catch ( CouldNotConnectException $e ) { echo 'Cought: ', $e, "\n"; } catch ( Exception $e ) { // Cought another exception } ?>]]></example> <blurb>Exceptions bubble through your code until catched.</blurb> <blurb>Exceptions result in a Fatal Error, if not catched properly.</blurb> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/objects-interfaces.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/objects-interfaces.xml +++ presentations/slides/php-weekender/objects-interfaces.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Objects - Interfaces</title> <blurb>The issue: Enforce users to respect method signatures in a class.</blurb> <blurb>Multiple interfaces may be implemented by one class.</blurb> <example result="0"><![CDATA[<?php class RandomClass implements Countable, Iterator { // You need to define all methods requested by the interfaces } ?>]]></example> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/objects-intro.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/objects-intro.xml +++ presentations/slides/php-weekender/objects-intro.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Objects - About this section</title> <blurb>What will I learn here?</blurb> <list> <bullet>Objects orientated features in PHP 5</bullet> <bullet>One more reason not to use PHP 4 any more</bullet> <bullet>PHP is ready for object orientated designes</bullet> </list> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/objects-scope.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/objects-scope.xml +++ presentations/slides/php-weekender/objects-scope.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Objects - Scope model</title> <blurb>The issue: Prevent user from accessing private object values.</blurb> <example result="1"><![CDATA[<?php class ScopeModel { private $private; protected $protected; public $public = 'public'; public function __construct() { // All properties can be accessed inside class $this->private = 'private'; $this->protected = 'protected'; } } $object = new ScopeModel(); echo $object->public, "\n"; // Would result in a fatal Error // echo $object->private, "\n"; // echo $object->protected, "\n"; ?>]]></example> <blurb>Protected properties and methods can not be accessed by inherited classes.</blurb> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/objects-static.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/objects-static.xml +++ presentations/slides/php-weekender/objects-static.xml <?xml version="1.0" encoding="iso-8859-1"?> <slide fontsize="3em"> <title>Objects - Static properties and methods</title> <blurb>The issue: Implementing singleton pattern</blurb> <example result="1"><![CDATA[<?php class Singleton { private static $instance; public static $static = 42; public $property; private function __construct() { $this->property = microtime(); } public static function getInstance() { if (!isset(self::$instance)) { self::$instance = new Singleton(); } return self::$instance; } } var_dump( Singleton::getInstance() ); var_dump( Singleton::getInstance() ); ?>]]></example> <blurb>PHP 4 could only simulate a singleton with global variables.</blurb> <blurb>Static properties may be accessed without a class instance.</blurb> <example result="1"><![CDATA[<?php var_dump( Singleton::$static ); ?>]]></example> </slide> http://cvs.php.net/viewvc.cgi/presentations/slides/php-weekender/title.xml?view=markup&rev=1.1 Index: presentations/slides/php-weekender/title.xml +++ presentations/slides/php-weekender/title.xml <slide fontsize="3.5em"> <title>Welcome!</title> <break lines="3"/> <blurb class="event">PHP Weekender</blurb> <break/> <blurb class="event">PHP Best Practices</blurb> <break/> <blurb class="event-date">PHP Weekender, Dortmund, Germany</blurb> <break/> <blurb class="event-presenter">Kore Nordmann - &lt;kn@ez.no&gt;</blurb> <break/> <blurb class="event-presenter">Tobias Schlitt - &lt;ts@ez.no&gt;</blurb> </slide>