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
0
votes
2 answers

PHP 8.1 - Laravel - Geoip find timezone by country and region

I want to find the timezone with the country and region using geoip_time_zone_by_country_and_region() but seems it needs geoip ext to be installed which is not supported anymore and seems geoip2 just works with IP but I want to get the timezone by…
alireza alizade
  • 178
  • 4
  • 14
0
votes
2 answers

PHP Deprecated: Automatic conversion of false to array is deprecated

I can't figured out whats wrong with this. PHP 8.1 PHP Deprecated: Automatic conversion of false to array is deprecated $request = parse_url( $_SERVER['REQUEST_URI'] ); $request['path'] = ( ! empty( $request['path'] ) ) ?…
Nuno Sarmento
  • 415
  • 5
  • 15
0
votes
0 answers

How to write a unit test for a class method with dependency injection?

I am learning Unit test in Symfony. I have a class that makes a client request class Client { public function __construct( private readonly string $url, private readonly HttpClientInterface $httpClient ) { } /** …
user1687891
  • 794
  • 2
  • 14
  • 30
0
votes
0 answers

base64_decode is not working with php8.1 & magento 2.4.4

We are using Magento 2.4.4 on php8.1 and one of the magento core file is having a method which is using base64_decode() method. Can you please suggest alternate of base64_decode(); $filterString = base64_decode($filterString);
Ram Sharma
  • 8,676
  • 7
  • 43
  • 56
0
votes
1 answer

Call to undefined function ssh2_connect() after PHP 8.1.14 update

After updating PHP 8.1 on Jan 7 2023 we began seeing "Call to undefined function ssh2_connect()" in previously working scripts. The Jan 5 PHP release changelog does not mention SSH at all. Apache2 has been manually restarted and eventually a full…
jerrygarciuh
  • 21,158
  • 26
  • 82
  • 139
0
votes
1 answer

How do I dynamically write a PHP object property name and set value?

I am using this to set the value. $gallery = setDateFrom('2023-01-01'); But fields are coming in an array ['dateFrom', 'dateTo'] $classKey = 'set' . ucfirst($key); $gallery->{$classKey}; I am not able to add date to this property. I tried…
nas
  • 2,289
  • 5
  • 32
  • 67
0
votes
1 answer

PHP 8.x Array to string conversion error in function validate_optional_fields in PHP-Nuke Titanium

I must be missing something... This is suppose to do supplementary validation of optional profile fields. This expects common stuff like trim() and strip_tags() to have already been run. Params are passed by-ref, so I can set them to an empty string…
0
votes
0 answers

"Class XXX is not a valid entity or mapped super class" after create folder inside Entity

I am getting error Class "App\Entity\Admin\User" is not a valid entity or mapped super class. I have a folder Admin under Entity which includes entities required for admin. User.php namespace App\Entity\Admin; use DateTime; use…
nas
  • 2,289
  • 5
  • 32
  • 67
0
votes
1 answer

Implode an array of enums in php 8.1

Is there an easy way to implode an array of enums ? enum Fruits: string{ case APPLE = 'apple'; case PEAR = 'pear'; case ORANGE = 'orange'; } /* * @param array|null $fruits */ function setInDB ( ... $fruits ... ){ ... …
J.BizMai
  • 2,621
  • 3
  • 25
  • 49
0
votes
0 answers

Wordpress React JS based template website not working after upgrading to PHP 8.1

After switching from PHP 7.4.30 to PHP 8.1, my WordPress website, which was built by the original developer using React JS, started acting strangely. The menus stopped working and the home page became frozen and immovable. Enable the debug and below…
wikis
  • 15
  • 3
0
votes
0 answers

Drupal does not work in Azure App Service

When I upload the source code of Drupal 9 with php 8.1 in Azure App Service, and then I run the installation, all goes well, but when the installation process finishes, it suddenly gives me 404 error, index.php not found. I've tried with the…
Raul Mercado
  • 324
  • 1
  • 4
  • 14
0
votes
1 answer

Mamp Pro renders without styles in Firefox but correctly in other browsers

for years I've used Mamp (free), but now I pretend to buy pro version, so I've recently installed demo of Mamp Pro and made a few sites work, however, there is one Drupal 9 site that works fine in most browsers, except in Firefox. It renders a…
Ricardo Castañeda
  • 5,746
  • 6
  • 28
  • 41
0
votes
1 answer

Symfony ApiPlatform 3.0.6 POST route Abstract Item normalizer error

I am in the middle of upgrading a project from API 2.7 to API 3.0 and have trouble with this POST route This is my request body: [ { "name": "firstName", "width": "10%", "priority": 1 }, { "name": "lastName", "width":…
fuqeba
  • 1
  • 1
0
votes
1 answer

imagettftext function in php causing error

I am trying to generate captcha image using php and this line in my code is causing a problem: $x = ($captchaWidth - $text_box[4])/2; //49.5 $y = ($captchaHeight - $text_box[5])/2; //9.5 imagettftext( <-- This part is causing the error …
0
votes
0 answers

Mapped super class error after creating entity inside folder

I created a folder Admin under Entity folder. Inside Admin, there is an entity User.php namespace App\Entity\Admin; use App\Repository\Admin\UserRepository; use DateTime; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; use…
nas
  • 2,289
  • 5
  • 32
  • 67