From ceb45bcb4a90930c85f17a1505002a14819c12d6 Mon Sep 17 00:00:00 2001 From: Steven Benner Date: Wed, 11 Jul 2012 19:52:26 -0700 Subject: [PATCH 01/19] Added object caching sub-section. --- _posts/10-03-01-Object-Caching.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 _posts/10-03-01-Object-Caching.md diff --git a/_posts/10-03-01-Object-Caching.md b/_posts/10-03-01-Object-Caching.md new file mode 100644 index 0000000..3fa94d9 --- /dev/null +++ b/_posts/10-03-01-Object-Caching.md @@ -0,0 +1,29 @@ +--- +isChild: true +--- + +## Object Caching + +There are times when it is advantageous to cache individual objects in your code, such as with data that is expensive to get or database calls where the result is unlikely to change. You can use object caching software to hold pieces of data in memory for extremely fast access later on. If you save these items in a data store after you get them then access the data for following requests from cache you will see significant performance increases and reduced load on your database servers. + +The most common memory object caching systems are APC and memcached. APC is a great choice for caching, it comes with PHP and is very easy to setup and to use, but it is tied to the server it is installed on. Memcached on the other hand is installed as a separate service and can be accessed across the network, meaning that you can store values in a hyper-fast data store in a central location and many different systems can pull from it. In a networked configuration APC will outperform memcached in terms of access speed, but memcached will be able to scale up faster and further. + +Example logic using APC: + +{% highlight php %} + Date: Thu, 12 Jul 2012 01:27:43 -0700 Subject: [PATCH 02/19] Wrap text to 120 characters. --- _posts/10-03-01-Object-Caching.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/_posts/10-03-01-Object-Caching.md b/_posts/10-03-01-Object-Caching.md index 3fa94d9..c366dc0 100644 --- a/_posts/10-03-01-Object-Caching.md +++ b/_posts/10-03-01-Object-Caching.md @@ -4,9 +4,17 @@ isChild: true ## Object Caching -There are times when it is advantageous to cache individual objects in your code, such as with data that is expensive to get or database calls where the result is unlikely to change. You can use object caching software to hold pieces of data in memory for extremely fast access later on. If you save these items in a data store after you get them then access the data for following requests from cache you will see significant performance increases and reduced load on your database servers. +There are times when it is advantageous to cache individual objects in your code, such as with data that is expensive to +get or database calls where the result is unlikely to change. You can use object caching software to hold pieces of data +in memory for extremely fast access later on. If you save these items in a data store after you get them then access the +data for following requests from cache you will see significant performance increases and reduced load on your database +servers. -The most common memory object caching systems are APC and memcached. APC is a great choice for caching, it comes with PHP and is very easy to setup and to use, but it is tied to the server it is installed on. Memcached on the other hand is installed as a separate service and can be accessed across the network, meaning that you can store values in a hyper-fast data store in a central location and many different systems can pull from it. In a networked configuration APC will outperform memcached in terms of access speed, but memcached will be able to scale up faster and further. +The most common memory object caching systems are APC and memcached. APC is a great choice for caching, it comes with +PHP and is very easy to setup and to use, but it is tied to the server it is installed on. Memcached on the other hand +is installed as a separate service and can be accessed across the network, meaning that you can store values in a +hyper-fast data store in a central location and many different systems can pull from it. In a networked configuration +APC will outperform memcached in terms of access speed, but memcached will be able to scale up faster and further. Example logic using APC: From e8bd3abcced64fcaa6b23e7d0ac1d6d872fcdfea Mon Sep 17 00:00:00 2001 From: Goran Rakic Date: Thu, 12 Jul 2012 14:28:21 +0200 Subject: [PATCH 03/19] Small fixes --- _posts/07-04-01-Data-Filtering.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/_posts/07-04-01-Data-Filtering.md b/_posts/07-04-01-Data-Filtering.md index 5534a0b..afc9f52 100644 --- a/_posts/07-04-01-Data-Filtering.md +++ b/_posts/07-04-01-Data-Filtering.md @@ -11,25 +11,25 @@ PHP functions `filter_var` and `filter_input` can sanitize text and validate tex email addresses). Foreign input can be anything, from `$_GET` and `$_POST` form input data, some values in `$_SERVER`, -the HTTP body via `fopen('php://input', 'r')`, etc are all considered foriegn inputs. It is not +the HTTP body via `fopen('php://input', 'r')`, etc are all considered foreign inputs. It is not limited to form data submitted by the user, both uploaded and downloaded files, session values and -cookies count too. +cookies count too. Data from third party web services should also be considered foreign input. While foreign data can be stored, combined and accessed later, it is still a foreign input. Every time you process, output, concatenate or include some data in your code you should ask yourself if the data is filtered properly and can it be trusted. -Filtering is tailored to the specific data usage. For example, when including foreign input is passed -to a HTML page output it can execute HTML and JavaScript on your site! This is known as Cross-Site +Filtering is tailored to the specific data usage. For example, when foreign input is passed +to a HTML page output it can execute HTML and JavaScript on your site! This is known as Cross-Site Scripting (XSS) and can be a very dangerous attack. One way to avoid this is to sanitize all HTML tags -in the input, or encode them. +in the input, removing tags or escaping them. That is of course one instance of filtering against a specific type of attach. Another example would be -when passing options to be executed on the command line. This can be extremely dangers and is usually bad +when passing options to be executed on the command line. This can be extremely dangerous and is usually bad idea, but you can use the built-in `escapeshellarg` function to sanitize the arguments. One last example would be accepting foreign input to determine a file to load. This could be expoited by -changing the filename to a file path, so you need to remove and / from the path, so it cant load potentially +changing the filename to a file path, so you need to remove / or other characters from the path, so it cant load potentially hidden or sensitive files. For performance, you can store filtered data and have it ready for usage next time. Just remember From 4749b951a302bde4d8bdd616cbece76f676000a1 Mon Sep 17 00:00:00 2001 From: Goran Rakic Date: Thu, 12 Jul 2012 15:21:38 +0200 Subject: [PATCH 04/19] Place Credits in TOC --- _layouts/default.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/_layouts/default.html b/_layouts/default.html index 2717256..190607f 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -39,6 +39,7 @@
  • {{ post.title }} {% assign lastIsChild = post.isChild %} {% endfor %} +
  • Credits
  • @@ -55,7 +56,7 @@ {{ content }} -
    +

    Created and maintained by

    • Josh Lockhart
    • From f662a0152d4d53543b6ab182db91f39b11866a16 Mon Sep 17 00:00:00 2001 From: = Date: Thu, 12 Jul 2012 10:22:50 -0400 Subject: [PATCH 05/19] Tweak data filtering section intro --- _posts/07-04-01-Data-Filtering.md | 39 ++++++++++++++----------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/_posts/07-04-01-Data-Filtering.md b/_posts/07-04-01-Data-Filtering.md index afc9f52..524c655 100644 --- a/_posts/07-04-01-Data-Filtering.md +++ b/_posts/07-04-01-Data-Filtering.md @@ -5,35 +5,30 @@ isChild: true ## Data Filtering Never ever (ever) trust foreign input introduced to your PHP code. Always sanitize and validate -foreign input before using it in code. - -PHP functions `filter_var` and `filter_input` can sanitize text and validate text formats (e.g. +foreign input before using it in code. The `filter_var` and `filter_input` functions can sanitize text and validate text formats (e.g. email addresses). -Foreign input can be anything, from `$_GET` and `$_POST` form input data, some values in `$_SERVER`, -the HTTP body via `fopen('php://input', 'r')`, etc are all considered foreign inputs. It is not -limited to form data submitted by the user, both uploaded and downloaded files, session values and -cookies count too. Data from third party web services should also be considered foreign input. +Foreign input can be anything: `$_GET` and `$_POST` form input data, some values in the `$_SERVER` +superglobal, and the HTTP request body via `fopen('php://input', 'r')`. Remember, foreign input is not +limited to form data submitted by the user. Uploaded and downloaded files, session values, cookie data, +and data from third-party web services are foreign input, too. -While foreign data can be stored, combined and accessed later, it is still a foreign input. Every -time you process, output, concatenate or include some data in your code you should ask yourself if +While foreign data can be stored, combined, and accessed later, it is still foreign input. Every +time you process, output, concatenate, or include data in your code, ask yourself if the data is filtered properly and can it be trusted. -Filtering is tailored to the specific data usage. For example, when foreign input is passed -to a HTML page output it can execute HTML and JavaScript on your site! This is known as Cross-Site -Scripting (XSS) and can be a very dangerous attack. One way to avoid this is to sanitize all HTML tags -in the input, removing tags or escaping them. +Data may be _filtered_ differently based on its purpose. For example, when unfiltered foreign input is passed +into HTML page output, it can execute HTML and JavaScript on your site! This is known as Cross-Site +Scripting (XSS) and can be a very dangerous attack. One way to avoid XSS is to sanitize all HTML tags +in the input by removing tags or escaping them into HTML entities. -That is of course one instance of filtering against a specific type of attach. Another example would be -when passing options to be executed on the command line. This can be extremely dangerous and is usually bad -idea, but you can use the built-in `escapeshellarg` function to sanitize the arguments. +Another example is passing options to be executed on the command line. This can be extremely dangerous +(and is usually a bad idea), but you can use the built-in `escapeshellarg` function to sanitize the executed +command's arguments. -One last example would be accepting foreign input to determine a file to load. This could be expoited by -changing the filename to a file path, so you need to remove / or other characters from the path, so it cant load potentially -hidden or sensitive files. - -For performance, you can store filtered data and have it ready for usage next time. Just remember -that data filtered for one kind of the output may not be sufficiently filtered for the other. +One last example is accepting foreign input to determine a file to load from the filesystem. This can be exploited by +changing the filename to a file path. You need to remove "/", "../", or other characters from the file path so it can't +load hidden, non-public, or sensitive files. * [Learn about data filtering][1] * [Learn about `filter_var`][4] From 0e1b4505e3967d46c938bd60b214ba146d0d61e6 Mon Sep 17 00:00:00 2001 From: = Date: Thu, 12 Jul 2012 10:56:18 -0400 Subject: [PATCH 06/19] Load contributors from GitHub API --- _layouts/default.html | 6 +++--- scripts/setup.js | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 scripts/setup.js diff --git a/_layouts/default.html b/_layouts/default.html index 190607f..7bcd73c 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -69,9 +69,7 @@

    Project contributors

    -

    - This project would not be possible without the help of our amazing contributors on GitHub. -

    +
    Loading…

    Project sponsors

      @@ -85,5 +83,7 @@
    + + diff --git a/scripts/setup.js b/scripts/setup.js new file mode 100644 index 0000000..cbab838 --- /dev/null +++ b/scripts/setup.js @@ -0,0 +1,26 @@ +(function ($) { + // Load contributors + var $contributors = $('#contributors'); + if ( $contributors.length ) { + var fail = function () { + $contributors.html('

    This project would not be possible without the help of our amazing contributors on GitHub.

    '); + }; + $.ajax({ + cache: false, + dataType: 'jsonp', + timeout: 3000, + type: 'GET', + url: 'https://api.github.com/repos/codeguy/php-the-right-way/contributors' + }).done(function (data) { + if ( data.data && data.data.length ) { + var $ul = $('
      '), dataLength = data.data.length; + for ( var i = 0; i < dataLength; i++ ) { + $ul.append(['
    • ', data.data[i].login, '
    • '].join('')); + } + $contributors.html($ul); + } else { + fail(); + } + }).fail(fail); + } +})(jQuery); From d022e6b2011102f73aedbc7f85f719963e622e74 Mon Sep 17 00:00:00 2001 From: Jarrod Nettles Date: Thu, 12 Jul 2012 10:32:14 -0500 Subject: [PATCH 07/19] Added some general information on the differences between Composer and PEAR, and that in general, Composer is for single projects and PEAR is s ystem-wide. --- _posts/04-01-01-Dependency-Management.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/_posts/04-01-01-Dependency-Management.md b/_posts/04-01-01-Dependency-Management.md index 46f0d9e..1c414c8 100644 --- a/_posts/04-01-01-Dependency-Management.md +++ b/_posts/04-01-01-Dependency-Management.md @@ -1,3 +1,10 @@ # Dependency Management There are a ton of PHP libraries, frameworks, and components to choose from. Your project will likely use several of them — these are project dependencies. Until recently, PHP did not have a good way to manage these project dependencies. Even if you managed them manually, you still had to worry about autoloaders. No more. + +Currently there are two major package management systems for PHP - Composer and PEAR. Which one is right for you? The answer is both. + + * Use **Composer** when managing dependencies for a single project. + * Use **PEAR** when managing dependencies for PHP as a whole on your system. + +In general, Composer packages will be available only in the projects that you explicitly specify whereas a PEAR package would be available to all of your PHP projects. While PEAR might sound like the easier approach at first glance, there are advantages to using a project-by-project approach to your dependencies. From fcfd4987b0343234640d0f668254aa36666e684c Mon Sep 17 00:00:00 2001 From: Jarrod Nettles Date: Thu, 12 Jul 2012 10:32:14 -0500 Subject: [PATCH 08/19] Added some general information on the differences between Composer and PEAR, and that in general, Composer is for single projects and PEAR is system-wide. --- _posts/04-01-01-Dependency-Management.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/_posts/04-01-01-Dependency-Management.md b/_posts/04-01-01-Dependency-Management.md index 46f0d9e..1c414c8 100644 --- a/_posts/04-01-01-Dependency-Management.md +++ b/_posts/04-01-01-Dependency-Management.md @@ -1,3 +1,10 @@ # Dependency Management There are a ton of PHP libraries, frameworks, and components to choose from. Your project will likely use several of them — these are project dependencies. Until recently, PHP did not have a good way to manage these project dependencies. Even if you managed them manually, you still had to worry about autoloaders. No more. + +Currently there are two major package management systems for PHP - Composer and PEAR. Which one is right for you? The answer is both. + + * Use **Composer** when managing dependencies for a single project. + * Use **PEAR** when managing dependencies for PHP as a whole on your system. + +In general, Composer packages will be available only in the projects that you explicitly specify whereas a PEAR package would be available to all of your PHP projects. While PEAR might sound like the easier approach at first glance, there are advantages to using a project-by-project approach to your dependencies. From 88302cbcd68f0266aba94bf276ebd6727d96df71 Mon Sep 17 00:00:00 2001 From: ziadoz Date: Thu, 12 Jul 2012 11:31:08 -0600 Subject: [PATCH 09/19] Added Nikita Popov to the list of people to follow in the PHP community. --- _posts/12-01-01-Resources.md | 1 + 1 file changed, 1 insertion(+) diff --git a/_posts/12-01-01-Resources.md b/_posts/12-01-01-Resources.md index 086fbd8..957c84d 100644 --- a/_posts/12-01-01-Resources.md +++ b/_posts/12-01-01-Resources.md @@ -13,6 +13,7 @@ * [Chris Shiflett](http://twitter.com/shiflett) * [Sebastian Bergmann](http://twitter.com/s_bergmann) * [Matthew Weier O'Phinney](http://twitter.com/weierophinney) +* [Nikita Popov](http://twitter.com/nikita_ppv) ## Mentoring From f59f236333e69f706b5bc61bf065985882cc0a17 Mon Sep 17 00:00:00 2001 From: Jamie York Date: Thu, 12 Jul 2012 12:32:51 -0600 Subject: [PATCH 10/19] Added security information about handling null bytes. --- _posts/07-05-01-Null-Bytes.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 _posts/07-05-01-Null-Bytes.md diff --git a/_posts/07-05-01-Null-Bytes.md b/_posts/07-05-01-Null-Bytes.md new file mode 100644 index 0000000..a88f8a1 --- /dev/null +++ b/_posts/07-05-01-Null-Bytes.md @@ -0,0 +1,18 @@ +--- +isChild: true +--- + +## Null Bytes + +A null byte `\0` denotes the end of a string in [C](http://en.wikipedia.org/wiki/C_(programming_language)). As PHP uses C for all it's +filesystem related operations it means a filesystem path could be [null byte poisoned][2]. + +To prevent this it is important to remove any null bytes from filesystem paths, _especially_ if they come from user input: + + $filepath = str_replace(chr(0), '', $_FILE['tmp_name']); + +[See Null Byte Related Issues][1] +[See Null Byte Poisoning][2] + +[1]: http://php.net/manual/en/security.filesystem.nullbytes.php +[2]: http://www.madirish.net/?article=436 \ No newline at end of file From d39b4c8448d54bb31b1c9b311f4a86582b156cff Mon Sep 17 00:00:00 2001 From: Jamie York Date: Thu, 12 Jul 2012 13:04:00 -0600 Subject: [PATCH 11/19] Moved null byte security information into data filtering. --- _posts/07-04-01-Data-Filtering.md | 4 +++- _posts/07-05-01-Null-Bytes.md | 18 ------------------ 2 files changed, 3 insertions(+), 19 deletions(-) delete mode 100644 _posts/07-05-01-Null-Bytes.md diff --git a/_posts/07-04-01-Data-Filtering.md b/_posts/07-04-01-Data-Filtering.md index 524c655..d3ebe41 100644 --- a/_posts/07-04-01-Data-Filtering.md +++ b/_posts/07-04-01-Data-Filtering.md @@ -27,12 +27,13 @@ Another example is passing options to be executed on the command line. This can command's arguments. One last example is accepting foreign input to determine a file to load from the filesystem. This can be exploited by -changing the filename to a file path. You need to remove "/", "../", or other characters from the file path so it can't +changing the filename to a file path. You need to remove "/", "../", [null bytes][6], or other characters from the file path so it can't load hidden, non-public, or sensitive files. * [Learn about data filtering][1] * [Learn about `filter_var`][4] * [Learn about `filter_input`][5] +* [Learn about handling null bytes][6] ### Sanitization @@ -61,4 +62,5 @@ email address, a phone number, or age when processing a registration submission. [3]: http://www.php.net/manual/en/filter.filters.validate.php [4]: http://php.net/manual/en/function.filter-var.php [5]: http://www.php.net/manual/en/function.filter-input.php +[6]: http://php.net/manual/en/security.filesystem.nullbytes.php [html-purifier]: http://htmlpurifier.org/ diff --git a/_posts/07-05-01-Null-Bytes.md b/_posts/07-05-01-Null-Bytes.md deleted file mode 100644 index a88f8a1..0000000 --- a/_posts/07-05-01-Null-Bytes.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -isChild: true ---- - -## Null Bytes - -A null byte `\0` denotes the end of a string in [C](http://en.wikipedia.org/wiki/C_(programming_language)). As PHP uses C for all it's -filesystem related operations it means a filesystem path could be [null byte poisoned][2]. - -To prevent this it is important to remove any null bytes from filesystem paths, _especially_ if they come from user input: - - $filepath = str_replace(chr(0), '', $_FILE['tmp_name']); - -[See Null Byte Related Issues][1] -[See Null Byte Poisoning][2] - -[1]: http://php.net/manual/en/security.filesystem.nullbytes.php -[2]: http://www.madirish.net/?article=436 \ No newline at end of file From ff8e9f87d7926a29d07b79670198721b3434013c Mon Sep 17 00:00:00 2001 From: Goran Rakic Date: Fri, 13 Jul 2012 00:27:20 +0200 Subject: [PATCH 12/19] Mac Setup fixes - Redo MAMP description - Move php-osx with the other package managers. --- _posts/01-04-01-Mac-Setup.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/_posts/01-04-01-Mac-Setup.md b/_posts/01-04-01-Mac-Setup.md index a568bd3..09ada49 100644 --- a/_posts/01-04-01-Mac-Setup.md +++ b/_posts/01-04-01-Mac-Setup.md @@ -6,13 +6,15 @@ isChild: true OSX comes prepackaged with PHP but it is normally a little behind the latest stable. Lion comes with PHP 5.3.6 and Mountain Lion has 5.3.10. -To update PHP on OSX you can get the PHP executable through a number of Mac [package managers][mac-package-managers] or [compile it yourself][mac-compile] (if compiling, be sure to have installed either Xcode or Apple's substitute ["Command Line Tools for Xcode" downloadable from Apple's Mac Developer Center][apple-developer]). +To update PHP on OSX you can get it installed through a number of Mac [package managers][mac-package-managers], with [php-osx by Liip][entropy-downloads] being recommended. -For a complete LAMP package with GUI try [MAMP][mamp-downloads], otherwise consider the [Entropy 5.4][entropy-downloads] package. +The other option is to [compile it yourself][mac-compile], in that case be sure to have installed either Xcode or Apple's substitute ["Command Line Tools for Xcode" downloadable from Apple's Mac Developer Center][apple-developer]. + +For a complete "all-in-one" package including PHP, Apache web server and MySQL database, all this with a nice control GUI, try [MAMP][mamp-downloads]. [mac-package-managers]: http://www.php.net/manual/en/install.macosx.packages.php [mac-compile]: http://www.php.net/manual/en/install.macosx.compile.php [xcode-gcc-substitution]: https://github.com/kennethreitz/osx-gcc-installer [apple-developer]: https://developer.apple.com/downloads [mamp-downloads]: http://www.mamp.info/en/downloads/index.html -[entropy-downloads]: http://php-osx.liip.ch/ \ No newline at end of file +[entropy-downloads]: http://php-osx.liip.ch/ From 076a1367ec350929c156a2ca65a992803038463a Mon Sep 17 00:00:00 2001 From: Goran Rakic Date: Fri, 13 Jul 2012 00:53:39 +0200 Subject: [PATCH 13/19] Wrap to 120 chars --- _posts/01-04-01-Mac-Setup.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/_posts/01-04-01-Mac-Setup.md b/_posts/01-04-01-Mac-Setup.md index 09ada49..d60d3c6 100644 --- a/_posts/01-04-01-Mac-Setup.md +++ b/_posts/01-04-01-Mac-Setup.md @@ -4,17 +4,21 @@ isChild: true ## Mac Setup -OSX comes prepackaged with PHP but it is normally a little behind the latest stable. Lion comes with PHP 5.3.6 and Mountain Lion has 5.3.10. +OSX comes prepackaged with PHP but it is normally a little behind the latest stable. Lion comes with PHP 5.3.6 and +Mountain Lion has 5.3.10. -To update PHP on OSX you can get it installed through a number of Mac [package managers][mac-package-managers], with [php-osx by Liip][entropy-downloads] being recommended. +To update PHP on OSX you can get it installed through a number of Mac [package managers][mac-package-managers], with +[php-osx by Liip][php-osx-downloads] being recommended. -The other option is to [compile it yourself][mac-compile], in that case be sure to have installed either Xcode or Apple's substitute ["Command Line Tools for Xcode" downloadable from Apple's Mac Developer Center][apple-developer]. +The other option is to [compile it yourself][mac-compile], in that case be sure to have installed either Xcode or +Apple's substitute ["Command Line Tools for Xcode" downloadable from Apple's Mac Developer Center][apple-developer]. -For a complete "all-in-one" package including PHP, Apache web server and MySQL database, all this with a nice control GUI, try [MAMP][mamp-downloads]. +For a complete "all-in-one" package including PHP, Apache web server and MySQL database, all this with a nice control +GUI, try [MAMP][mamp-downloads]. [mac-package-managers]: http://www.php.net/manual/en/install.macosx.packages.php [mac-compile]: http://www.php.net/manual/en/install.macosx.compile.php [xcode-gcc-substitution]: https://github.com/kennethreitz/osx-gcc-installer [apple-developer]: https://developer.apple.com/downloads [mamp-downloads]: http://www.mamp.info/en/downloads/index.html -[entropy-downloads]: http://php-osx.liip.ch/ +[php-osx-downloads]: http://php-osx.liip.ch/ From 94e0b6b09f0ea69639396eec867dfe592197d051 Mon Sep 17 00:00:00 2001 From: = Date: Thu, 12 Jul 2012 20:10:14 -0400 Subject: [PATCH 14/19] Add Community section Fixes #100 --- _posts/13-01-01-Community.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 _posts/13-01-01-Community.md diff --git a/_posts/13-01-01-Community.md b/_posts/13-01-01-Community.md new file mode 100644 index 0000000..ecb9b5e --- /dev/null +++ b/_posts/13-01-01-Community.md @@ -0,0 +1,23 @@ +# Community + +The PHP community is as diverse as it is large, and it's members are ready and willing to support new PHP programmers. You should consider joining your local PHP user group (PUG) or attending larger PHP conferences to learn more about the best practices shown here. Get out there, meet new developers, learn new topics and, above all, make new friends. + +[Read the Official PHP Events Calendar][php-calendar] + +## PHP User Groups + +If you live in a larger city, odds are there's a PHP user group nearby. Although there's not yet an official list of PUGs, you can easily find your local PUG by searching on [Google][google] or [Meetup.com][meetup]. If you live in a smaller town, there may not be a local PUG; if that's the case, start one! + +[Read about User Groups on the PHP Wiki][php-wiki] + +## PHP Conferences + +The PHP community also hosts larger regional and national conferences in many countries around the world. Well-known members of the PHP community usually speak at these larger events, so it's a great opportunity to learn directly from industry leaders. + +[Find a PHP Conference][php-conf] + +[php-calendar]: http://www.php.net/cal.php +[google]: https://www.google.com/search?q=php+user+group+near+me +[meetup]: http://www.meetup.com/find/ +[php-wiki]: https://wiki.php.net/usergroups +[php-conf]: http://php.net/conferences/index.php From 5ba8978d46ca0d08f7dec4a02705114ebf9a30ac Mon Sep 17 00:00:00 2001 From: Steven Benner Date: Thu, 12 Jul 2012 18:25:28 -0700 Subject: [PATCH 15/19] Expanded on object caching. --- _posts/10-03-01-Object-Caching.md | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/_posts/10-03-01-Object-Caching.md b/_posts/10-03-01-Object-Caching.md index c366dc0..fd8fff9 100644 --- a/_posts/10-03-01-Object-Caching.md +++ b/_posts/10-03-01-Object-Caching.md @@ -4,17 +4,21 @@ isChild: true ## Object Caching -There are times when it is advantageous to cache individual objects in your code, such as with data that is expensive to -get or database calls where the result is unlikely to change. You can use object caching software to hold pieces of data -in memory for extremely fast access later on. If you save these items in a data store after you get them then access the -data for following requests from cache you will see significant performance increases and reduced load on your database -servers. +There are times when it can be advantageous to cache individual objects in your code, such as with data that is +expensive to get or database calls where the result is unlikely to change. You can use object caching software to hold +these pieces of data in memory for extremely fast access later on. If you save these items to a data store after you +retrieve them, then pull them directly from the cache for following requests you can gain a significant improvement in +performance as well as reduce load on your database servers. -The most common memory object caching systems are APC and memcached. APC is a great choice for caching, it comes with -PHP and is very easy to setup and to use, but it is tied to the server it is installed on. Memcached on the other hand -is installed as a separate service and can be accessed across the network, meaning that you can store values in a -hyper-fast data store in a central location and many different systems can pull from it. In a networked configuration -APC will outperform memcached in terms of access speed, but memcached will be able to scale up faster and further. +The most commonly used memory object caching systems are APC and memcached. APC is a great choice for object caching as +well as opcode caching *(see above)*. APC comes bundled with PHP and it is very easy to setup and to use, the only +possible downside is that it is tied to the server it is installed on. Memcached on the other hand is installed as a +separate service and can be accessed across the network, meaning that you can store objects in a hyper-fast data store +in a central location and many different systems can pull from it. + +In a networked configuration APC will usally outperform memcached in terms of access speed, but memcached will be able +to scale up faster and further. If you do not expect to have multiple servers running your application, or do not need +the extra features that memcached offers then APC is probably your best choice for object caching. Example logic using APC: @@ -30,8 +34,8 @@ if (!$data) Learn more about popular object caching systems. -* [APC](http://php.net/manual/en/book.apc.php) +* [APC](http://php.net/manual/en/book.apc.php) (Can do opcode caching and object caching) * [APC Functions](http://php.net/manual/en/ref.apc.php) * [Memcached](http://memcached.org/) * [Redis](http://redis.io/) -* [WinCache](http://php.net/manual/en/book.wincache.php) (Windows Only) +* [WinCache](http://php.net/manual/en/book.wincache.php) (Windows Only, can do opcode caching and object caching) From a58285588a170281ae64857b98d323dc19d5ef2d Mon Sep 17 00:00:00 2001 From: Steven Benner Date: Thu, 12 Jul 2012 22:33:37 -0700 Subject: [PATCH 16/19] More improvements to object caching section. --- _posts/10-03-01-Object-Caching.md | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/_posts/10-03-01-Object-Caching.md b/_posts/10-03-01-Object-Caching.md index fd8fff9..df29b2e 100644 --- a/_posts/10-03-01-Object-Caching.md +++ b/_posts/10-03-01-Object-Caching.md @@ -4,19 +4,22 @@ isChild: true ## Object Caching -There are times when it can be advantageous to cache individual objects in your code, such as with data that is -expensive to get or database calls where the result is unlikely to change. You can use object caching software to hold -these pieces of data in memory for extremely fast access later on. If you save these items to a data store after you -retrieve them, then pull them directly from the cache for following requests you can gain a significant improvement in -performance as well as reduce load on your database servers. +There are times when it can be beneficial to cache individual objects in your code, such as with data that is expensive +to get or database calls where the result is unlikely to change. You can use object caching software to hold these +pieces of data in memory for extremely fast access later on. If you save these items to a data store after you retrieve +them, then pull them directly from the cache for following requests you can gain a significant improvement in +performance as well as reduce the load on your database servers. -The most commonly used memory object caching systems are APC and memcached. APC is a great choice for object caching as -well as opcode caching *(see above)*. APC comes bundled with PHP and it is very easy to setup and to use, the only -possible downside is that it is tied to the server it is installed on. Memcached on the other hand is installed as a -separate service and can be accessed across the network, meaning that you can store objects in a hyper-fast data store -in a central location and many different systems can pull from it. +Many of the popular bytecode caching solutions let you cache custom data as well, so there's even more reason to take +advantage of them. APC, XCache, and WinCache all provide APIs to save data from your PHP code to their memory cache. -In a networked configuration APC will usally outperform memcached in terms of access speed, but memcached will be able +The most commonly used memory object caching systems are APC and memcached. APC is an excellent choice for object +caching, it includes a simple API for adding your own data to its memory cache and is very easy to setup and use. The +one real limitation of APC is that it is tied to the server it's installed on. Memcached on the other hand is installed +as a separate service and can be accessed across the network, meaning that you can store objects in a hyper-fast data +store in a central location and many different systems can pull from it. + +In a networked configuration APC will usually outperform memcached in terms of access speed, but memcached will be able to scale up faster and further. If you do not expect to have multiple servers running your application, or do not need the extra features that memcached offers then APC is probably your best choice for object caching. @@ -32,10 +35,10 @@ if (!$data) } {% endhighlight %} -Learn more about popular object caching systems. +Learn more about popular object caching systems: -* [APC](http://php.net/manual/en/book.apc.php) (Can do opcode caching and object caching) * [APC Functions](http://php.net/manual/en/ref.apc.php) * [Memcached](http://memcached.org/) * [Redis](http://redis.io/) -* [WinCache](http://php.net/manual/en/book.wincache.php) (Windows Only, can do opcode caching and object caching) +* [XCache APIs](http://xcache.lighttpd.net/wiki/XcacheApi) +* [WinCache Functions](http://www.php.net/manual/en/ref.wincache.php) From 4d81eef404bdc8bfa68e357e57ccb5412a5a3d0c Mon Sep 17 00:00:00 2001 From: Goran Rakic Date: Fri, 13 Jul 2012 08:57:18 +0200 Subject: [PATCH 17/19] Make link shorter --- _posts/01-04-01-Mac-Setup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_posts/01-04-01-Mac-Setup.md b/_posts/01-04-01-Mac-Setup.md index d60d3c6..c646ce9 100644 --- a/_posts/01-04-01-Mac-Setup.md +++ b/_posts/01-04-01-Mac-Setup.md @@ -11,7 +11,7 @@ To update PHP on OSX you can get it installed through a number of Mac [package m [php-osx by Liip][php-osx-downloads] being recommended. The other option is to [compile it yourself][mac-compile], in that case be sure to have installed either Xcode or -Apple's substitute ["Command Line Tools for Xcode" downloadable from Apple's Mac Developer Center][apple-developer]. +Apple's substitute ["Command Line Tools for Xcode"][apple-developer] downloadable from Apple's Mac Developer Center. For a complete "all-in-one" package including PHP, Apache web server and MySQL database, all this with a nice control GUI, try [MAMP][mamp-downloads]. From 0f3891c14c649da42e7e6eb1d2570ec48e793de3 Mon Sep 17 00:00:00 2001 From: Rafael Dohms Date: Fri, 13 Jul 2012 10:35:55 +0200 Subject: [PATCH 18/19] Adding PHPC information Added information about the PHPC initiative, on IRC and Twitter. --- _posts/13-01-01-Community.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/_posts/13-01-01-Community.md b/_posts/13-01-01-Community.md index ecb9b5e..3b87668 100644 --- a/_posts/13-01-01-Community.md +++ b/_posts/13-01-01-Community.md @@ -1,6 +1,6 @@ # Community -The PHP community is as diverse as it is large, and it's members are ready and willing to support new PHP programmers. You should consider joining your local PHP user group (PUG) or attending larger PHP conferences to learn more about the best practices shown here. Get out there, meet new developers, learn new topics and, above all, make new friends. +The PHP community is as diverse as it is large, and it's members are ready and willing to support new PHP programmers. You should consider joining your local PHP user group (PUG) or attending larger PHP conferences to learn more about the best practices shown here. You can also hang out on IRC in the #phpc channel on irc.freenode.com and follow the [@phpc][phpc-twitter] twitter account. Get out there, meet new developers, learn new topics and, above all, make new friends. [Read the Official PHP Events Calendar][php-calendar] @@ -21,3 +21,4 @@ The PHP community also hosts larger regional and national conferences in many co [meetup]: http://www.meetup.com/find/ [php-wiki]: https://wiki.php.net/usergroups [php-conf]: http://php.net/conferences/index.php +[phpc-twitter]: https://twitter.com/phpc From d570bf841f199f37e371c7665f133e6c939382ed Mon Sep 17 00:00:00 2001 From: Steven Benner Date: Fri, 13 Jul 2012 02:38:22 -0700 Subject: [PATCH 19/19] American english fix. --- _posts/08-02-01-Test-Driven-Development.md | 2 +- _posts/08-04-01-Complementary-Testing-Tools.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/_posts/08-02-01-Test-Driven-Development.md b/_posts/08-02-01-Test-Driven-Development.md index 04e2255..4498555 100644 --- a/_posts/08-02-01-Test-Driven-Development.md +++ b/_posts/08-02-01-Test-Driven-Development.md @@ -17,7 +17,7 @@ expected, from the point you build them all the way through the development cycl values going in and out of various functions and methods, you can make sure the internal logic is working correctly. By using Dependency Injection and building "mock" classes and stubs you can verify that dependencies are correctly used for even better test coverage. -When you create a class or function you should create a unit test for each behaviour it must have. At a very basic level you should +When you create a class or function you should create a unit test for each behavior it must have. At a very basic level you should make sure it errors if you send it bad arguments and make sure it works if you send it valid arguments. This will help ensure that when you make changes to this class or function later on in the development cycle that the old functionality continues to work as expected. The only alternative to this would be diff --git a/_posts/08-04-01-Complementary-Testing-Tools.md b/_posts/08-04-01-Complementary-Testing-Tools.md index 1ba5892..7abc24b 100644 --- a/_posts/08-04-01-Complementary-Testing-Tools.md +++ b/_posts/08-04-01-Complementary-Testing-Tools.md @@ -4,7 +4,7 @@ isChild: true ## Complementary Testing Tools -Besides individual testing and behaviour driven frameworks, there are also a number of generic frameworks and helper libraries useful for any preferred approach taken. +Besides individual testing and behavior driven frameworks, there are also a number of generic frameworks and helper libraries useful for any preferred approach taken. ### Tool Links