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 this somebody overusing AI?

I was reading a PR recently and saw this code:->color(Closure::fromCallable([$this, “getStateColor”]))

This does the same thing (edit: in my app, which takes values or Closures) as ->color($this->getStateColor()). Except, at least to me, I have no idea why any human would write it the former way unless they were heavily using AI without thinking (this guy’s code regularly breaks, but previously this could be ascribed to a lack of skill or attention to detail).

Am I off base here?

https://redd.it/1kdx7xk
@r_php
Why did the old CGI style of structuring sites die?

Most websites can have their routes be modeled by the filesystem (folders, static files, dynamic .php files). Nowadays the trend is to have files that are fully code (and not necessarily in a location that matches the route it defines) with template files that have some tag defined to paste string there. To me the new way feels way less natural and approachable, so why is it almost universally recommended over the old way?

https://redd.it/1kec7np
@r_php
Package : Symfony-ai-context-bundle

Hello developers,



I've just published a new open source Symfony bundle that automatically generates an AI-readable JSON context from your project.



It extracts information from your Doctrine entities, services, controllers, routes, and repositories, and outputs a structured JSON file that can be fed directly into tools like ChatGPT or any other LLM — for example to help with code generation, analysis, automation, or fine-tuned configuration.



Package: https://packagist.org/packages/ai-context/symfony-ai-context-bundle



Command: `php bin/console ai-context:generate`



I'm looking for early feedback: bugs, edge cases, suggestions, criticisms — anything that could help improve the tool before a broader release.



Some work is still planned, especially around excluding specific classes.



Thanks in advance to anyone willing to give it a try.

https://redd.it/1keg0bf
@r_php
Do you use uuids with doctrine and symfony?

I tried to use UUIDs, but there were so many problems that it wasn't worth it for me. I tried using UUIDv7, but there were problems generating fixtures—for some reason, I got duplicated UUIDs when creating 1000 entities with fixtures. Probably the UUIDs got generated too fast, but how to fix this? I don't want to add a sleep or something like that.
Also, the dev toolbar Doctrine query section doesn't show the UUIDs—instead, it shows the hex code, I think. PhpMyAdmin also doesn't work well with UUIDs. And I think there were some more problems I don't remember anymore.

https://redd.it/1keluec
@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/1keoni9
@r_php
Laravel Reverb & App communication. Who’s calling who?

I’m running three separate containers in AWS Fargate:

* App (Laravel API/Backend)
* Reverb (WebSocket server)
* Horizon (queue worker)

In my AWS WAF logs, I’m seeing a recurring HTTPS request to /apps/12345/connections approximately every 15 seconds. The request originates from my own NAT Gateway, so it’s definitely internal traffic from one of these containers.

I’m trying to figure out which service is making these calls.

Is the Laravel app sending HTTP requests to Reverb?

Or is Reverb making HTTP requests back to the Laravel API (for example to fetch presence info or statistics)?

Could this be triggered by something like Laravel Pulse, or is this behavior built into the Reverb server itself?

I’m mainly trying to optimize internal traffic routing and avoid unnecessary public ALB and WAF processing for internal service calls. Any insight into what triggers these /connections requests and which service initiates them would be really helpful.





https://redd.it/1kes9bm
@r_php
Weekly Ask Anything Thread

Feel free to ask any questions you think may not warrant a post. Asking for help here is also fine.

https://redd.it/1kf1u95
@r_php
Weekly help thread

Hey there!

This subreddit isn't meant for help threads, though there's one exception to the rule: in this thread you can ask anything you want PHP related, someone will probably be able to help you out!

https://redd.it/1kf4i3p
@r_php
Symphony E2E tests

Hello everyone,

I am trying to E2E test a Symfony app with Playwright, and I am struggling a bit. Is it possible to build and test the app on GitHub actions with every push/PR without deploying the app on test server and then run the tests? Does anyone have a workflow file that can help me? Any help is greatly appreciated

