Merge branch 'gh-pages' into patch-rpm

This commit is contained in:
Phil Sturgeon
2025-04-23 21:49:19 +02:00
committed by GitHub
18 changed files with 73 additions and 73 deletions

View File

@@ -1,3 +1,3 @@
Copyright (c) 2013 Josh Lockhart
Copyright (c) 2025 Josh Lockhart
https://creativecommons.org/licenses/by-nc-sa/3.0/

View File

@@ -36,7 +36,6 @@ You should read the `CONTRIBUTING.md` file for precise instructions and tips. Bu
<https://www.phptherightway.com>
* [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

View File

@@ -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

View File

@@ -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)

View File

@@ -2,17 +2,11 @@
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>{% if page.title %}{{ page.title }} - {% endif %}PHP: The Right Way</title>
<meta name="description" content="{{ page.description }}"/>
{% seo %}
<meta name="robots" content="index,follow,archive"/>
<meta property="og:image:url" content="https://www.phptherightway.com/images/og-image.png"/>
<meta property="og:image:width" content="1024"/>
<meta property="og:image:height" content="640"/>
<meta property="og:title" content="PHP: The Right Way"/>
<meta property="og:description" content="An easy-to-read, quick reference for PHP best practices, accepted coding standards, and links to authoritative PHP tutorials around the Web"/>
<meta property="og:url" content="https://www.phptherightway.com"/>
<meta property="og:site_name" content="PHP: The Right Way"/>
<meta property="og:type" content="website"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<link rel="icon" href="{{ site.baseurl }}images/favicon.png" type="image/png"/>
<link rel="stylesheet" href="{{ site.baseurl }}styles/syntax.css">
@@ -25,7 +19,7 @@
<h1><a href="/">PHP <em>The Right Way</em></a></h1>
<div class="build-date">Last Updated: {{ site.time }}</div>
<div class="share">
<a class="btn-share" href="https://twitter.com/intent/tweet?text=PHP+The+Right+Way&amp;url=https%3A%2F%2Fwww.phptherightway.com&amp;hashtags=PHP" target="_blank">Share on Twitter</a>
<a class="btn-share" href="https://x.com/intent/tweet?text=PHP+The+Right+Way&amp;url=https%3A%2F%2Fwww.phptherightway.com&amp;hashtags=PHP" target="_blank">Share on X</a>
</div>
<a class="fork-me" href="https://github.com/codeguy/php-the-right-way" target="_blank"></a>
</header>

View File

@@ -2,17 +2,11 @@
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>{% if page.title %}{{ page.title }} - {% endif %}PHP: The Right Way</title>
<meta name="description" content="{{ page.description }}"/>
{% seo %}
<meta name="robots" content="index,follow,archive"/>
<meta property="og:image:url" content="https://www.phptherightway.com/images/og-image.png"/>
<meta property="og:image:width" content="1024"/>
<meta property="og:image:height" content="640"/>
<meta property="og:title" content="PHP: The Right Way"/>
<meta property="og:description" content="An easy-to-read, quick reference for PHP best practices, accepted coding standards, and links to authoritative PHP tutorials around the Web"/>
<meta property="og:url" content="https://www.phptherightway.com"/>
<meta property="og:site_name" content="PHP: The Right Way"/>
<meta property="og:type" content="website"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<link rel="icon" href="{{ site.baseurl }}images/favicon.png" type="image/png"/>
<link rel="stylesheet" href="{{ site.baseurl }}styles/syntax.css">
@@ -25,7 +19,7 @@
<h1><a href="/">PHP <em>The Right Way</em></a></h1>
<div class="build-date">Last Updated: {{ site.time }}</div>
<div class="share">
<a class="btn-share" href="https://twitter.com/intent/tweet?text=PHP+The+Right+Way&amp;url=https%3A%2F%2Fwww.phptherightway.com&amp;hashtags=PHP" target="_blank">Share on Twitter</a>
<a class="btn-share" href="https://x.com/intent/tweet?text=PHP+The+Right+Way&amp;url=https%3A%2F%2Fwww.phptherightway.com&amp;hashtags=PHP" target="_blank">Share on X</a>
</div>
<a class="fork-me" href="https://github.com/codeguy/php-the-right-way" target="_blank"></a>
</header>

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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.

View File

@@ -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

View File

@@ -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)

View File

@@ -15,7 +15,7 @@ Below is an example of how you might document a class with a few methods;
<?php
/**
* @author A Name <a.name@example.com>
* @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

View File

@@ -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:
* <https://www.ogprogrammer.com/2017/06/28/how-to-get-connected-with-the-php-community/>
* <https://twitter.com/CalEvans/lists/phpeople>
* <https://x.com/CalEvans/lists/phpeople>

View File

@@ -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/)

View File

@@ -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

View File

@@ -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

View File

@@ -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
---