• Overview
    Key features
    • Observability
    • Auto-scaling
    • Multiframework
    • Security
    Frameworks
    • Django
    • Next.js
    • Drupal
    • WordPress
    • Symfony
    • Magento
    • See all frameworks
    Languages
    • PHP
    • Python
    • Node.js
    • Ruby
    • Java
    • Go
  • Industries
    • Consumer Goods
    • Media/Entertainment
    • Higher Education
    • Government
    • Ecommerce
  • Pricing
  • Featured articles
    • Switching to Platform.sh can help IT/DevOps organizations drive 219% ROI
    • Organizations, the ultimate way to manage your users and projects
  • Support
  • Docs
  • Login
  • Request a demo
  • Free Trial
Meet Upsun. The new, self-service, fully managed PaaS, powered by Platform.sh.Try it now
Blog

A festive treat: PHP 8.3 is already available on Platform.sh

phpimprovementsupdates
06 December, 2023
Rémi Lejeune
Rémi Lejeune
Product Manager

Just like the feeling you get when you hear the first notes of Mariah Carey's "All I Want for Christmas Is You" signaling the arrival of the festive season, PHP developers can also rejoice in the release of a special gift this month—PHP 8.3.

As many of you may already know, a few days ago PHP 8.3 was released and after some testing, it’s now ready to use on all Platform.sh projects.

In this article, we’re going to share some of the noteworthy features that PHP 8.3 has to offer but if you want to get straight to testing it our for yourself, simply implement this single code change into your .platform.app.yaml and get started:

type: php:8.3

Now, let’s unwrap those shiny new features from PHP 8.3!

1. Type class constants

A significant enhancement of PHP 8.3 is that it allows developers to explicitly define the data type of a class constant. Marking a departure from the previous untyped approach, where the data type of a class constant was determined by its assigned value. Developers can now specify the data type—such as int, string, or bool—directly in the constant declaration. This not only improves type safety by preventing incompatible data type assignments but also enhances code readability by making the intended data type clear and unambiguous.

2. Dynamic class constant fetch

PHP 8.3 also allows developers to access constants using their names as strings using the C::{$name} syntax. This simplifies constant access, especially for constants defined in parent classes or interfaces, allowing for a far more efficient workflow.

3. New #[\Override] attribute

Developers can now explicitly mark methods as overriding methods from their parent class with this latest update. This explicit declaration improves code clarity, prevents unintended overrides, and facilitates refactoring.

4. Deep-cloning of readonly properties

PHP 8.3 introduces the ability to deep-clone readonly properties, ensuring that cloned objects retain the values of their readonly properties. This enhances object cloning and promotes consistent data handling for PHP projects.

5. New json_validate() function

The new json_validate() function simplifies JSON data validation by directly evaluating JSON strings without the need for decoding. Enabling developers to validate JSON data with greater efficiency and accuracy than ever before with PHP.

6. New Randomizer::getBytesFromString() method

PHP 8.3’s new Randomizer::getBytesFromString() method provides a convenient way to generate random byte sequences from specific strings. Developers can now efficiently create customized random sequences for enhanced security and unpredictability.

7. New Randomizer::getFloat() and Randomizer::nextFloat() methods

These two new methods simplify the generation of random floating-point numbers within specific ranges: Randomizer::getFloat() and Randomizer::nextFloat(). Developers can now generate random numbers with greater precision and an unbiased fashion.

Unlocking new horizons of performance optimization with PHP 8.3 and Blackfire

As PHP continues to evolve, Blackfire remains steadfast in its commitment to providing comprehensive performance profiling and optimization solutions for PHP applications. With the release of PHP 8.3, Blackfire seamlessly integrates with this latest version, empowering developers to harness the full potential of PHP's performance enhancements.

Update your Platform.sh yaml file with the PHP single code change and you can access both with your Platform.sh projects in no time. Take a look at the step-by-step guide below to find out how:

How to update your application for PHP 8.3

To transition your PHP application to PHP 8.3, follow these simple steps:

Step 1: Create a new branch

Start by creating a new branch to validate your application against PHP 8.3 on an isolated preview environment.

$ platform checkout main
$ platform branch upgrade-php-8.3

 

Step 2: Update the .platform.app.yaml file

Then modify your .platform.app.yaml file to specify PHP 8.3 as the desired PHP version:

type: php:8.3

 

Step 3: Test and verify

Deploy the new code and test your application thoroughly in the preview environment to ensure compatibility with PHP 8.3 and Blackfire:

$ git add .platform.app.yaml && git commit -m "Upgrade PHP to v8.3"
$ platform deploy

 

Step 4: Deploy to production

Once testing is complete and the application functions as expected, deploy the updated codebase to the production environment:

$ platform checkout main
$ platform merge upgrade-php-8.3

And just like that, you’re applications will be updated with the PHP version 8.3. Happy deploying!

If you want to get involved in the conversation on any Platform.sh-related topic join our public Slack channel or catch us over on our community website.

Get the latest Platform.sh news and resources
Subscribe

Related Content

Standardizing your web application stack and how to do it

Standardizing your web application stack and how to do it

Company
AboutSecurity and complianceTrust CenterCareersPressContact us
Thank you for subscribing!
  •  
Field required
Leader Winter 2023
System StatusPrivacyTerms of ServiceImpressumWCAG ComplianceAcceptable Use PolicyManage your cookie preferencesReport a security issue
© 2024 Platform.sh. All rights reserved.
Supported by Horizon 2020's SME Instrument - European Commission 🇪🇺