https://redd.it/1kf607i
@r_php
Is reading open-sources high-starred projects a good way to level up your level?

I've been recently thinking about reading others repos for learning and gathering new things. It seemed like an awesome idea. Any thoughts?

https://redd.it/1kf7hhg
@r_php
"FrankenPHP | Graceful reload" How?

I use FrankenPHP on production. It works perfectly and - almost - fits my CI/CD noscripts and actually I would recommend to anybody who want to work w/ PHP.

I think I understood every main features of the FrankenPHP and I use a lot of them to speed up my applications. There is only one exception: the graceful reload. I understand the use-case and its goal to result zero downtime.

My question is simple: How?

When everything is ready for the new version to release, my noscript is building and start the noscript like this

$ docker compose build --no-cache
$ docker compose up -d --wait


The building of the app takes time, that is around ~2-3 minutes on the VPS. The docker app seems to be "Unhealthy" during the application building and starting.

Surely my knowledge is incomplete. So, does anybody know how to create a noscript that completely cover the "Graceul reload" functionality?

Edit: During the building and starting the application, the user cannot reach the application.

https://redd.it/1kfix2t
@r_php
fgets doesn't detect newline over http

There is a remote computer I can't access to, but it can access me. I need to send it some data as soon as something happens.

I decided to keep it simple, and have the remote computer connect a webpage of mine, and that webpage answers with a line reading '0' every second, and something else if there is something to do. To achieve this, the webpage simply echoes "0\n" (or whatever) then flush, every second. Calling this webpage directly I can see a new '0' appear every second, as intended.

The remote computer is in an infinite loop reading from fgets, processing each line as it arrives. The whole things works wonders... in testing.

Now, all this is on php 5 (can't update due to reasons), but the real remote computer has php 8, and there, it fails.

I've pinpointed the error to fgets: it reads one line (or many, as long as they are sent in one go), but further lines are not received. fgets hangs ~~forever~~ for a long time. It doesn't timeout, either.

Running tests, adding a parameter to fgets to limit the maximum amount of characters, made me realize the issue: it doesn't detect the end of a line after the first flush (which happens in the local computer)

I've solved this issue by reimplementing the function using fgetc, and everything works now, but it still bugs me. What happened? Anyone knows?

https://redd.it/1kfldh8
@r_php
Why do we need auto-loading?

(This is mostly just me thinking out loud.)

I do remember working with PHP being a lot more tedious before auto-loading, and more recently any time I've worked on projects where auto-loading isn't working for all files using the non-autoloaded files being much more annoying.

But on the other hand I also work with Typenoscript, and there there is no auto-loading, you just explicitly give the path to any symbol you want to import and that seems to work fine. And compared to PHP it has the big advantage that you can import many things from the same file if you want to, and of course they don't have to be classes.

So I'm wondering how bad it would be to go back to explicit require_once, if we had tooling support to automatically insert it whenever needed. You might end up with a big list of require_once at the top of the file but you wouldn't have to read it.

I guess you'd have the complication in PHP that you still can't load two classes with the same fully qualified name, but you could still avoid that by following PSR-4 or a slight variant of it to allow having multiple classlikes in one file if the filename matches the penultimate section of the FQN.

Maybe there'd be use for syntax to combine require_once and import into a single statement to allow importing one or multiple symbols from a PHP file, although that might be more confusing than helpful if was just equivalent to using those two functions separately and didn't actually check that the file contained the symbol.

https://redd.it/1kfo5dg
@r_php
Laravel Nova vs Backpack (It's that time of the year)

Client needs to extend a project with a big dashboard. Metrics here, user management there, etc.

Years ago I always recommended Backpack since Nova was kinda rocky, but I'm seeing Backpack offers a free version and a premium version. If I'm going to pay (and pass the cost to the client, of course)... Cons and pros, apart for one being free?

https://redd.it/1kfvzrg
@r_php