PHP Reddit – Telegram
PHP Reddit
34 subscribers
292 photos
37 videos
24.9K links
Channel to sync with /r/PHP /r/Laravel /r/Symfony. Powered by awesome @r_channels and @reddit2telegram
Download Telegram
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
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
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
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
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
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
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
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
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
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
What's the best way to handle a open source SaaS product with managed hosted version?

I currently build a customer feedback tool with Symfony and i thinking about making it open source similar to plausible with a managed hosting version. But obviously there should be no payment and Google login in the open source version what's the best way to handling it? Should I create a Symfony bundle or create a fork of the open source version for the managed version? Just curious what do you think about how to handle this use case in Symfony.

https://redd.it/1k2z8rd
@r_php
I made a tiny PHPUnit extension for PSR-7, XML/HTML and JSON assertions

Hi! I found myself often struggling with testing against server PSR-7 responses, XML and JSON documents, Frameworks like Laravel and Symfony offer useful assertions for that but it's often that a project is not using either of the frameworks or it's just not enough. So I made an extension to PHPUnit:

https://github.com/stein197/phpunit-extended

I'd be glad if someone finds its also useful or finds any issues with it

https://redd.it/1k2zy0l
@r_php
PHP named argument unpacking

Hello, I am planning to make an RFC but before that I wanted to know your opinion on it.

Currently PHP allows named arguments so we can do something like this:

function calc(int $number, int $power): int

calc(number: $number, power: $power);

But when we have a variable parameter.

function calc(int $number, int ...$power): int

It is not possible to call the function using named parameters since PHP does not know how to group variable parameters so this is my proposal:

calc(number: $number, power: { $calc_number_1, $calc_number_2, $calc_number_3 });

{ } could be used only when trying to call a function with named parameters and one of its parameters is variadic.

A simpler example to visualize would be this:

function calc(array $into, array ...$insert): array

calc(insert: { $var_1, $var_2, $var_3 }, into: $my_array);

This syntax is much clearer and easier to understand than:

calc(insert: [$var_1, $var_2, $var_3], into: $my_array);

Also, another point to take into account is that with this new syntax, you could combine "parameters by reference" with "named parameters"
For example:

function build_user(int $type, mixed &...$users) {
foreach($users as &$user) {
// Any actions
$user = new my\User(...);
}

build_user(type: $user_type, users: { $alice, $dominic, $patrick });

$alice->name('Alice');

$dominic->name('dominic');

$patrick->name('patrick');

-------------------------------------------------------------------------------

This is already an extra:

If when using named parameters together with the variadic variable, the unpacker returns as a key the name of the sent variable you could do something like this:

function extract(string $path, mixed &...$sources) {
foreach( $sources as $type => &$source) {
switch($type) {
case: 'css':
$source = new my\CSS($path);
break;
case: 'js':
$source = new my\JS($path);
default:
$source = null;
}
}

extract(path: $my_path, sources: { $css, $js });

print $css;

print $js;

Another extra:

It would also be possible to have more than one variadic parameter in a function.

function zoo(int $id, Mammals ...$mammals, ...Cetaseans $cetaceans, Birds ...$birds)

zoo(id: $id, mammals: { $elephants, $giraffes, $wolves }, cetaseans: { $belugas }, birds: { $eagles, $hummingbirds });

https://redd.it/1k37pfd
@r_php
How much overhead does DDEV take when the applications are in operation?

When the web, database and other service related containers setup for docker by DDEV are in operation do the requests have to be proxied through some DDEV services running in the background?

I take it that with some DDEV services listening on port 80 and 443 on the Docker host there may be some overhead, but does that entail some real computational work?

I just want to ascertain that other than issuing the ddev commands to the docker containers DDEV doesn't incur much overhead, and that any overhead will be down to the containers themselves.

https://redd.it/1k37i3x
@r_php
One month into PHP and I feel like I’m getting nowhere. Is this normal ?

I’ve just started learning PHP from scratch it’s been almost a month now. But honestly, I’m finding it super boring. Feels like I’m not getting anywhere. I study, but nothing sticks… I keep forgetting everything. Does this happen to everyone, or is it just me?

https://redd.it/1k3j7m6
@r_php
Weekly /r/Laravel Help Thread

Ask your Laravel help questions here. To improve your chances of getting an answer from the community, here are some tips:

What steps have you taken so far?
What have you tried from the documentation?
Did you provide any error messages you are getting?
Are you able to provide instructions to replicate the issue?
Did you provide a code example?
Please don't post a screenshot of your code. Use the code block in the Reddit text editor and ensure it's formatted correctly.

For more immediate support, you can ask in the official Laravel Discord.

Thanks and welcome to the r/Laravel community!

https://redd.it/1k3r4oz
@r_php
Got an unexpected Laravel Cloud bill :/
https://redd.it/1k414p0
@r_php