Questions tagged [php-8.1]

For questions specific to the usage and new features of PHP 8.1. Also, include the more generic [php] tag when using this tag.

PHP 8.1 (released November 2021) includes many new features including:

A full list of changes can be found in the migration guide.

336 questions
2
votes
1 answer

PHP8.1-fpm: pdo-mysql installed but not appear on php -m

i have install php8.1-fpm and setup it with apache2/FGPI. But after many operation, impossible to "enable pdo-mysql". i have make this sudo apt-get install php8.1-pdo-mysql with result Note, selecting 'php8.1-mysql' instead of…
Alex
  • 77
  • 1
  • 1
  • 7
2
votes
0 answers

Why PHP 8.1 Sodium PHP-Extension shows enabled but .iso file is not in extension folder

Why the php cli command "php -m" and also phpinfo() both show "sodium" php-extension as enabled / loaded, although there is no sodium.iso file in extension folder "/usr/lib/php/20210902" and no *.ini file of no SAPI's showing as enabling it…
Fakhar Anwar
  • 21
  • 1
  • 4
2
votes
1 answer

Did PHP 8.1 break functionality of internal class SoapClient?

While making a library, that uses PHP's SoapClient, compatible with PHP 8.1 I came across this issue: All properties of SoapClient are now private when they where public before. So things like getting the last soap fault ($soapClient->__soap_fault)…
Marc S.
  • 23
  • 6
2
votes
1 answer

How to mock/work with public readonly properties in unit tests

before PHP 8.1 we would have something like this:
Urst
  • 21
  • 3
2
votes
1 answer

Is there a way to install laravel 9 on your machine with out having php 8 on your machine?

I tried creating larvel 9 project using composer. Since my machine don't have php 8 installed on it. While running command composer create-project laravel/laravel --prefer-dist myapp, a laravel 8 project is created. While running composer…
2
votes
0 answers

PHP 8.1.4 - Opcache runs out of memory

I've been having trouble where TTFB would increase after a few hours. I initially thought it was due to something in IIS, but it turns out it's actually opcache. I also noticed the "manual restarts" value keeps increasing. No manual restarts are…
ChrisB3127
  • 31
  • 3
2
votes
1 answer

Doctrine 2 native PHP 8.1 enum support - using enum with query builder doesn't work

Doctrine added native support for PHP8.1 enumeration types. It looks like it works on entity side as expected (saving entity on DB and hydration while fetching entity works as intended). But while I try to fetch entity using repository query builder…
imclickingmaniac
  • 1,467
  • 1
  • 16
  • 28
2
votes
0 answers

vscode + PHP intelephense named arguments from PHP 8.1 shown as errors

In code written in PHP8.1 I use named arguments in a method call: // function definition public function myFunction(string $name, string $description = "") // method call with errors ->myFunction(name: self::SOME_CONSTANT) however extension PHP…
jave.web
  • 13,880
  • 12
  • 91
  • 125
2
votes
3 answers

How do you access attributes on enum cases?

According to the RFC on Enumerations, attributes can be added to cases by using Attribute::TARGET_CLASS_CONSTANT. (Actually, the RFC says TARGET_CLASS_CONST but that is either a typo or a later change.) I'm having trouble trying to access them using…
Chris Haas
  • 53,986
  • 12
  • 141
  • 274
2
votes
1 answer

PHP public readonly properties vs private field with getter

PHP 8.1 introduces readonly class properties. For example, before I would write: class User { public string $name; public function __construct(string $name) { $this->name = $name; } public getName(): string { return…
Duncan Lukkenaer
  • 12,050
  • 13
  • 64
  • 97
2
votes
0 answers

Symfony CollectionType Entity constructor arguments

Form: $builder->add('positions', CollectionType::class, [ 'entry_type' => FooPositionType::class, 'allow_add' => true, 'allow_delete' => true, 'delete_empty' => true, 'prototype' => true, 'prototype_data' => (new…
mhpcc
  • 120
  • 1
  • 12
2
votes
1 answer

Implementing JsonSerializable by a Pure Enum

According to the PHP manual If a Pure Enum is serialized to JSON, an error will be thrown. If a Backed Enum is serialized to JSON, it will be represented by its value scalar only, in the appropriate type. The behavior of both may be overridden by…
Rain
  • 3,416
  • 3
  • 24
  • 40
1
vote
0 answers

What could cause Laravel to read from another project's ENV file?

I am using XAMPP with 3 projects in the htdocs folder. suddenly one of the Laravel projects started reading the .env values of another project. After I restarted XAMPP it was fixed. Each project is using its own local domain in the hosts file
pileup
  • 1
  • 2
  • 18
  • 45
1
vote
0 answers

Nextcloud Fatal Error Insufficient shared memory

I get this message immediately after reboot trying to run a php script: # sudo -u apache php updater.phar Mon Jul 31 17:59:24 2023 (2241): Fatal Error Insufficient shared memory! It is a Nextcloud upgrade script. Also these messages in the…
Clodoaldo Neto
  • 118,695
  • 26
  • 233
  • 260
1
vote
0 answers

After migrating pimcore 6.9 to 10.6 successfully, admin interface has router issue

After migrating pimcore 6.9 to 10.6 successfully, admin interface has router issue I have changed routing as per symfony flex document, But getting this error Also please help me to organize existing bundle after migrating to pimcore 10.6…
Thejaswini
  • 11
  • 2