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
1
vote
1 answer

PHP 8.1 Redis session handler issue

Warning: ini_set(): Session save handler "redis" cannot be found on my page where I have use the code as shown below ini_set('session.save_handler', 'redis'); This code works fine if the PHP version is 7.4 but when I upgraded PHP to PHP8 or PHP8.1…
ashokostech
  • 307
  • 1
  • 5
  • 11
1
vote
1 answer

How to setup PDO Informix (php_pdo_informix) with PHP version 8 (8.0 and/or 8.1)?

My project is running on PHP-laravel(PHP 8.0) + vuejs. I'm trying to set up pdo Informix with PHP. Firstly, I tried using docker setup (including PHP 8.0, Nginx, MSSQL, Debian) and then I tried with wamp setup. I have set up IBM client SDK for both…
1
vote
0 answers

How to install memcached in PHP 8.1 using Wamp Server

I need to set up memcached in my application, I am using PHP 8.1 and Wamp is my local server. I have added php_memcached.dll file in my php ext folder and also extension=php_memcached.dll added in php.ini. After that I have restarted my Wamp I have…
1
vote
2 answers

Laravel return different timestamp from database using eloquent

I'm using Laravel Framework 9.37.0 PHP 8.1.10 Using postman for get and add data I try to get data from MySQL database using eloquent $investment = Investment::where('user_id', $user_id)->orderBy('created_at', 'DESC')->get(); return…
1
vote
2 answers

PHP: pthreads not loading on PHP 8.1

I'm trying to add pthreads extension on PHP 8.1 TS and it doesn't seem to work, It's sayin that it is not installed while in fact it is. PHP -v PHP 8.1.10 (cli) (built: Aug 30 2022 18:05:49) (ZTS Visual C++ 2019 x64) Copyright (c) The PHP Group Zend…
Kaloyan Nikolov
  • 91
  • 1
  • 1
  • 10
1
vote
1 answer

PHP enums always throws a Parse error Unexpected T_STRING

I am trying out the new PHP 8.1 enums. What appeared to be simple, drives me crazy. I have an enum and want to get the back the status as a string back. Every time I run the script, I get the following parse error: ParseError : syntax error,…
Jake
  • 175
  • 6
  • 17
1
vote
2 answers

PHP Excel export box/spout replacement

I am using the box/spout library for exporting simple Excel files and it is no longer maintained and I wonder what solution I should choose for the current and also future projects. Box/spout was much faster than the library I used before and as…
Calamity Jane
  • 2,189
  • 5
  • 36
  • 68
1
vote
0 answers

Doctrine2 and backed enums from php8 – how to migrate from myclabs?

I'm migrating from php 7.4 to 8.1. Other versions are: PHP 8.1, Doctrine 2.13, Symfony 5.4, ApiPlatform 2.7, myclabs/php-enum 1.8. I've updated my code to use baked enums as said here: https://www.doctrine-project.org/2022/01/11/orm-2.11.html . But…
trogwar
  • 216
  • 1
  • 11
  • 26
1
vote
0 answers

Laravel queue job only works when I clear browser cache?

Goal: is to dispatch job: right after user is logged in into the system. So I have placed dispatch code in: app/Http/Middleware/RedirectIfAuthenticated.php class RedirectIfAuthenticated { /** * Handle an incoming request. * *…
Vipertecpro
  • 3,056
  • 2
  • 24
  • 43
1
vote
0 answers

Declaration of ChildClass::someMethod must be compatible with BaseClass::someMethod

So I have 4 classes class BaseConstraints {} class ChildConstraints extends BaseConstraints {} class BaseClass { function someMethod(BaseConstraints $baseConstraints) {} } class ChildClass extends BaseClass { function…
Christoph
  • 978
  • 7
  • 17
1
vote
1 answer

Docker Image PHP 8.1.10 with Xdebug doesn't work with PhpStorm

I have a problem with Xdebug, this is my Docker configuration: Dockerfile: FROM php:8.1.10-fpm-alpine RUN apk update RUN apk add php81-dev gcc make g++ zlib-dev icu-dev bash git openssl yaml-dev RUN pecl channel-update pecl.php.net # For YAML RUN…
Mitsukk
  • 314
  • 2
  • 13
1
vote
0 answers

parrot os Unable to locate /install php package 8.1

I have been trying to install PHP 8+ on my Parrot 5.0 but nothing works. I tried following Instructions on Digital Ocean I also tried running and adding the repo sudo add-apt-repository ppa:ondrej/php but it gives me this error described in this…
1
vote
0 answers

How to get random value from enum class in PHP?

This is my enum class. I want a random value every time from this enum class. I am using the PHP 8.1 enum feature. declare(strict_types=1); namespace App\Enums; enum Division: string { case BARISAL = 'barisal'; case CHITTAGONG =…
1
vote
1 answer

Laravel 9 How to Validate Optional Enum Values

I'm using the new enum class in my Laravel application and want to validate optional parameters. I'm able to validate enum parameters if I pass them, but if I don't pass anything, I get the error, "Undefined array key". My enum class is: enum…
Josh
  • 714
  • 2
  • 8
  • 20
1
vote
2 answers

Illuminate\Database\Grammar::parameterize(): Argument #1 ($values) must be of type array, string given

I am trying to Seed a database using a Model Factory in Laravel but am seeing this error on the terminal. $ php artisan tinker Psy Shell v0.11.8 (PHP 8.1.0 — cli) by Justin Hileman >>> Parking::factory(1)->create(); [!] Aliasing 'Parking' to…
John
  • 361
  • 4
  • 12