From 779932b2727c6a7313d4e5c07cfe5108ac2eb1f7 Mon Sep 17 00:00:00 2001 From: Maxime Fabre Date: Tue, 21 Oct 2014 19:57:26 +0200 Subject: [PATCH 01/32] Reword DM to use Composer as global PM --- _posts/04-01-01-Dependency-Management.md | 7 +------ _posts/04-02-01-Composer-and-Packagist.md | 11 +++++++++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/_posts/04-01-01-Dependency-Management.md b/_posts/04-01-01-Dependency-Management.md index 95be994..50dbcc8 100644 --- a/_posts/04-01-01-Dependency-Management.md +++ b/_posts/04-01-01-Dependency-Management.md @@ -6,9 +6,4 @@ anchor: 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. +Currently there are two major package management systems for PHP - Composer and PEAR. The former is the main package manager to use for PHP, however for a long time PEAR used to fill that role, and you may still find references to it so it's a good idea to be aware of its extistence too. \ No newline at end of file diff --git a/_posts/04-02-01-Composer-and-Packagist.md b/_posts/04-02-01-Composer-and-Packagist.md index 9f3fa27..76e45c7 100644 --- a/_posts/04-02-01-Composer-and-Packagist.md +++ b/_posts/04-02-01-Composer-and-Packagist.md @@ -40,7 +40,7 @@ The path `$HOME/local/bin` (or a directory of your choice) should be in your `$P When you come across documentation that states to run Composer as `php composer.phar install`, you can substitute that with: composer install - + This section will assume you have installed composer globally. ### How to Define and Install Dependencies @@ -70,7 +70,7 @@ This is most useful when you define your version requirements flexibly. For inst ### Update Notifications -To receive notifications about new version releases you can sign up for [VersionEye][3], a web service that can monitor +To receive notifications about new version releases you can sign up for [VersionEye][3], a web service that can monitor your GitHub and BitBucket accounts for `composer.json` files and send emails with new package releases. ### Checking your dependencies for security issues @@ -86,3 +86,10 @@ The [Security Advisories Checker][4] is a web service and a command-line tool, b [5]: http://getcomposer.org/doc/00-intro.md [6]: https://getcomposer.org/Composer-Setup.exe +### Handling global dependencies with Composer + +Composer can also handle global dependencies and their binaries. Usage is straight-forward, all you need to do is prefix your command with `global`. If per example you wanted to install PHPUnit and have it available globally, you'd run the following command: + + composer global require phpunit/phpunit + +This will create a `~/.composer` folder where your global dependencies reside. To have the installed packages' binaries available everywhere, you'd then add the `~/.composer/vendor/bin` folder to your PATH. \ No newline at end of file From 846addf2ed040dcfcdf6c613cb1e89b2115a0390 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Sun, 7 Dec 2014 21:46:54 +0100 Subject: [PATCH 02/32] syntax highlighting for Twig examples enabled --- _posts/08-04-01-Compiled-Templates.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/_posts/08-04-01-Compiled-Templates.md b/_posts/08-04-01-Compiled-Templates.md index 8481eb2..e32d199 100644 --- a/_posts/08-04-01-Compiled-Templates.md +++ b/_posts/08-04-01-Compiled-Templates.md @@ -20,7 +20,7 @@ when proper caching is used. Using the [Twig](http://twig.sensiolabs.org/) library. -{% highlight text %} +{% highlight html+jinja %} {% raw %} {% include 'header.html' with {'title': 'User Profile'} %} @@ -35,7 +35,7 @@ Using the [Twig](http://twig.sensiolabs.org/) library. Using the [Twig](http://twig.sensiolabs.org/) library. -{% highlight text %} +{% highlight html+jinja %} {% raw %} // template.html @@ -54,7 +54,7 @@ Using the [Twig](http://twig.sensiolabs.org/) library. {% endraw %} {% endhighlight %} -{% highlight text %} +{% highlight html+jinja %} {% raw %} // user_profile.html @@ -66,4 +66,4 @@ Using the [Twig](http://twig.sensiolabs.org/) library.

Hello, {{ name }}

{% endblock %} {% endraw %} -{% endhighlight %} \ No newline at end of file +{% endhighlight %} From d1851cc82bda9669ceea22ea62dc645b848bde1f Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Tue, 9 Dec 2014 06:18:31 +0100 Subject: [PATCH 03/32] jekyll-sitemap gem added --- _config.yml | 13 ++++++++++++- banners.md | 1 + index.html | 1 + pages/Design-Patterns.md | 1 + pages/Functional-Programming.md | 1 + pages/The-Basics.md | 3 ++- sitemap.xml | 15 --------------- 7 files changed, 18 insertions(+), 17 deletions(-) delete mode 100644 sitemap.xml diff --git a/_config.yml b/_config.yml index caa75bc..fdadac1 100644 --- a/_config.yml +++ b/_config.yml @@ -1,4 +1,3 @@ -safe: true baseurl: / url: http://localhost:4000 @@ -11,3 +10,15 @@ maruku: png_engine: blahtex png_dir: images/latex png_url: /images/latex + +gems: + - jekyll-sitemap + +defaults: + - + scope: + path: "" + values: + sitemap: false + +exclude: ['CNAME', 'CONTRIBUTING.md', 'LICENSE', 'README.md', 'pages/example.md'] diff --git a/banners.md b/banners.md index b4a06bb..c809b7f 100644 --- a/banners.md +++ b/banners.md @@ -2,6 +2,7 @@ layout: default title: Website Banners description: "Spread the word! Use these banner to let new PHP programmers know about PHP: The Right Way" +sitemap: true --- # Web Banners diff --git a/index.html b/index.html index 5fdb78f..7fd22cb 100644 --- a/index.html +++ b/index.html @@ -1,6 +1,7 @@ --- layout: default description: "An easy-to-read, quick reference for PHP best practices, accepted coding standards, and links to authoritative PHP tutorials around the Web" +sitemap: true --- {% capture welcome_content %}{% include welcome.md %}{% endcapture %} diff --git a/pages/Design-Patterns.md b/pages/Design-Patterns.md index 7e57cb9..d659d66 100644 --- a/pages/Design-Patterns.md +++ b/pages/Design-Patterns.md @@ -1,6 +1,7 @@ --- layout: page title: Design Patterns +sitemap: true --- # Design Patterns diff --git a/pages/Functional-Programming.md b/pages/Functional-Programming.md index b625a84..85bb97f 100644 --- a/pages/Functional-Programming.md +++ b/pages/Functional-Programming.md @@ -1,6 +1,7 @@ --- layout: page title: Functional Programming in PHP +sitemap: true --- # Functional Programming in PHP diff --git a/pages/The-Basics.md b/pages/The-Basics.md index 75221e3..b98d542 100644 --- a/pages/The-Basics.md +++ b/pages/The-Basics.md @@ -1,6 +1,7 @@ --- layout: page title: The Basics +sitemap: true --- # The Basics @@ -283,7 +284,7 @@ EOD; // closing 'EOD' must be on it's own line, and to th * [Heredoc syntax](http://php.net/language.types.string#language.types.string.syntax.heredoc) -### Which is quicker? +### Which is quicker? There is a myth floating around that single quote strings are fractionally quicker than double quote strings. This is fundamentally not true. diff --git a/sitemap.xml b/sitemap.xml deleted file mode 100644 index ff86f72..0000000 --- a/sitemap.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - http://www.phptherightway.com/index.html - 2012-07-07T01:00:00-05:00 - daily - 1 - - - http://www.phptherightway.com/banners.html - 2012-07-08T14:11:00-05:00 - weekly - 0.5 - - From d1f5645c3372027234f34cc4f4a33cd2bb4fe995 Mon Sep 17 00:00:00 2001 From: Frank Perez Date: Tue, 9 Dec 2014 09:16:56 -0500 Subject: [PATCH 04/32] Update text under Vagrant section. --- _posts/13-02-01-Vagrant.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_posts/13-02-01-Vagrant.md b/_posts/13-02-01-Vagrant.md index 9210827..cfabf89 100644 --- a/_posts/13-02-01-Vagrant.md +++ b/_posts/13-02-01-Vagrant.md @@ -5,7 +5,7 @@ anchor: vagrant ## Vagrant {#vagrant_title} -[Vagrant] helps you building your virtual boxes on top of the known virtual environments and will configure these +[Vagrant] helps you build your virtual boxes on top of the known virtual environments and will configure these environments based on a single configuration file. These boxes can be set up manually, or you can use "provisioning" software such as [Puppet] or [Chef] to do this for you. Provisioning the base box is a great way to ensure that multiple boxes are set up in an identical fashion and removes the need for you to maintain complicated "set up" From a12560b6fd5e2bddd12ab8e2a399a9222728c06d Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Fri, 2 Jan 2015 14:01:16 +0800 Subject: [PATCH 05/32] Add Chinese Traditional link. Signed-off-by: Bo-Yi Wu --- README.md | 1 + _includes/welcome.md | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index e262049..34719a8 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ developers know where to find good information! * [English](http://www.phptherightway.com) * [Bulgarian](http://bg.phptherightway.com) * [Chinese (Simplified)](http://wulijun.github.com/php-the-right-way) +* [Chinese (Traditional)](http://laravel-taiwan.github.io/php-the-right-way) * [French](http://eilgin.github.io/php-the-right-way/) * [German](http://rwetzlmayr.github.io/php-the-right-way) * [Indonesian](http://id.phptherightway.com) diff --git a/_includes/welcome.md b/_includes/welcome.md index 6f98291..796bdf7 100644 --- a/_includes/welcome.md +++ b/_includes/welcome.md @@ -23,6 +23,7 @@ _PHP: The Right Way_ is (or soon will be) translated into many different languag * [English](http://www.phptherightway.com) * [Bulgarian](http://bg.phptherightway.com/) * [Chinese (Simplified)](http://wulijun.github.com/php-the-right-way) +* [Chinese (Traditional)](http://laravel-taiwan.github.io/php-the-right-way) * [French](http://eilgin.github.io/php-the-right-way/) * [German](http://rwetzlmayr.github.io/php-the-right-way/) * [Indonesian](http://id.phptherightway.com/) From f73d3cd77861004c33c1dfd9270410eb9e4a1f32 Mon Sep 17 00:00:00 2001 From: "Andrew (Andrius) Marcinkevicius" Date: Fri, 2 Jan 2015 12:51:15 +0200 Subject: [PATCH 06/32] Remove dead text I don't think it's really needed as it's not true anymore and probably just the artifact from the document creation. --- _includes/welcome.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_includes/welcome.md b/_includes/welcome.md index 6f98291..adebbc5 100644 --- a/_includes/welcome.md +++ b/_includes/welcome.md @@ -18,7 +18,7 @@ and examples as they become available. ## Translations -_PHP: The Right Way_ is (or soon will be) translated into many different languages: +_PHP: The Right Way_ is translated into many different languages: * [English](http://www.phptherightway.com) * [Bulgarian](http://bg.phptherightway.com/) From cabe8ad232836c8142653ac0bb6090ffcbb36fb8 Mon Sep 17 00:00:00 2001 From: "Andrew (Andrius) Marcinkevicius" Date: Fri, 2 Jan 2015 14:55:10 +0200 Subject: [PATCH 07/32] Update 03-05-01-Command-Line-Interface.md I think additional emphasis on the **not** could improve the text as it can be missed (at first read "*... put in public*", though "*that isn't right*" and rereading noticed the not). --- _posts/03-05-01-Command-Line-Interface.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_posts/03-05-01-Command-Line-Interface.md b/_posts/03-05-01-Command-Line-Interface.md index 5bc19e6..12bbbe1 100644 --- a/_posts/03-05-01-Command-Line-Interface.md +++ b/_posts/03-05-01-Command-Line-Interface.md @@ -9,7 +9,7 @@ PHP was created to write web applications, but is also useful for scripting comm Command line PHP programs can help automate common tasks like testing, deployment, and application administrivia. CLI PHP programs are powerful because you can use your app's code directly without having to create and secure a web -GUI for it. Just be sure not to put your CLI PHP scripts in your public web root! +GUI for it. Just be sure **not** to put your CLI PHP scripts in your public web root! Try running PHP from your command line: From fe46acb3577e1bc6f7d0fba06c3e57346ef1ae86 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 11 Dec 2014 02:02:23 +0100 Subject: [PATCH 08/32] Add links to other useful resources and video tutorials --- _posts/16-08-01-Sites.md | 22 +++++++++++++++++++ _posts/16-09-01-Videos.md | 12 ++++++++++ .../{16-08-01-Books.md => 16-10-01-Books.md} | 0 pages/The-Basics.md | 1 + 4 files changed, 35 insertions(+) create mode 100644 _posts/16-08-01-Sites.md create mode 100644 _posts/16-09-01-Videos.md rename _posts/{16-08-01-Books.md => 16-10-01-Books.md} (100%) diff --git a/_posts/16-08-01-Sites.md b/_posts/16-08-01-Sites.md new file mode 100644 index 0000000..a5189dc --- /dev/null +++ b/_posts/16-08-01-Sites.md @@ -0,0 +1,22 @@ +--- +isChild: true +anchor: other_resources +title: Other Useful Resources +--- + +## Other Useful Resources {#other_resources_title} + +### Cheatsheets + +* [PHP Cheatsheets](http://phpcheatsheets.com/) - for variable comparisons, arithmetics and variable testing in various +PHP versions +* [PHP Security Cheatsheet](https://www.owasp.org/index.php/PHP_Security_Cheat_Sheet) + +### More best practices + +* [PHP Best Practices](https://phpbestpractices.org/) +* [Best practices for Modern PHP Development](https://www.airpair.com/php/posts/best-practices-for-modern-php-development) + +### PHP universe + +* [PHP Developer blog](http://blog.phpdeveloper.org/) diff --git a/_posts/16-09-01-Videos.md b/_posts/16-09-01-Videos.md new file mode 100644 index 0000000..35f2a00 --- /dev/null +++ b/_posts/16-09-01-Videos.md @@ -0,0 +1,12 @@ +--- +isChild: true +anchor: videos +title: Video Tutorials +--- + +## Video Tutorials {#videos_title} + +### Paid Videos + +* [Standards and Best practices](http://teamtreehouse.com/library/standards-and-best-practices) +* [PHP Training on Pluralsight](http://www.pluralsight.com/search/?searchTerm=php) diff --git a/_posts/16-08-01-Books.md b/_posts/16-10-01-Books.md similarity index 100% rename from _posts/16-08-01-Books.md rename to _posts/16-10-01-Books.md diff --git a/pages/The-Basics.md b/pages/The-Basics.md index b98d542..782a734 100644 --- a/pages/The-Basics.md +++ b/pages/The-Basics.md @@ -36,6 +36,7 @@ if (strpos('testing', 'test') !== false) { // true, as strict comparison was * [Comparison operators](http://php.net/language.operators.comparison) * [Comparison table](http://php.net/types.comparisons) +* [Comparison cheatsheet](http://phpcheatsheets.com/index.php?page=compare) ## Conditional statements From b2008fa8dc54d9baf4ac647ada18a220099b0103 Mon Sep 17 00:00:00 2001 From: Bramus! Date: Fri, 2 Jan 2015 20:01:21 +0100 Subject: [PATCH 09/32] Github Pages are hosted on *.github.io domains --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 34719a8..f4ab5dc 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ If you are interested in translating _PHP: The Right Way_, fork this repo on Git To avoid fragmentation and reader confusion, please choose one of these options: -1. We link to your GitHub Pages fork with `[username].github.com/php-the-right-way` +1. We link to your GitHub Pages fork with `[username].github.io/php-the-right-way` 2. We link to your GitHub Pages fork with a subdomain (e.g. "ru.phptherightway.com") If you use a subdomain, enter the subdomain into the `CNAME` file, and ask us to setup DNS for you. If you do not use a subdomain, remove the `CNAME` file entirely else your fork will not build when pushed. From 28d3f1a9ea30db5d75e0883eec0bf751365c1ca8 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Sat, 3 Jan 2015 23:36:03 +0100 Subject: [PATCH 10/32] PSR-0 is deprecated. --- _posts/03-03-01-Namespaces.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/_posts/03-03-01-Namespaces.md b/_posts/03-03-01-Namespaces.md index dee41d7..48e69c1 100644 --- a/_posts/03-03-01-Namespaces.md +++ b/_posts/03-03-01-Namespaces.md @@ -16,11 +16,11 @@ two PHP classes with the same name may co-exist in separate PHP namespaces. It's It is important for you to namespace your code so that it may be used by other developers without fear of colliding with other libraries. -One recommended way to use namespaces is outlined in [PSR-0][psr0], which aims to provide a standard file, class and +One recommended way to use namespaces is outlined in [PSR-4][psr4], which aims to provide a standard file, class and namespace convention to allow plug-and-play code. -In December 2013 the PHP-FIG created a new autoloading standard: [PSR-4][psr4], which one day will probably replace -PSR-0. Currently both are still usable, as PSR-4 requires PHP 5.3 and many PHP 5.2-only projects currently implement +In October 2014 the PHP-FIG deprecated the previous autoloading standard: [PSR-0][psr0], which has been replaced with +[PSR-4][psr4]. Currently both are still usable, as PSR-4 requires PHP 5.3 and many PHP 5.2-only projects currently implement PSR-0. If you're going to use an autoloader standard for a new application or package then you almost certainly want to look into PSR-4. From 1b95df47bcf0ab7d1e69b32537f1d2524f74067b Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Sun, 4 Jan 2015 18:24:09 +0100 Subject: [PATCH 11/32] typos fixed --- _posts/03-06-01-XDebug.md | 14 +++++++------- _posts/09-02-01-Errors.md | 14 +++++++------- _posts/13-02-01-Vagrant.md | 8 ++++---- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/_posts/03-06-01-XDebug.md b/_posts/03-06-01-XDebug.md index 6ac4a54..9d35a27 100644 --- a/_posts/03-06-01-XDebug.md +++ b/_posts/03-06-01-XDebug.md @@ -1,20 +1,20 @@ --- -title: XDebug +title: Xdebug isChild: true anchor: xdebug --- -## XDebug {#xdebug_title} +## Xdebug {#xdebug_title} One of the most useful tools in software development is a proper debugger. It allows you to trace the execution of your -code and monitor the contents of the stack. XDebug, PHP's debugger, can be utilized by various IDEs to provide +code and monitor the contents of the stack. Xdebug, PHP's debugger, can be utilized by various IDEs to provide Breakpoints and stack inspection. It can also allow tools like PHPUnit and KCacheGrind to perform code coverage analysis and code profiling. If you find yourself in a bind, willing to resort to `var_dump()`/`print_r()`, and you still can't find the solution - maybe you need to use the debugger. -[Installing XDebug][xdebug-install] can be tricky, but one of its most important features is "Remote Debugging" - if +[Installing Xdebug][xdebug-install] can be tricky, but one of its most important features is "Remote Debugging" - if you develop code locally and then test it inside a VM or on another server, Remote Debugging is the feature that you will want to enable right away. @@ -34,10 +34,10 @@ Your IDE will now intercept the current state as the script executes, allowing y values in memory. Graphical debuggers make it very easy to step through code, inspect variables, and eval code against the live runtime. -Many IDE's have built-in or plugin-based support for graphical debugging with xdebug. MacGDBp is a free, open-source, -stand-alone xdebug GUI for Mac. +Many IDE's have built-in or plugin-based support for graphical debugging with Xdebug. MacGDBp is a free, open-source, +stand-alone Xdebug GUI for Mac. - * [Learn more about XDebug][xdebug-docs] + * [Learn more about Xdebug][xdebug-docs] * [Learn more about MacGDBp][macgdbp-install] diff --git a/_posts/09-02-01-Errors.md b/_posts/09-02-01-Errors.md index d435b42..d495f8b 100644 --- a/_posts/09-02-01-Errors.md +++ b/_posts/09-02-01-Errors.md @@ -5,8 +5,8 @@ anchor: errors ## Errors {#errors_title} -In many "exception-heavy" programming languages, whenever anything goes wrong an exception will be thrown. This is -certainly a viable way to do things, but PHP is an "exception-light" programming language. While it does have +In many "exception-heavy" programming languages, whenever anything goes wrong an exception will be thrown. This is +certainly a viable way to do things, but PHP is an "exception-light" programming language. While it does have exceptions and more of the core is starting to use them when working with objects, most of PHP itself will try to keep processing regardless of what happens, unless a fatal error occurs. @@ -96,14 +96,14 @@ for the existence of the file before you try to load it, but if the file is dele is potentially something PHP should resolve, but is one case where error suppression might seem like the only valid solution. -Earlier we mentioned there's no way in a stock PHP system to turn off the error control operator. However, [xDebug] has +Earlier we mentioned there's no way in a stock PHP system to turn off the error control operator. However, [Xdebug] has an `xdebug.scream` ini setting which will disable the error control operator. You can set this via your `php.ini` file with the following. {% highlight ini %} xdebug.scream = On {% endhighlight %} - + You can also set this value at runtime with the `ini_set` function {% highlight php %} @@ -111,7 +111,7 @@ You can also set this value at runtime with the `ini_set` function ini_set('xdebug.scream', '1') {% endhighlight %} -The "[Scream]" PHP extension offers similar functionality to xDebug's, although Scream's ini setting is named +The "[Scream]" PHP extension offers similar functionality to Xdebug's, although Scream's ini setting is named `scream.enabled`. This is most useful when you're debugging code and suspect an informative error is suppressed. Use scream with care, @@ -121,7 +121,7 @@ disabled. * [Error Control Operators] * [SitePoint] -* [xDebug] +* [Xdebug] * [Scream] @@ -149,7 +149,7 @@ More information on this and details on how to use `ErrorException` with error h [errorreport]: /#error_reporting -[xDebug]: http://xdebug.org/docs/basic +[Xdebug]: http://xdebug.org/docs/basic [Scream]: http://php.net/book.scream [Error Control Operators]: http://php.net/language.operators.errorcontrol [SitePoint]: http://www.sitepoint.com/ diff --git a/_posts/13-02-01-Vagrant.md b/_posts/13-02-01-Vagrant.md index cfabf89..64fa1c1 100644 --- a/_posts/13-02-01-Vagrant.md +++ b/_posts/13-02-01-Vagrant.md @@ -19,13 +19,13 @@ create and edit your files on your host machine and then run the code inside you If you need a little help to start using Vagrant there are some services that might be useful: -- [Rove]: service that allows you to pre-generate typical Vagrant builds, PHP among the options. The provisioning is +- [Rove][Rove]: service that allows you to pre-generate typical Vagrant builds, PHP among the options. The provisioning is made with Chef. -- [Puphpet]: simple GUI to set up virtual machines for PHP development. **Heavily focused in PHP**. Besides local VMs, +- [Puphpet][Puphpet]: simple GUI to set up virtual machines for PHP development. **Heavily focused in PHP**. Besides local VMs, it can be used to deploy to cloud services as well. The provisioning is made with Puppet. -- [ Protobox]: is a layer on top of vagrant and a web GUI to setup virtual machines for web development. A single YAML +- [Protobox][Protobox]: is a layer on top of vagrant and a web GUI to setup virtual machines for web development. A single YAML document controls everything that is installed on the virtual machine. -- [Phansible]: provides an easy to use interface that helps you generate Ansible Playbooks for PHP based projects. +- [Phansible][Phansible]: provides an easy to use interface that helps you generate Ansible Playbooks for PHP based projects. [Vagrant]: http://vagrantup.com/ From 632cd0763fb5b930da0422804672ca3a6fb6b239 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Sun, 4 Jan 2015 23:31:28 +0100 Subject: [PATCH 12/32] unneeded config options removed --- _config.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/_config.yml b/_config.yml index fdadac1..3f5364e 100644 --- a/_config.yml +++ b/_config.yml @@ -1,6 +1,3 @@ -baseurl: / -url: http://localhost:4000 - highlighter: pygments markdown: kramdown permalink: date From 4d01642a8969312525b73338b17f6c96178c4b2b Mon Sep 17 00:00:00 2001 From: Don MacAskill Date: Mon, 5 Jan 2015 11:09:42 -0800 Subject: [PATCH 13/32] Fix comment error around UTF-8 and PDO --- _posts/05-05-01-PHP-and-UTF8.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_posts/05-05-01-PHP-and-UTF8.md b/_posts/05-05-01-PHP-and-UTF8.md index 0066fba..467e0df 100644 --- a/_posts/05-05-01-PHP-and-UTF8.md +++ b/_posts/05-05-01-PHP-and-UTF8.md @@ -86,7 +86,7 @@ $string = mb_substr($string, 0, 15); // Connect to a database to store the transformed string // See the PDO example in this document for more information -// Note the `set names utf8mb4` commmand! +// Note the `charset=utf8mb4` in the Data Source Name (DSN) $link = new PDO( 'mysql:host=your-hostname;dbname=your-db;charset=utf8mb4', 'your-username', From 3b393c2c4b67c02d0e69a45a69924102b57ec537 Mon Sep 17 00:00:00 2001 From: Don MacAskill Date: Mon, 5 Jan 2015 11:43:35 -0800 Subject: [PATCH 14/32] Fix PDO not using input filtering in example Somehow, this pull request (https://github.com/codeguy/php-the-right-way/pull/26) went missing in the move to `gh-pages`. But it's fairly critical, since the example has `$_GET` being passed straight into a `PDO` statement. On a write (`INSERT` or `UPDATE`), this can still result in dangerous data (to the app, not to SQL) being written accidentally by a new PHP developer. Data should always be filtered prior to use. --- _posts/07-03-01-Databases_PDO.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/_posts/07-03-01-Databases_PDO.md b/_posts/07-03-01-Databases_PDO.md index 60a960f..d49e57d 100644 --- a/_posts/07-03-01-Databases_PDO.md +++ b/_posts/07-03-01-Databases_PDO.md @@ -50,13 +50,16 @@ FROM users` which will delete all of your users! Instead, you should sanitize th prepare('SELECT name FROM users WHERE id = :id'); -$stmt->bindParam(':id', $_GET['id'], PDO::PARAM_INT); // <-- Automatically sanitized by PDO +$id = filter_input(FILTER_GET, 'id', FILTER_SANITIZE_NUMBER_INT); // <-- filter your data first (see [Data Filtering](#data_filtering)), especially important for INSERT, UPDATE, etc. +$stmt->bindParam(':id', $id, PDO::PARAM_INT); // <-- Automatically sanitized for SQL by PDO $stmt->execute(); {% endhighlight %} This is correct code. It uses a bound parameter on a PDO statement. This escapes the foreign input ID before it is introduced to the database preventing potential SQL injection attacks. +For writes, such as INSERT or UPDATE, it's especially critical to still [filter your data](#data_filtering) first and sanitize it for other things (removal of HTML tags, JavaScript, etc). PDO will only sanitize it for SQL, not for your application. + * [Learn about PDO] You should also be aware that database connections use up resources and it was not unheard-of to have resources From b355c73c3736b4bed1848b619b037bb16f509c73 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Mon, 5 Jan 2015 22:33:09 +0100 Subject: [PATCH 15/32] adding baseurl back to config --- _config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/_config.yml b/_config.yml index 3f5364e..8f818c5 100644 --- a/_config.yml +++ b/_config.yml @@ -1,3 +1,4 @@ +baseurl: / highlighter: pygments markdown: kramdown permalink: date From 0a852e293d186cbae3b855446acd98b46e13f489 Mon Sep 17 00:00:00 2001 From: Dave Hulbert Date: Tue, 6 Jan 2015 08:34:05 +0000 Subject: [PATCH 16/32] Use strict equality comparison when comparing ints This isn't a bug, per se, but bring strict is "the right way" and important to get right in a code example here. --- _posts/03-05-01-Command-Line-Interface.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_posts/03-05-01-Command-Line-Interface.md b/_posts/03-05-01-Command-Line-Interface.md index 12bbbe1..beb5c3c 100644 --- a/_posts/03-05-01-Command-Line-Interface.md +++ b/_posts/03-05-01-Command-Line-Interface.md @@ -26,7 +26,7 @@ Let's write a simple "Hello, $name" CLI program. To try it out, create a file na {% highlight php %} Date: Tue, 6 Jan 2015 20:53:29 +0545 Subject: [PATCH 17/32] Add Lynda.com and Tutsplus in Videos Page Lynda.com and Tutsplus frequently adds new courses about Modern PHP so I think adding them to Paid Videos category will help a lot to newcomers --- _posts/16-09-01-Videos.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/_posts/16-09-01-Videos.md b/_posts/16-09-01-Videos.md index 35f2a00..66e1ec0 100644 --- a/_posts/16-09-01-Videos.md +++ b/_posts/16-09-01-Videos.md @@ -10,3 +10,5 @@ title: Video Tutorials * [Standards and Best practices](http://teamtreehouse.com/library/standards-and-best-practices) * [PHP Training on Pluralsight](http://www.pluralsight.com/search/?searchTerm=php) +* [PHP Training on Lynda.com](http://www.lynda.com/search?q=php) +* [PHP Training on Tutsplus](http://code.tutsplus.com/categories/php/courses) From 4e89fcba0f67c16076a27d65c94650eab11b18f9 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Tue, 6 Jan 2015 14:07:39 -0500 Subject: [PATCH 18/32] class Foo should be FooModel --- _posts/07-04-01-Interacting-via-Code.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_posts/07-04-01-Interacting-via-Code.md b/_posts/07-04-01-Interacting-via-Code.md index 251f788..8f21311 100644 --- a/_posts/07-04-01-Interacting-via-Code.md +++ b/_posts/07-04-01-Interacting-via-Code.md @@ -65,7 +65,7 @@ include 'views/foo-list.php'; {% highlight php %} Date: Wed, 7 Jan 2015 12:31:40 +0545 Subject: [PATCH 19/32] Add SPL paid video course from lynda.com Up and Running with the Standard PHP Library is an awesome course about SPL on Lynda.com. Adding it to the SPL category will help a lot to the readers. --- _posts/03-04-01-Standard-PHP-Library.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/_posts/03-04-01-Standard-PHP-Library.md b/_posts/03-04-01-Standard-PHP-Library.md index a81e7c5..6275976 100644 --- a/_posts/03-04-01-Standard-PHP-Library.md +++ b/_posts/03-04-01-Standard-PHP-Library.md @@ -11,6 +11,8 @@ primarily of commonly needed datastructure classes (stack, queue, heap, and so o over these datastructures or your own classes which implement SPL interfaces. * [Read about the SPL][spl] +* [SPL video course on Lynda.com(Paid)][spllynda] [spl]: http://php.net/book.spl +[spllynda]: http://www.lynda.com/PHP-tutorials/Up-Running-Standard-PHP-Library/175038-2.html From 709e1ead7f43b2ed792b59a3a18abef7d66e4fec Mon Sep 17 00:00:00 2001 From: Peter Dave Hello Date: Wed, 7 Jan 2015 15:03:10 +0800 Subject: [PATCH 20/32] use protocol-relative url to load resources --- _layouts/default.html | 6 +++--- _layouts/page.html | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/_layouts/default.html b/_layouts/default.html index e8a0e02..55a6527 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -12,7 +12,7 @@ - + @@ -95,14 +95,14 @@
  • New Media Campaigns
  • - Creative Commons License
    PHP: The Right Way by Josh Lockhart is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    Based on a work at www.phptherightway.com. + Creative Commons License
    PHP: The Right Way by Josh Lockhart is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    Based on a work at www.phptherightway.com.

    - + diff --git a/_layouts/page.html b/_layouts/page.html index ed25cc7..0396cb8 100644 --- a/_layouts/page.html +++ b/_layouts/page.html @@ -12,7 +12,7 @@ - + @@ -42,7 +42,7 @@ Return to Main Page From 72f1ccedb6d29a3e45881e94f2934007d20f5c85 Mon Sep 17 00:00:00 2001 From: defenestrator Date: Wed, 7 Jan 2015 12:16:29 -0700 Subject: [PATCH 21/32] Fix typos and improve readability of one sentence in Section 3. --- _posts/03-02-01-Programming-Paradigms.md | 6 +++--- _posts/03-05-01-Command-Line-Interface.md | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/_posts/03-02-01-Programming-Paradigms.md b/_posts/03-02-01-Programming-Paradigms.md index 9271541..772f27c 100644 --- a/_posts/03-02-01-Programming-Paradigms.md +++ b/_posts/03-02-01-Programming-Paradigms.md @@ -21,10 +21,10 @@ interfaces, inheritance, constructors, cloning, exceptions, and more. PHP supports first-class function, meaning that a function can be assigned to a variable. Both user-defined and built-in functions can be referenced by a variable and invoked dynamically. Functions can be passed as arguments to -other functions (feature called Higher-order functions) and function can return other functions. +other functions (a feature called _Higher-order Functions_) and function can return other functions. -Recursion, a feature that allows a function to call itself, is supported by the language, but most of the PHP code -focus on iteration. +Recursion, a feature that allows a function to call itself, is supported by the language, but most PHP code +is focused on iteration. New anonymous functions (with support for closures) are present since PHP 5.3 (2009). diff --git a/_posts/03-05-01-Command-Line-Interface.md b/_posts/03-05-01-Command-Line-Interface.md index beb5c3c..825e1c3 100644 --- a/_posts/03-05-01-Command-Line-Interface.md +++ b/_posts/03-05-01-Command-Line-Interface.md @@ -6,7 +6,7 @@ anchor: command_line_interface ## Command Line Interface {#command_line_interface_title} PHP was created to write web applications, but is also useful for scripting command line interface (CLI) programs. -Command line PHP programs can help automate common tasks like testing, deployment, and application administrivia. +Command line PHP programs can help automate common tasks like testing, deployment, and application administration. CLI PHP programs are powerful because you can use your app's code directly without having to create and secure a web GUI for it. Just be sure **not** to put your CLI PHP scripts in your public web root! From 239fbe97650346657e4afeaa727a7fc007dacef6 Mon Sep 17 00:00:00 2001 From: Suraj Adhikari Date: Thu, 8 Jan 2015 11:01:22 +0545 Subject: [PATCH 22/32] Add Youtube Channels section for more free content YouTube has always been a great starting point for everyone to start learning new technologies. Some of the channels that I've listed frequently updates their content with modern information. So i think adding them will be a great help for new and experienced developers. --- _posts/16-09-01-Videos.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/_posts/16-09-01-Videos.md b/_posts/16-09-01-Videos.md index 66e1ec0..d021b2e 100644 --- a/_posts/16-09-01-Videos.md +++ b/_posts/16-09-01-Videos.md @@ -4,7 +4,11 @@ anchor: videos title: Video Tutorials --- -## Video Tutorials {#videos_title} +### Youtube Channels +* [PHP Academy](https://www.youtube.com/user/phpacademy) +* [The New Boston](https://www.youtube.com/user/thenewboston) +* [Sherif Ramadan](https://www.youtube.com/user/businessgeek) +* [Level Up Tuts](https://www.youtube.com/user/LevelUpTuts) ### Paid Videos From f328d5fc1a8591e5e592846a07124c225b73c9c1 Mon Sep 17 00:00:00 2001 From: Chris Brown Date: Sat, 10 Jan 2015 17:15:05 -0500 Subject: [PATCH 23/32] Update 01-05-01-Windows-Setup.md Removed link to Zend Server CE, since that product is no longer available, and the new options are no longer free (unless you can confirm you're a contributor to an active Open Source project, or you want the headaches of dealing with expiring trial licenses). --- _posts/01-05-01-Windows-Setup.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/_posts/01-05-01-Windows-Setup.md b/_posts/01-05-01-Windows-Setup.md index 27fb89d..547f8c8 100644 --- a/_posts/01-05-01-Windows-Setup.md +++ b/_posts/01-05-01-Windows-Setup.md @@ -10,7 +10,7 @@ could use a '.msi' installer. The installer is no longer supported and stops at For learning and local development you can use the built in webserver with PHP 5.4+ so you don't need to worry about configuring it. If you would like an "all-in-one" which includes a full-blown webserver and MySQL too then tools such -as the [Web Platform Installer][wpi], [Zend Server CE][zsce], [XAMPP][xampp], [EasyPHP][easyphp] and [WAMP][wamp] will +as the [Web Platform Installer][wpi], [XAMPP][xampp], [EasyPHP][easyphp] and [WAMP][wamp] will help get a Windows development environment up and running fast. That said, these tools will be a little different from production so be careful of environment differences if you are working on Windows and deploying to Linux. @@ -22,7 +22,6 @@ there is a [dedicated area on iis.net][php-iis] for PHP. [php-downloads]: http://windows.php.net [wpi]: http://www.microsoft.com/web/downloads/platform.aspx -[zsce]: http://www.zend.com/en/products/server-ce/ [xampp]: http://www.apachefriends.org/en/xampp.html [easyphp]: http://www.easyphp.org/ [wamp]: http://www.wampserver.com/en/ From 84de9271d2891224fd287fb7086810632da36c5e Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Sun, 11 Jan 2015 23:56:23 +0100 Subject: [PATCH 24/32] contributing minor fixings --- CONTRIBUTING.md | 2 +- README.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a795ab9..3c69b84 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -62,7 +62,7 @@ included in the project: git checkout -b ``` -4. Install the [Jekyll](https://github.com/mojombo/jekyll/) gem to preview locally. +4. Install the [Jekyll](https://github.com/jekyll/jekyll/) gem to preview locally. 5. Commit your changes in logical chunks. Please adhere to these [git commit message guidelines](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) diff --git a/README.md b/README.md index f4ab5dc..2c0dcf5 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,8 @@ To avoid fragmentation and reader confusion, please choose one of these options: If you use a subdomain, enter the subdomain into the `CNAME` file, and ask us to setup DNS for you. If you do not use a subdomain, remove the `CNAME` file entirely else your fork will not build when pushed. +Add information about your translation in the [wiki page](https://github.com/codeguy/php-the-right-way/wiki/Translations). + When your translation is ready, open an issue on the Issue Tracker to let us know. ## Why From 42bf67238c68a1eca2c946d2c4dd9ba67dbe6fd3 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Tue, 13 Jan 2015 23:03:47 +0000 Subject: [PATCH 25/32] Updated phpdoc stuff --- _posts/15-02-01-PHPDoc.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/_posts/15-02-01-PHPDoc.md b/_posts/15-02-01-PHPDoc.md index cfbc758..8ae1faa 100644 --- a/_posts/15-02-01-PHPDoc.md +++ b/_posts/15-02-01-PHPDoc.md @@ -16,15 +16,15 @@ Below is an example of how you might document a class with a few methods; /** * @author A Name * @link http://www.phpdoc.org/docs/latest/index.html - * @package helper */ class DateTimeHelper { /** * @param mixed $anything Anything that we can convert to a \DateTime object * - * @return \DateTime * @throws \InvalidArgumentException + * + * @return \DateTime */ public function dateTimeFromAnything($anything) { @@ -59,10 +59,9 @@ class DateTimeHelper } {% endhighlight %} -The documentation for the class as a whole firstly has the [@author] tag, this tag is used to document the author of -the code and can be repeated for documenting several authors. Secondly is the [@link] tag, used to link to a website -indicating a relationship between the website and the code. Thirdly it has the [@package] tag, used to categorize the -code. +The documentation for the class as a whole has the [@author] tag and a [@link] tag. The [@author] tag is used to +document the author of the code and can be repeated for documenting several authors. The [@link] tag is used to link to +a website indicating a relationship between the website and the code. Inside the class, the first method has an [@param] tag documenting the type, name and description of the parameter being passed to the method. Additionally it has the [@return] and [@throws] tags for documenting the return type, and @@ -78,7 +77,6 @@ results in the same (no return) action. [PHPDoc manual]: http://www.phpdoc.org/docs/latest/index.html [@author]: http://www.phpdoc.org/docs/latest/references/phpdoc/tags/author.html [@link]: http://www.phpdoc.org/docs/latest/references/phpdoc/tags/link.html -[@package]: http://www.phpdoc.org/docs/latest/references/phpdoc/tags/package.html [@param]: http://www.phpdoc.org/docs/latest/references/phpdoc/tags/param.html [@return]: http://www.phpdoc.org/docs/latest/references/phpdoc/tags/return.html [@throws]: http://www.phpdoc.org/docs/latest/references/phpdoc/tags/throws.html From 4e94aad9b1d44d41a86aea772e0721cb78996cb7 Mon Sep 17 00:00:00 2001 From: Anton Date: Mon, 19 Jan 2015 13:20:36 +0300 Subject: [PATCH 26/32] Update 12-05-01-Building-your-Application.md --- _posts/12-05-01-Building-your-Application.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_posts/12-05-01-Building-your-Application.md b/_posts/12-05-01-Building-your-Application.md index a994958..0e009d3 100644 --- a/_posts/12-05-01-Building-your-Application.md +++ b/_posts/12-05-01-Building-your-Application.md @@ -44,7 +44,7 @@ developers interested in Capistrano. [Chef] is more than a deployment framework, it is a very powerful Ruby based system integration framework that doesn't just deploy your app but can build your whole server environment or virtual boxes. -[Deployer] is a deployment tool written in PHP, it's simple and functional. Deploy your code to all servers you want, it supports deploy via copy, or via VCS (like git), or via rsync. Run your tasks on all your servers, or use our recipes of common tasks for Symfony, Laravel, Zend Framework and Yii. +[Deployer] is a deployment tool written in PHP, it's simple and functional. Run tasks in parallel, atomic deployment, keep servers in consistency. Recipes of common tasks for Symfony, Laravel, Zend Framework and Yii. #### Chef resources for PHP developers: @@ -91,4 +91,4 @@ PHP. [Jenkins]: http://jenkins-ci.org/ [PHPCI]: http://www.phptesting.org/ [Teamcity]: http://www.jetbrains.com/teamcity/ -[Deployer]: http://deployer.in/ \ No newline at end of file +[Deployer]: http://deployer.org/ From 91e959b563650c4cd75d19809e3dc5ec93307162 Mon Sep 17 00:00:00 2001 From: Anton Medvedev Date: Wed, 21 Jan 2015 12:06:40 +0300 Subject: [PATCH 27/32] Update 12-05-01-Building-your-Application.md --- _posts/12-05-01-Building-your-Application.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_posts/12-05-01-Building-your-Application.md b/_posts/12-05-01-Building-your-Application.md index 0e009d3..919c543 100644 --- a/_posts/12-05-01-Building-your-Application.md +++ b/_posts/12-05-01-Building-your-Application.md @@ -44,7 +44,7 @@ developers interested in Capistrano. [Chef] is more than a deployment framework, it is a very powerful Ruby based system integration framework that doesn't just deploy your app but can build your whole server environment or virtual boxes. -[Deployer] is a deployment tool written in PHP, it's simple and functional. Run tasks in parallel, atomic deployment, keep servers in consistency. Recipes of common tasks for Symfony, Laravel, Zend Framework and Yii. +[Deployer] is a deployment tool written in PHP, it's simple and functional. Runs tasks in parallel, atomic deployment, keeps consistency between servers. Recipes of common tasks for Symfony, Laravel, Zend Framework and Yii. #### Chef resources for PHP developers: From 0a78e24f3d88e60ffa4ab2cd88c6046da002483b Mon Sep 17 00:00:00 2001 From: Aykut Farsak Date: Thu, 22 Jan 2015 12:00:32 +0200 Subject: [PATCH 28/32] Update 07-03-01-Databases_PDO.md http://php.net/manual/en/function.filter-input.php --- _posts/07-03-01-Databases_PDO.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_posts/07-03-01-Databases_PDO.md b/_posts/07-03-01-Databases_PDO.md index d49e57d..da20237 100644 --- a/_posts/07-03-01-Databases_PDO.md +++ b/_posts/07-03-01-Databases_PDO.md @@ -50,7 +50,7 @@ FROM users` which will delete all of your users! Instead, you should sanitize th prepare('SELECT name FROM users WHERE id = :id'); -$id = filter_input(FILTER_GET, 'id', FILTER_SANITIZE_NUMBER_INT); // <-- filter your data first (see [Data Filtering](#data_filtering)), especially important for INSERT, UPDATE, etc. +$id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT); // <-- filter your data first (see [Data Filtering](#data_filtering)), especially important for INSERT, UPDATE, etc. $stmt->bindParam(':id', $id, PDO::PARAM_INT); // <-- Automatically sanitized for SQL by PDO $stmt->execute(); {% endhighlight %} From a0b56d6c37be391d9bb7163a0a2eb8d242e90d74 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Thu, 22 Jan 2015 15:01:59 -0500 Subject: [PATCH 29/32] noticable -> noticeable --- pages/The-Basics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/The-Basics.md b/pages/The-Basics.md index 782a734..9628b60 100644 --- a/pages/The-Basics.md +++ b/pages/The-Basics.md @@ -297,7 +297,7 @@ If you are concatenating multiple strings of any type, or interpolate values int results can vary. If you are working with a small number of values, concatenation is minutely faster. With a lot of values, interpolating is minutely faster. -Regardless of what you are doing with strings, none of the types will ever have any noticable impact on your +Regardless of what you are doing with strings, none of the types will ever have any noticeable impact on your application. Trying to rewrite code to use one or the other is always an exercise in futility, so avoid this micro- optimization unless you really understand the meaning and impact of the differences. From d7cca904ea7e49f3aab42c42a7dad268d5e0b063 Mon Sep 17 00:00:00 2001 From: david Date: Sat, 24 Jan 2015 09:49:04 -0800 Subject: [PATCH 30/32] Add DOMDocument UTF-8 stackoverflow link. --- _posts/05-05-01-PHP-and-UTF8.md | 1 + 1 file changed, 1 insertion(+) diff --git a/_posts/05-05-01-PHP-and-UTF8.md b/_posts/05-05-01-PHP-and-UTF8.md index 467e0df..6684510 100644 --- a/_posts/05-05-01-PHP-and-UTF8.md +++ b/_posts/05-05-01-PHP-and-UTF8.md @@ -150,3 +150,4 @@ header('Content-Type: text/html; charset=UTF-8'); * [Stack Overflow: Best practices in PHP and MySQL with international strings](http://stackoverflow.com/questions/140728/best-practices-in-php-and-mysql-with-international-strings) * [How to support full Unicode in MySQL databases](http://mathiasbynens.be/notes/mysql-utf8mb4) * [Bringing Unicode to PHP with Portable UTF-8](http://www.sitepoint.com/bringing-unicode-to-php-with-portable-utf8/) +* [Stack Overflow: DOMDocument loadHTML does not encode UTF-8 correctly](http://stackoverflow.com/questions/8218230/php-domdocument-loadhtml-not-encoding-utf-8-correctly) From 1aa7d4de8a9ad4b2a0c1817f52a9599136231af1 Mon Sep 17 00:00:00 2001 From: Artem Gordinsky Date: Mon, 26 Jan 2015 09:00:07 +0200 Subject: [PATCH 31/32] Remove a line break inside a PHP version number --- _posts/05-05-01-PHP-and-UTF8.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/_posts/05-05-01-PHP-and-UTF8.md b/_posts/05-05-01-PHP-and-UTF8.md index 6684510..578656b 100644 --- a/_posts/05-05-01-PHP-and-UTF8.md +++ b/_posts/05-05-01-PHP-and-UTF8.md @@ -38,8 +38,7 @@ Explicitly defining the encoding of your strings in every script will save you a Additionally, many PHP functions that operate on strings have an optional parameter letting you specify the character encoding. You should always explicitly indicate UTF-8 when given the option. For example, `htmlentities()` has an -option for character encoding, and you should always specify UTF-8 if dealing with such strings. Note that as of PHP 5. -4.0, UTF-8 is the default encoding for `htmlentities()` and `htmlspecialchars()`. +option for character encoding, and you should always specify UTF-8 if dealing with such strings. Note that as of PHP 5.4.0, UTF-8 is the default encoding for `htmlentities()` and `htmlspecialchars()`. Finally, If you are building an distributed application and cannot be certain that the `mbstring` extension will be enabled, then consider using the [patchwork/utf8] Composer package. This will use `mbstring` if it is available, and From 35069640b8c4d0dae6ddffb220c07725ac616ed0 Mon Sep 17 00:00:00 2001 From: c9s Date: Mon, 26 Jan 2015 23:48:45 +0800 Subject: [PATCH 32/32] Add section for MacPorts --- _posts/01-04-01-Mac-Setup.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/_posts/01-04-01-Mac-Setup.md b/_posts/01-04-01-Mac-Setup.md index 0dceb5e..f437efa 100644 --- a/_posts/01-04-01-Mac-Setup.md +++ b/_posts/01-04-01-Mac-Setup.md @@ -18,6 +18,26 @@ There are multiple ways to install PHP on OS X. At this point, you can install `php53`, `php54`, `php55` or `php56` using the `brew install` command, and switch between them by modifying your `PATH` variable. +### Install PHP via Macports + +The [MacPorts] Project is an open-source community initiative to design an +easy-to-use system for compiling, installing, and upgrading either +command-line, X11 or Aqua based open-source software on the OS X operating +system. + +MacPorts supports pre-compiled binaries, so you don't need to recompile every +dependencies from the source tarball files, it saves your life if you don't +have any package installed on your system. + +At this point, you can install `php53`, `php54`, `php55` or `php56` using the `port install` command, for example: + + sudo port install php54 + sudo port install php55 + +And you can run `select` command to switch your active php: + + sudo port select --set php php55 + ### Install PHP via phpbrew [phpbrew] is a tool for installing and managing multiple PHP versions. This can be really useful if two different @@ -38,6 +58,7 @@ you and tie them all together, but ease of setup comes with a trade-off of flexi [Homebrew]: http://brew.sh/ [Homebrew PHP]: https://github.com/Homebrew/homebrew-php#installation +[MacPorts]: https://www.macports.org/install.php [phpbrew]: https://github.com/phpbrew/phpbrew [mac-compile]: http://php.net/install.macosx.compile [xcode-gcc-substitution]: https://github.com/kennethreitz/osx-gcc-installer