617 questions
5
votes
3
answers
391
views
Increment on non-numeric string is deprecated, use str_increment() instead
We are migrating a legacy PHP application to PHP 8.5. We must also support outdated PHP versions, i.e. before PHP 8.3.
I have some code increasing a variable with a letter:
$d = 'H';
++$d;
This ...
2
votes
1
answer
206
views
fopen and stream_select not working after PHP 8 upgrade
I upgraded a PHP 7 application to PHP 8. The following code was working before, but no longer:
$options = [
'http' => [
'method' => 'POST',
'header' => "Content-Type: ...
Best practices
0
votes
11
replies
6k
views
How does a recursive function work in PHP?
Edit: How does this recursive call play out, why is i = 1, even though the function fires 3 times ?
Doesn't the function reach the if statement -> fires -> (this repeats 3 times) then reaches ...
1
vote
1
answer
227
views
Typed property App\Entity\X:X must not be accessed before initialization
I'm trying to upgrade my Symfony from 5.4 to 6.4 and PHP from 7.4 to 8.4. I almost did all changes but I'm currently blocked on this exception :
Typed property App\Entity\AppRole::$uniqid must not be ...
2
votes
2
answers
132
views
PHP new DateTime() with unix timestamp ignores Timezone for application and also explicit Timezone in constructor
I have an object which have created property like unix timestamp integer.
I try to convert this property to DateTime object and supposed the PHP will set up correct Timezone according application ...
2
votes
2
answers
282
views
Is there a way to use both named args and variable args in a function call?
Going through a code review and found named argument call being used to a argument that uses the spread operator for variable args (vargs). To my suprise it works fine for 1 argument, but I cannot ...
0
votes
1
answer
72
views
Php script returns full log when testing with cuRL
Doing my first steps with php and I am a bit confused. I have written a small script, which should take a POST request with some data, put the data in a formatted email and send it. For this I simply ...
-3
votes
1
answer
197
views
Simple NULL checking in PHP using Null Safe? [closed]
I'm clearly late to the Null Safe party and trying to catch up. For some reason I can't get my head wrapped around it.
I have lots of instances in my PHP code like:
if($_POST['submit'] == NULL){
**...
1
vote
0
answers
95
views
shell_exec does not support 24bits nor 8 bits color mode
I'm running a command with shell_exec from ascii-image-converter
(https://github.com/TheZoraiz/ascii-image-converter)
which return
<?php
$cmd = "ascii-image-converter $fichier -s ./assets/...
0
votes
0
answers
48
views
Is it possible to have full sql queries in the stack trace? [duplicate]
I wasn't able to locate a solution to this online, google was not being my friend today. Recently we did a PHP upgrade to 8.3 on our webserver at work, from PHP 5.6.12, which was quite a heavy lift. ...
1
vote
2
answers
401
views
How to Optimize Memory Usage in PHP When Processing Large CSV Files Without Hitting the Memory Limit?
I’m working on a PHP script that processes large CSV files (up to 1GB in size) by reading the file, performing some transformations on each row, and then saving the results to a database. My current ...
1
vote
0
answers
129
views
Trying to use a2lix/TranslationFormBundle with #[Gedmo\Translatable]
I’m currently facing an issue with translating certain fields in my form. The error I’m encountering is:
Field 'name' doesn't exist in App\Entity\ModuleTranslation
It appears that the system is ...
1
vote
1
answer
115
views
Wrong Carbon\Carbon namespace for date property genrated by sethsandaru/eloquent-docs
I am upgrading laravel 10 project to version 11. I have upgraded
sethphat/eloquent-docs package to v2.0.1
user001@DEV:~/projects/my-project$ composer show sethphat/eloquent-docs
name : sethphat/...
0
votes
1
answer
82
views
Can I use automatic casting by setting $cast property in model definition?
On laravel 10 site I use enums, defined like :
namespace App\Enums;
...
enum PointsStatusEnum: string
{
case STATUS_BEGIN = 'B';
...
public static function getCasesArray(): array
{...
0
votes
1
answer
151
views
use $this->authorizeResource in __construct() method in laravel controller
this my __construct() method :
public function __construct(){
$this->authorizeResource(Event::class, 'event');
}
but i have this error:
Undefined method 'authorizeResource'.
I saw a tutorial ...