I just realized backed enum cannot be printed directly
I was using some backed enums and realized that eums cannot be printed directly or passed to functions like fputcsv, even though there is a text rappresentation of them. Also, you cannot implement stringable.
I also found a few rfc talking about this:
[https://wiki.php.net/rfc/enumerations#auto-scalar\_conversion](https://wiki.php.net/rfc/enumerations#auto-scalar_conversion)
https://wiki.php.net/rfc/auto-implement\_stringable\_for\_string\_backed\_enums
In the first RFC, I guess it made sense at that time hold back on this behaviour. Instead, do you know what happend to the second RFC?
Maybe this discussion could be reopened now that enums are more battle tested?
https://redd.it/1k19onm
@r_php
I was using some backed enums and realized that eums cannot be printed directly or passed to functions like fputcsv, even though there is a text rappresentation of them. Also, you cannot implement stringable.
I also found a few rfc talking about this:
[https://wiki.php.net/rfc/enumerations#auto-scalar\_conversion](https://wiki.php.net/rfc/enumerations#auto-scalar_conversion)
https://wiki.php.net/rfc/auto-implement\_stringable\_for\_string\_backed\_enums
In the first RFC, I guess it made sense at that time hold back on this behaviour. Instead, do you know what happend to the second RFC?
Maybe this discussion could be reopened now that enums are more battle tested?
https://redd.it/1k19onm
@r_php
Laravel 12.9 Introduces Memoized Cache Driver
https://nabilhassen.com/laravel-129-introduces-memoized-cache-driver
https://redd.it/1k1chxr
@r_php
https://nabilhassen.com/laravel-129-introduces-memoized-cache-driver
https://redd.it/1k1chxr
@r_php
Nabilhassen
Laravel 12.9 Introduces Memoized Cache Driver
Laravel now includes a memoized cache driver that stores retrieved values in memory per request, reducing repeated access to the underlying cache store.
Facebook marketing api
Hello,
I am working in a legacy facebook marketing api. The legacy code does daily +4000 api query per day. To handle this the legacy code use proc_open and sleep for 5 sec for every chunk of apis. The code create some CSV and after finishing all the api calls it merge all CSV to one CSV to import later on db.
This solution works fine sometimes and sometimes freezes without any error. So I thought to refactor with laravel jobs/queues. Any one have been working with facebook apo or laravel queue to handle thousand of api calls?
https://redd.it/1k1gjjt
@r_php
Hello,
I am working in a legacy facebook marketing api. The legacy code does daily +4000 api query per day. To handle this the legacy code use proc_open and sleep for 5 sec for every chunk of apis. The code create some CSV and after finishing all the api calls it merge all CSV to one CSV to import later on db.
This solution works fine sometimes and sometimes freezes without any error. So I thought to refactor with laravel jobs/queues. Any one have been working with facebook apo or laravel queue to handle thousand of api calls?
https://redd.it/1k1gjjt
@r_php
Reddit
From the PHP community on Reddit
Explore this post and more from the PHP community
Model except(), assertThrowsNothing & Arr::sole() in Laravel 12.4
https://youtu.be/w1WqD8V4xvU
https://redd.it/1k1kg7t
@r_php
https://youtu.be/w1WqD8V4xvU
https://redd.it/1k1kg7t
@r_php
YouTube
Model except(), assertThrowsNothing & Arr::sole() in Laravel 12.4
What's new in Laravel is back! We share new features of the Laravel framework every week 🙌 (v12.4)
1️⃣ Add except() method to Model class
https://github.com/laravel/framework/pull/55072
2️⃣ Add assertThrowsNothing
https://github.com/laravel/framework/pull/55100…
1️⃣ Add except() method to Model class
https://github.com/laravel/framework/pull/55072
2️⃣ Add assertThrowsNothing
https://github.com/laravel/framework/pull/55100…
Trying to make coding content that’s actually useful. How am I doing?
https://youtu.be/JFc2De9vID0?si=Jy59VU3Qj2BmJE8j
https://redd.it/1k1nnhc
@r_php
https://youtu.be/JFc2De9vID0?si=Jy59VU3Qj2BmJE8j
https://redd.it/1k1nnhc
@r_php
YouTube
Learn to Code Like a Pro – HTML, CSS & JavaScript Explained by two @Microsoft Developers
Welcome to CodeCoach, the ultimate destination for learning to code fast, free, and efficiently! 💡 Our startup is powered by 15+ industry experts with over 15 years of hands-on experience, dedicated to helping you master web development.
In this video…
In this video…
Issue with doctrine flushing objects after exception
I'm running a Symfony command and the persists and flushes seem to work just fine until I throw an exception and the persists and flushes seem to stop working
here's the code:
try {
throw new \Exception("foo");
$successEvent = $this->dispatcher->dispatch($totalChargeEvent, 'billing.charge.card');
} catch (\Exception $e) {
$this->markSubnoscriptionsCanceled($subnoscriptionsToBePaid);
continue;
}
public function markSubnoscriptionsCanceled(array $subnoscriptions) : void
{
$now = new \DateTime();
foreach($subnoscriptions as $subnoscription) {
$subnoscription->fromArray(
'status' => Subnoscription::SUBSCRIPTION_STATUS_CANCELED,
, $this->em);
$subnoscription->setCanceledAt($now);
$this->em->persist($subnoscription);
}
$this->em->flush();
}
There are no exceptions or problems after the initial exception. Everything seems to work fine except that after the items are flushed... the changes aren't saved to the database. I'm having trouble understanding why this is happening. Another db row deletion returns with success after the exception as well, but in the Database, the row is still there (It works fine if the exception isn't thrown and caught). I checked and the objects are "contained" in the entity manager, and the connection is open. Any insight is helpful. thanks. Perhaps db connections function differently in commands? I dunno.
https://redd.it/1k1qoup
@r_php
I'm running a Symfony command and the persists and flushes seem to work just fine until I throw an exception and the persists and flushes seem to stop working
here's the code:
try {
throw new \Exception("foo");
$successEvent = $this->dispatcher->dispatch($totalChargeEvent, 'billing.charge.card');
} catch (\Exception $e) {
$this->markSubnoscriptionsCanceled($subnoscriptionsToBePaid);
continue;
}
public function markSubnoscriptionsCanceled(array $subnoscriptions) : void
{
$now = new \DateTime();
foreach($subnoscriptions as $subnoscription) {
$subnoscription->fromArray(
'status' => Subnoscription::SUBSCRIPTION_STATUS_CANCELED,
, $this->em);
$subnoscription->setCanceledAt($now);
$this->em->persist($subnoscription);
}
$this->em->flush();
}
There are no exceptions or problems after the initial exception. Everything seems to work fine except that after the items are flushed... the changes aren't saved to the database. I'm having trouble understanding why this is happening. Another db row deletion returns with success after the exception as well, but in the Database, the row is still there (It works fine if the exception isn't thrown and caught). I checked and the objects are "contained" in the entity manager, and the connection is open. Any insight is helpful. thanks. Perhaps db connections function differently in commands? I dunno.
https://redd.it/1k1qoup
@r_php
Reddit
From the symfony community on Reddit
Explore this post and more from the symfony community
Certifications
Unfortunately the financial and time commitment barrier required of post secondary education proved too great. I've worked as a Web Applications Developer for four years and in my current position do a mix of general IT and Wordpress Plugin Development. I want to better refine my craft (security and authentication are some weak points personally) and provide some sort of paper of proof to add on top of my Github for a future employer.
Any recommendations?
https://redd.it/1k1tjpd
@r_php
Unfortunately the financial and time commitment barrier required of post secondary education proved too great. I've worked as a Web Applications Developer for four years and in my current position do a mix of general IT and Wordpress Plugin Development. I want to better refine my craft (security and authentication are some weak points personally) and provide some sort of paper of proof to add on top of my Github for a future employer.
Any recommendations?
https://redd.it/1k1tjpd
@r_php
Reddit
From the PHP community on Reddit
Explore this post and more from the PHP community
Help me convince company to allow me to add redis
I work for a small business which runs a PHP 8.3 /Symfony 7.2 API application (UI runs in React on a completely separate instance) in a major cloud provider. The instance is built in docker and runs apache.
We use the Lexik Authentication bundle so a running instance will provide a bearer token, currently stored in memory, with the refresh token stored in the database.
The cloud provider scales up and down the number of instances in response to load. However, because the bearer tokens are stored in memory in each instance, it becomes a lottery each time a request is made, as to if you will hit the same server that your system authenticated with initially, leading to lots and lots of requests to refresh the bearer token. Each request takes around 200 - 250ms to complete, so this adds a noticeable delay when using the UI.
I would like to add redis to our infrastructure so that, in the short term, store the bearer tokens in redis. I could use memcached as well, but I'm more familiar with redis.
My tech lead is not keen on this idea for some reason, even after I've explained all of this. I'm aware that Symfony supports redis out of the box as well, and this has also been explained.
How can I convince my organisation to at least let me set this up on a test environment (also running in the cloud provider)? I think this would be a massive improvement to the app.
Also, do you think it's worth moving the refresh tokens to redis as well? The app provides a facility to reset passwords using a token. Should that also move?
Also I mentioned Apache before. Would the app benefit from moving to nginx/PHP FPM?
Thanks for your help in advance.
https://redd.it/1k1u2m3
@r_php
I work for a small business which runs a PHP 8.3 /Symfony 7.2 API application (UI runs in React on a completely separate instance) in a major cloud provider. The instance is built in docker and runs apache.
We use the Lexik Authentication bundle so a running instance will provide a bearer token, currently stored in memory, with the refresh token stored in the database.
The cloud provider scales up and down the number of instances in response to load. However, because the bearer tokens are stored in memory in each instance, it becomes a lottery each time a request is made, as to if you will hit the same server that your system authenticated with initially, leading to lots and lots of requests to refresh the bearer token. Each request takes around 200 - 250ms to complete, so this adds a noticeable delay when using the UI.
I would like to add redis to our infrastructure so that, in the short term, store the bearer tokens in redis. I could use memcached as well, but I'm more familiar with redis.
My tech lead is not keen on this idea for some reason, even after I've explained all of this. I'm aware that Symfony supports redis out of the box as well, and this has also been explained.
How can I convince my organisation to at least let me set this up on a test environment (also running in the cloud provider)? I think this would be a massive improvement to the app.
Also, do you think it's worth moving the refresh tokens to redis as well? The app provides a facility to reset passwords using a token. Should that also move?
Also I mentioned Apache before. Would the app benefit from moving to nginx/PHP FPM?
Thanks for your help in advance.
https://redd.it/1k1u2m3
@r_php
Reddit
From the symfony community on Reddit
Explore this post and more from the symfony community
PhpStorm 2025.1 Is Now Available
https://blog.jetbrains.com/phpstorm/2025/04/phpstorm-2025-1-is-now-available/
https://redd.it/1k21emi
@r_php
https://blog.jetbrains.com/phpstorm/2025/04/phpstorm-2025-1-is-now-available/
https://redd.it/1k21emi
@r_php
The JetBrains Blog
PhpStorm 2025.1 Is Now Available | The PhpStorm Blog
This release is a major update that includes improvements in PHPStan annotations, Xdebug, and WordPress support, an AI Free tier and new subnoscription system for JetBrains AI, and more.
Is React the new king of the front-end with Laravel?
We're considering moving away from Svelte in our large Inertia 1.0 application instead of migrating from Svelte 4 to 5.
Not because Svelte is bad - not all, it's fantastic, and I love Svelte 5 even more - but because we as a team feel like we're missing so much by being outside of the ecosystems of Vue and React.
Our first thought was to migrate to VueJS because we have experience with it, but also because almost everyone on the team has a personal opinion that it's much nicer to work with that React.
But one of our developers brought up the question - "even though we're not personal fans of React, should we be considering it purely for the ecosystem support?"
With Laravel Cloud being React, I can see many tools coming out in the future from the team that are React-first, and I haven't seen much 'buzz' in the Vue ecosystem in a long time.
I'd love to know how everyone is feeling around Vue recently - I believe that support for it will always remain in first-party tools (at least, for another {x} years), but how are you all feeling about it?
https://redd.it/1k20zh0
@r_php
We're considering moving away from Svelte in our large Inertia 1.0 application instead of migrating from Svelte 4 to 5.
Not because Svelte is bad - not all, it's fantastic, and I love Svelte 5 even more - but because we as a team feel like we're missing so much by being outside of the ecosystems of Vue and React.
Our first thought was to migrate to VueJS because we have experience with it, but also because almost everyone on the team has a personal opinion that it's much nicer to work with that React.
But one of our developers brought up the question - "even though we're not personal fans of React, should we be considering it purely for the ecosystem support?"
With Laravel Cloud being React, I can see many tools coming out in the future from the team that are React-first, and I haven't seen much 'buzz' in the Vue ecosystem in a long time.
I'd love to know how everyone is feeling around Vue recently - I believe that support for it will always remain in first-party tools (at least, for another {x} years), but how are you all feeling about it?
https://redd.it/1k20zh0
@r_php
Reddit
From the laravel community on Reddit
Explore this post and more from the laravel community
Here are some funny definitions of (PHP), enjoy
1. PHP – Please Hold Pain
>
2. PHP – Probably Has Problems
>
3. PHP – People Hate Programming (in it)
>
4. PHP – Panic Here Please
>
5. PHP – Painful, Hilarious, Perpetual
>
6. PHP – Print Hello Please
>
7. PHP – Please Hire Python
>
8. PHP – Pizza Hut Programming
>
https://redd.it/1k21afg
@r_php
1. PHP – Please Hold Pain
>
2. PHP – Probably Has Problems
>
3. PHP – People Hate Programming (in it)
>
4. PHP – Panic Here Please
>
5. PHP – Painful, Hilarious, Perpetual
>
6. PHP – Print Hello Please
>
7. PHP – Please Hire Python
>
8. PHP – Pizza Hut Programming
>
https://redd.it/1k21afg
@r_php
Reddit
From the PHP community on Reddit
Explore this post and more from the PHP community
What happened with p++?
Hi all. I'm a programmer who mostly has a background in non web-dev programming (lots of data programming). Although I do have one personal project with Node and Express.
Several years ago I heard of the P++ project that was being debated within the php community. I read recently that PHP has a very good type system these days. Was that type system implemented from the p++ project or did it come from something else? I'm just curious.
Thanks!
https://redd.it/1k2eefr
@r_php
Hi all. I'm a programmer who mostly has a background in non web-dev programming (lots of data programming). Although I do have one personal project with Node and Express.
Several years ago I heard of the P++ project that was being debated within the php community. I read recently that PHP has a very good type system these days. Was that type system implemented from the p++ project or did it come from something else? I'm just curious.
Thanks!
https://redd.it/1k2eefr
@r_php
question about the programs you use to code?
Hi Everyone,
I just went through the tutorials; honestly, they were not very helpful. So i decided to start my project. For fun, I have decided to create an e-commerce website. My question is for Python people who use Visual Code. What about for PH,P and will this support HTML AND CSS?
https://redd.it/1k2ntma
@r_php
Hi Everyone,
I just went through the tutorials; honestly, they were not very helpful. So i decided to start my project. For fun, I have decided to create an e-commerce website. My question is for Python people who use Visual Code. What about for PH,P and will this support HTML AND CSS?
https://redd.it/1k2ntma
@r_php
Reddit
From the PHP community on Reddit
Explore this post and more from the PHP community
Symfony 7: Nullable password field vs Random password for OAuth users?
Hello,
I'm currently implementing multiple authentication methods (classic password login + Google OAuth via HWIOAuthBundle) in a Symfony 7 application.
I'm unsure about the best practice regarding the `password` field in my User entity. Two options come to mind:
**Option 1: Keep password non-nullable**
When a user logs in via OAuth, I'll generate and store a random hashed password:
$randomPwd = bin2hex(random_bytes(30));
$hashedPwd = $this->passwordHasher->hashPassword($user, $randomPwd);
$user->setPassword($hashedPwd);
**Option 2: Make password nullable**
Modify the default `User` entity to allow a nullable `password` field.
When using the default `FormLoginAuthenticator`, Symfony already handles empty passwords by throwing exceptions (e.g., `BadCredentialsException`).
What approach would you recommend, and why?
Thanks for your insights!
https://redd.it/1k2rbmq
@r_php
Hello,
I'm currently implementing multiple authentication methods (classic password login + Google OAuth via HWIOAuthBundle) in a Symfony 7 application.
I'm unsure about the best practice regarding the `password` field in my User entity. Two options come to mind:
**Option 1: Keep password non-nullable**
When a user logs in via OAuth, I'll generate and store a random hashed password:
$randomPwd = bin2hex(random_bytes(30));
$hashedPwd = $this->passwordHasher->hashPassword($user, $randomPwd);
$user->setPassword($hashedPwd);
**Option 2: Make password nullable**
Modify the default `User` entity to allow a nullable `password` field.
When using the default `FormLoginAuthenticator`, Symfony already handles empty passwords by throwing exceptions (e.g., `BadCredentialsException`).
What approach would you recommend, and why?
Thanks for your insights!
https://redd.it/1k2rbmq
@r_php
Reddit
From the symfony community on Reddit
Explore this post and more from the symfony community
Secure Your Webhooks in Laravel: Preventing Data Spoofing
Hi all,
I hope you're having a lovely weekend! It's been a little while since I've posted on my blog so I thought I'd share this one. As I've mentioned before it's more for my reference but I write these articles in the hope that it helps and/or inspires others.
https://christalks.dev/post/secure-your-webhooks-in-laravel-preventing-data-spoofing-fe25a70e
I hope you enjoy the read and feedback is welcome!
https://redd.it/1k2rsqd
@r_php
Hi all,
I hope you're having a lovely weekend! It's been a little while since I've posted on my blog so I thought I'd share this one. As I've mentioned before it's more for my reference but I write these articles in the hope that it helps and/or inspires others.
https://christalks.dev/post/secure-your-webhooks-in-laravel-preventing-data-spoofing-fe25a70e
I hope you enjoy the read and feedback is welcome!
https://redd.it/1k2rsqd
@r_php
christalks.dev
Secure Your Webhooks in Laravel: Preventing Data Spoofing
Learn how to implement robust authentication using pre-shared keys and HMAC signatures to protect your webhook endpoints.
Testing paying with Stripe with Behat
I have a Symfony app which is well covered with Behat tests. Now I need to add a functionality for paying with Stripe in it, which I also want to cover with tests. For the js scenarios I use Panther with gecko driver (firefox).
The implemented flow is:
1. The customer opens the checkout page and the Stripe card form is loaded
2. The customer enters the card details and presses Pay
3. A request is sent to the backend, which creates a Stripe PaymentIntent and responds with a client secret
4. The Stripe js library uses that client secret to confirm the payment intent
5. The customer is redirected to Stripe and then back to my app (a result page)
6. The payment is automatically captured
So far, when I open the page in Behat, i tried looking for the Stripe iframe with the card form to fill it, but i could not manage to get into it, even if i intentionally wait for more seconds for it to load.
My questions are:
1. Does it even make sense to test this?
2. If yes, do you have any suggestions how to test this properly?
https://redd.it/1k2rz5y
@r_php
I have a Symfony app which is well covered with Behat tests. Now I need to add a functionality for paying with Stripe in it, which I also want to cover with tests. For the js scenarios I use Panther with gecko driver (firefox).
The implemented flow is:
1. The customer opens the checkout page and the Stripe card form is loaded
2. The customer enters the card details and presses Pay
3. A request is sent to the backend, which creates a Stripe PaymentIntent and responds with a client secret
4. The Stripe js library uses that client secret to confirm the payment intent
5. The customer is redirected to Stripe and then back to my app (a result page)
6. The payment is automatically captured
So far, when I open the page in Behat, i tried looking for the Stripe iframe with the card form to fill it, but i could not manage to get into it, even if i intentionally wait for more seconds for it to load.
My questions are:
1. Does it even make sense to test this?
2. If yes, do you have any suggestions how to test this properly?
https://redd.it/1k2rz5y
@r_php
Reddit
From the PHP community on Reddit
Explore this post and more from the PHP community
Pitch Your Project 🐘
In this monthly thread you can share whatever code or projects you're working on, ask for reviews, get people's input and general thoughts, … anything goes as long as it's PHP related.
Let's make this a place where people are encouraged to share their work, and where we can learn from each other 😁
Link to the previous edition: /u/brendt_gd should provide a link
https://redd.it/1k2r9g2
@r_php
In this monthly thread you can share whatever code or projects you're working on, ask for reviews, get people's input and general thoughts, … anything goes as long as it's PHP related.
Let's make this a place where people are encouraged to share their work, and where we can learn from each other 😁
Link to the previous edition: /u/brendt_gd should provide a link
https://redd.it/1k2r9g2
@r_php
Reddit
From the PHP community on Reddit
Explore this post and more from the PHP community
Where do you buy your favorite programming-themed coffee mugs?
Hey everyone,
I’m on the hunt for some cool, funny, or just well-designed programming-related coffee mugs—think clever coding jokes, languages (like PHP, JS, etc.), or even just clean dev-inspired designs.
I’ve seen a few on Amazon and Etsy, but I feel like I’m missing out on some hidden gems that only devs would know about.
Where do you get yours?
https://redd.it/1k2s3z9
@r_php
Hey everyone,
I’m on the hunt for some cool, funny, or just well-designed programming-related coffee mugs—think clever coding jokes, languages (like PHP, JS, etc.), or even just clean dev-inspired designs.
I’ve seen a few on Amazon and Etsy, but I feel like I’m missing out on some hidden gems that only devs would know about.
Where do you get yours?
https://redd.it/1k2s3z9
@r_php
Reddit
From the PHP community on Reddit
Explore this post and more from the PHP community
Do I Need to Read All of php.net Documentation to Become a PHP Master?
To become a PHP master, do I need to read all of the documentation on php.net?
https://redd.it/1k2w5nx
@r_php
To become a PHP master, do I need to read all of the documentation on php.net?
https://redd.it/1k2w5nx
@r_php
Reddit
From the PHP community on Reddit
Explore this post and more from the PHP community