diff --git a/LICENSE b/LICENSE index c3a7010..99ae39a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,3 +1,3 @@ -Copyright (c) 2013 Josh Lockhart +Copyright (c) 2025 Josh Lockhart https://creativecommons.org/licenses/by-nc-sa/3.0/ diff --git a/README.md b/README.md index 0efa7ec..5c47a2b 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,6 @@ You should read the `CONTRIBUTING.md` file for precise instructions and tips. Bu * [English](https://www.phptherightway.com) -* [Deutsch](https://rwetzlmayr.github.io/php-the-right-way) * [Español](https://phpdevenezuela.github.io/php-the-right-way) * [Français](https://eilgin.github.io/php-the-right-way/) * [Indonesia](https://id.phptherightway.com) @@ -79,7 +78,7 @@ There's been a lot of discussion lately about how the PHP community lacks suffic ## Who -My name is [Josh Lockhart](https://twitter.com/codeguy). I'm the author of the [Slim Framework](https://www.slimframework.com/), and I work for [New Media Campaigns](https://www.newmediacampaigns.com/). +My name is [Josh Lockhart](https://x.com/codeguy). I'm the author of the [Slim Framework](https://www.slimframework.com/), and I work for [New Media Campaigns](https://www.newmediacampaigns.com/). ### Collaborators diff --git a/_config.yml b/_config.yml index 11e5662..ed5167d 100644 --- a/_config.yml +++ b/_config.yml @@ -18,6 +18,11 @@ defaults: path: "" values: sitemap: false + image: + path: /images/og-image.png + width: 1024 + height: 640 + alt: "PHP: The Right Way" # Excludes should be appended to the default # https://github.com/jekyll/jekyll/blob/master/lib/site_template/_config.yml#L37-L55 @@ -27,7 +32,9 @@ exclude: - gemfiles/ - Gemfile - Gemfile.lock + - Gruntfile.js - node_modules/ + - package.json - vendor/bundle/ - vendor/cache/ - vendor/gems/ @@ -39,3 +46,8 @@ exclude: - pages/example.md future: true + +title: "PHP: The Right Way" +tagline: Reference for PHP best practices +description: An easy-to-read, quick reference for PHP best practices, accepted coding standards, and links to authoritative PHP tutorials around the Web +logo: /images/og-image.png diff --git a/_includes/welcome.md b/_includes/welcome.md index e8b9b11..412989a 100644 --- a/_includes/welcome.md +++ b/_includes/welcome.md @@ -20,7 +20,6 @@ and examples as they become available. _PHP: The Right Way_ is translated into many different languages: * [English](https://www.phptherightway.com) -* [Deutsch](https://rwetzlmayr.github.io/php-the-right-way) * [Español](https://phpdevenezuela.github.io/php-the-right-way) * [Français](https://eilgin.github.io/php-the-right-way/) * [Indonesia](https://id.phptherightway.com) diff --git a/_layouts/default.html b/_layouts/default.html index 5a4619f..0727f1f 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -2,17 +2,11 @@ - {% if page.title %}{{ page.title }} - {% endif %}PHP: The Right Way - + + {% seo %} + - - - - - - - - + @@ -25,7 +19,7 @@

PHP The Right Way

Last Updated: {{ site.time }}
- Share on Twitter + Share on X
diff --git a/_layouts/page.html b/_layouts/page.html index 35cc108..247a179 100644 --- a/_layouts/page.html +++ b/_layouts/page.html @@ -2,17 +2,11 @@ - {% if page.title %}{{ page.title }} - {% endif %}PHP: The Right Way - + + {% seo %} + - - - - - - - - + @@ -25,7 +19,7 @@

PHP The Right Way

