PHP and Laravel Version

Get familiar with the PHP and Laravel versions used in this course.

We'll cover the following

PHP version

Throughout this course, we will explore many different concepts and ideas through many code examples. PHP 8.1.12 was used throughout the writing process, but the code examples can be adapted to any modern PHP version.

As a consequence of deciding to use PHP 8.1.12, there was no consideration made for the overloading of the standard string functions using PHP’s function overloading feature because this was removed in PHP version 8.1.12.

You can consult the official documentation for more information about PHP’s removed function overloading feature.

<?php
// prints e.g. 'Current PHP version: 8.1.12'
 phpversion();
PHP version check

Laravel version

Laravel version 9.26.1 was used when writing the examples that we will find throughout the course. Because of the frequency of updates to the Laravel framework, there might be delays in seeing newly added helper methods covered throughout the various chapters.

Although we will assume Laravel version 9 for our code examples and exercises, the method signatures will outline any difference between Laravel 8 and Laravel 9 to help upgrade processes.

When we introduce new helper methods throughout the course, we will see an overview of their signature. Where we would typically see a description of the method in typical PHP source code, we will see which versions of the Laravel framework support the helper method.

For example, the lcfirst helper method was introduced in Laravel 9 and will have the following method signature:

Press + to interact
<?php
/**
* Version: Laravel 9
*
* @return string
*/
public static function lcfirst(
string $string
);

In contrast, the lower helper method appears in Laravel versions 8 and 9, with no differences in the method signature between the two versions:

Press + to interact
<?php
/**
* Versions: Laravel 8, 9
*
* @return string
*/
public static function lower(
string $value
);

If a helper method is present in both Laravel 8 and 9 but has a different signature between the two versions, the method signature will list both so we can more easily see the differences. An example of this is the wordCount method signature:

Press + to interact
<?php
// Version: Laravel 8
public static function wordCount(
string $string
);
// Version: Laravel 9
public static function wordCount(
string $string,
string|null $characters = null
);