Last Updated: {{ site.time }}
- Share on Twitter + Share on X
diff --git a/_posts/01-02-01-Use-the-Current-Stable-Version.md b/_posts/01-02-01-Use-the-Current-Stable-Version.md index 7df7797..9047574 100644 --- a/_posts/01-02-01-Use-the-Current-Stable-Version.md +++ b/_posts/01-02-01-Use-the-Current-Stable-Version.md @@ -1,14 +1,14 @@ --- -title: Use the Current Stable Version (8.2) +title: Use the Current Stable Version (8.4) isChild: true anchor: use_the_current_stable_version --- -## Use the Current Stable Version (8.2) {#use_the_current_stable_version_title} +## Use the Current Stable Version (8.4) {#use_the_current_stable_version_title} -If you are getting started with PHP, start with the current stable release of [PHP 8.2][php-release]. PHP 8.x adds many [new features](#language_highlights) over the older 7.x and 5.x versions. The engine has been largely re-written, and PHP is now even quicker than older versions. PHP 8 is a major update of the language and contains many new features and optimizations. +If you are getting started with PHP, start with the current stable release of [PHP 8.4][php-release]. PHP 8.x adds many [new features](#language_highlights) over the older 7.x and 5.x versions. The engine has been largely re-written, and PHP is now even quicker than older versions. PHP 8 is a major update of the language and contains many new features and optimizations. -You should try to upgrade to the latest stable version quickly - PHP 7.4 [is already End of Life][php-supported]. Upgrading is easy, as there are not many backwards compatibility breaks [PHP 8.0][php-bc-80], [PHP 8.1][php-bc-81], [PHP 8.2][php-bc-82]. If you are not sure which version a function or feature is in, you can check the PHP documentation on the [php.net][php-docs] website. +You should try to upgrade to the latest stable version quickly - PHP 7.4 [is already End of Life][php-supported]. Upgrading is easy, as there are not many backwards compatibility breaks [PHP 8.0][php-bc-80], [PHP 8.1][php-bc-81], [PHP 8.2][php-bc-82], [PHP 8.3][php-bc-83], [PHP 8.4][php-bc-84]. If you are not sure which version a function or feature is in, you can check the PHP documentation on the [php.net][php-docs] website. [php-release]: https://www.php.net/downloads.php [php-supported]: https://www.php.net/supported-versions.php @@ -16,3 +16,5 @@ You should try to upgrade to the latest stable version quickly - PHP 7.4 [is alr [php-bc-80]: https://www.php.net/manual/migration80.incompatible.php [php-bc-81]: https://www.php.net/manual/migration81.incompatible.php [php-bc-82]: https://www.php.net/manual/migration82.incompatible.php +[php-bc-83]: https://www.php.net/manual/migration83.incompatible.php +[php-bc-84]: https://www.php.net/manual/migration84.incompatible.php diff --git a/_posts/01-04-01-Mac-Setup.md b/_posts/01-04-01-Mac-Setup.md index 5f10ab6..06b6cc1 100644 --- a/_posts/01-04-01-Mac-Setup.md +++ b/_posts/01-04-01-Mac-Setup.md @@ -5,14 +5,14 @@ anchor: mac_setup ## macOS Setup {#mac_setup_title} -macOS comes prepackaged with PHP but it is normally a little behind the latest stable release. There are multiple ways to install the latest PHP version on macOS. +macOS 12 (Monterey) and later does not come prepackaged with PHP. Earlier macOS versions include PHP but are behind the latest stable release. There are multiple ways to install the latest PHP version on macOS. ### Install PHP via Homebrew -[Homebrew] is a package manager for macOS that helps you easily install PHP and various extensions. The Homebrew core repository provides "formulae" for PHP 7.4, 8.0, 8.1 and PHP 8.2. Install the latest version with this command: +[Homebrew] is a package manager for macOS that helps you easily install PHP and various extensions. The Homebrew core repository provides "formulae" for PHP 8.1, 8.2, 8.3 and 8.4. Install the latest version with this command: ``` -brew install php@8.2 +brew install php ``` You can switch between Homebrew PHP versions by modifying your `PATH` variable. Alternatively, you can use [brew-php-switcher][brew-php-switcher] to switch PHP versions automatically. @@ -21,12 +21,12 @@ You can also switch between PHP versions manually by unlinking and linking the w ``` brew unlink php -brew link --overwrite php@8.1 +brew link --overwrite php@8.2 ``` ``` brew unlink php -brew link --overwrite php@8.2 +brew link --overwrite php@8.3 ``` ### Install PHP via Macports @@ -40,14 +40,14 @@ MacPorts supports pre-compiled binaries, so you don't need to recompile every dependency 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 `php54`, `php55`, `php56`, `php70`, `php71`, `php72`, `php73`, `php74`, `php80`, `php81` or `php82` using the `port install` command, for example: +At this point, you can install `php54`, `php55`, `php56`, `php70`, `php71`, `php72`, `php73`, `php74`, `php80`, `php81`, `php82` or `php83` using the `port install` command, for example: sudo port install php74 - sudo port install php82 + sudo port install php83 And you can run `select` command to switch your active PHP: - sudo port select --set php php82 + sudo port select --set php php83 ### Install PHP via phpbrew diff --git a/_posts/02-01-01-Code-Style-Guide.md b/_posts/02-01-01-Code-Style-Guide.md index 06f7c8f..b890309 100644 --- a/_posts/02-01-01-Code-Style-Guide.md +++ b/_posts/02-01-01-Code-Style-Guide.md @@ -39,8 +39,8 @@ And you can run phpcs manually from shell: phpcs -sw --standard=PSR1 file.php It will show errors and describe how to fix them. -It can also be helpful to include this command in a git hook. -That way, branches which contain violations against the chosen standard cannot enter the repository until those +It can also be helpful to include the `phpcs` command in a git pre-commit hook with the `--filter=GitStaged` CLI argument. +That way, code which contain violations against the chosen standard cannot enter the repository until those violations have been fixed. If you have PHP_CodeSniffer, then you can fix the code layout problems reported by it, automatically, with the @@ -65,8 +65,8 @@ Finally, a good supplementary resource for writing clean PHP code is [Clean Code [per-cs]: https://www.php-fig.org/per/coding-style/ [pear-cs]: https://pear.php.net/manual/en/standards.php [symfony-cs]: https://symfony.com/doc/current/contributing/code/standards.html -[phpcs]: https://github.com/squizlabs/PHP_CodeSniffer -[phpcbf]: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Fixing-Errors-Automatically +[phpcs]: https://github.com/PHPCSStandards/PHP_CodeSniffer +[phpcbf]: https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Fixing-Errors-Automatically [st-cs]: https://github.com/benmatselby/sublime-phpcs [phpcsfixer]: https://cs.symfony.com/ [cleancode]: https://github.com/jupeter/clean-code-php diff --git a/_posts/04-01-01-Dependency-Management.md b/_posts/04-01-01-Dependency-Management.md index 8b55043..ed0fe9d 100644 --- a/_posts/04-01-01-Dependency-Management.md +++ b/_posts/04-01-01-Dependency-Management.md @@ -5,7 +5,7 @@ anchor: dependency_management # Dependency Management {#dependency_management_title} 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 +several of them — these are project dependencies. 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. That is no longer an issue. diff --git a/_posts/11-02-01-Test-Driven-Development.md b/_posts/11-02-01-Test-Driven-Development.md index 95a8bea..25b4230 100644 --- a/_posts/11-02-01-Test-Driven-Development.md +++ b/_posts/11-02-01-Test-Driven-Development.md @@ -63,7 +63,8 @@ users of the application. #### Functional Testing Tools -* [Selenium](https://www.selenium.dev/) -* [Mink](https://mink.behat.org/) * [Codeception](https://codeception.com/) is a full-stack testing framework that includes acceptance testing tools -* [Storyplayer](https://datasift.github.io/storyplayer/) is a full-stack testing framework that includes support for creating and destroying test environments on demand +* [Cyress](https://www.cypress.io/) +* [Mink](https://mink.behat.org/) +* [Selenium](https://www.selenium.dev/) +* [Storyplayer](https://github.com/MeltwaterArchive/storyplayer) is a full-stack testing framework that includes support for creating and destroying test environments on demand diff --git a/_posts/14-03-01-Object-Caching.md b/_posts/14-03-01-Object-Caching.md index 07155dc..714df62 100644 --- a/_posts/14-03-01-Object-Caching.md +++ b/_posts/14-03-01-Object-Caching.md @@ -20,9 +20,11 @@ one real limitation of APCu is that it is tied to the server it's installed on. 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. -Note that when running PHP as a (Fast-)CGI application inside your webserver, every PHP process will have its own cache, -i.e. APCu data is not shared between your worker processes. In these cases, you might want to consider using memcached -instead, as it's not tied to the PHP processes. +Note that whether the cache is shared across PHP processes depends on how PHP is used. When running PHP via PHP-FPM, +the cache is shared across all processes of all pools. When running PHP as a (Fast-)CGI application inside your +webserver, the cache is not shared, i.e every PHP process will have its own APCu data. When running PHP on the command +line, the cache is not shared and will only exist for the duration of the command, so you have to be mindful of your +situation and goals. You might want to consider using memcached instead, as it's not tied to the PHP processes. In a networked configuration APCu 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 @@ -42,9 +44,6 @@ if ($data === false) { print_r($data); {% endhighlight %} -Note that prior to PHP 5.5, there was the APC extension which provided both an object cache and a bytecode cache. The new APCu is a project to bring APC's -object cache to PHP 5.5+, since PHP now has a built-in bytecode cache (OPcache). - ### Learn more about popular object caching systems: * [APCu](https://github.com/krakjoe/apcu) diff --git a/_posts/15-02-01-PHPDoc.md b/_posts/15-02-01-PHPDoc.md index 49c3a46..415abc0 100644 --- a/_posts/15-02-01-PHPDoc.md +++ b/_posts/15-02-01-PHPDoc.md @@ -15,7 +15,7 @@ Below is an example of how you might document a class with a few methods; - * @link https://www.phpdoc.org/docs/latest/index.html + * @link https://docs.phpdoc.org/ */ class DateTimeHelper { @@ -70,10 +70,10 @@ difference between the second and third methods' doc block is the inclusion/excl `@return void` explicitly informs us that there is no return; historically omitting the `@return void` statement also results in the same (no return) action. -[tags]: https://docs.phpdoc.org/latest/guide/references/phpdoc/tags/index.html -[PHPDoc manual]: https://docs.phpdoc.org/latest/index.html -[@author]: https://docs.phpdoc.org/latest/guide/references/phpdoc/tags/author.html -[@link]: https://docs.phpdoc.org/latest/guide/references/phpdoc/tags/link.html -[@param]: https://docs.phpdoc.org/latest/guide/references/phpdoc/tags/param.html -[@return]: https://docs.phpdoc.org/latest/guide/references/phpdoc/tags/return.html -[@throws]: https://docs.phpdoc.org/latest/guide/references/phpdoc/tags/throws.html +[tags]: https://docs.phpdoc.org/guide/references/phpdoc/tags/ +[PHPDoc manual]: https://docs.phpdoc.org/ +[@author]: https://docs.phpdoc.org/guide/references/phpdoc/tags/author.html +[@link]: https://docs.phpdoc.org/guide/references/phpdoc/tags/link.html +[@param]: https://docs.phpdoc.org/guide/references/phpdoc/tags/param.html +[@return]: https://docs.phpdoc.org/guide/references/phpdoc/tags/return.html +[@throws]: https://docs.phpdoc.org/guide/references/phpdoc/tags/throws.html diff --git a/_posts/16-03-01-People-to-Follow.md b/_posts/16-03-01-People-to-Follow.md index b96c6bf..b82565f 100644 --- a/_posts/16-03-01-People-to-Follow.md +++ b/_posts/16-03-01-People-to-Follow.md @@ -11,4 +11,4 @@ community members when you are first starting out. You can find an abbreviated list of PHP community members to get you started at: * -* +* diff --git a/_posts/16-05-01-PHP-PaaS-Providers.md b/_posts/16-05-01-PHP-PaaS-Providers.md index 4fee26c..c1fde41 100644 --- a/_posts/16-05-01-PHP-PaaS-Providers.md +++ b/_posts/16-05-01-PHP-PaaS-Providers.md @@ -6,19 +6,19 @@ anchor: php_paas_providers ## PHP PaaS Providers {#php_paas_providers_title} -* [AppFog](https://www.ctl.io/appfog/) * [Amezmo](https://www.amezmo.com) * [AWS Elastic Beanstalk](https://aws.amazon.com/elasticbeanstalk/) * [Cloudways](https://www.cloudways.com/) -* [Divio](https://www.divio.com/php/) +* [DigitalOcean App Platform](https://www.digitalocean.com/products/app-platform) +* [Divio](https://www.divio.com/) * [Engine Yard Cloud](https://www.engineyard.com/) * [fortrabbit](https://www.fortrabbit.com/) * [Google App Engine](https://cloud.google.com/appengine/docs/php/) * [Heroku](https://devcenter.heroku.com/categories/php-support) -* [IBM Cloud](https://console.bluemix.net/docs/runtimes/php/getting-started.html#getting_started) -* [Jelastic](https://jelastic.com/) +* [IBM Cloud](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-prep#prep_php) +* [Lumen](https://www.lumen.com/) * [Microsoft Azure](https://azure.microsoft.com/) -* [Nanobox](https://nanobox.io/) -* [Pivotal Web Services](https://run.pivotal.io/) +* [Pivotal Web Services](https://network.pivotal.io/) * [Platform.sh](https://platform.sh/) * [Red Hat OpenShift](https://www.openshift.com/) +* [Virtuozzo](https://www.virtuozzo.com/application-platform-partners/) diff --git a/_posts/17-01-01-Community.md b/_posts/17-01-01-Community.md index c574e54..cb12a68 100644 --- a/_posts/17-01-01-Community.md +++ b/_posts/17-01-01-Community.md @@ -6,15 +6,16 @@ anchor: community The PHP community is as diverse as it is large, and its members are ready and willing to support new PHP programmers. Consider joining your local PHP user group (PUG) or attending larger PHP conferences to learn more about the best -practices shown here. You can hang out on IRC in the #phpc channel on [irc.freenode.com][php-irc] and follow the -@phpc on [Twitter][phpc-twitter] or [Mastodon][phpc-mastodon]. Get out there, meet new developers, learn new topics, and above all, make new +practices shown here. You can hang out on IRC in the #phpc channel on [irc.libera.chat][php-irc] and follow the +@phpc, on [Discord][php-discord], on [X][phpc-x] or [Mastodon][phpc-mastodon]. Get out there, meet new developers, learn new topics, and above all, make new friends! Other community resources include [StackOverflow][php-so]. [Read the Official PHP Events Calendar][php-calendar] -[php-irc]: https://webchat.freenode.net/?channels=phpc -[phpc-twitter]: https://twitter.com/phpc +[php-irc]: https://web.libera.chat/#phpc +[php-discord]: https://phpc.chat/ +[phpc-x]: https://x.com/phpc [phpc-mastodon]: https://phpc.social/ [php-so]: https://stackoverflow.com/questions/tagged/php [php-calendar]: https://www.php.net/cal.php diff --git a/_posts/17-02-01-User-Groups.md b/_posts/17-02-01-User-Groups.md index 16beb08..89d8d76 100644 --- a/_posts/17-02-01-User-Groups.md +++ b/_posts/17-02-01-User-Groups.md @@ -22,5 +22,5 @@ generally promote the creating of a "female friendly" and professional atmospher [meetup]: https://www.meetup.com/find/ [php-ug]: https://php.ug/ [NomadPHP]: https://nomadphp.com/ -[PHPWomen]: https://twitter.com/PHPWomen +[PHPWomen]: https://x.com/PHPWomen [php-wiki]: https://wiki.php.net/usergroups diff --git a/index.html b/index.html index aaa39c0..783d636 100644 --- a/index.html +++ b/index.html @@ -1,6 +1,5 @@ --- 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 ---