PHP Reddit – Telegram
PHP Reddit
34 subscribers
288 photos
36 videos
24.8K links
Channel to sync with /r/PHP /r/Laravel /r/Symfony. Powered by awesome @r_channels and @reddit2telegram
Download Telegram
Package turns Laravel Container into Shared Dependency by Default

Hello everyone!

Recently, I came across this PR: https://github.com/laravel/framework/pull/51209 on Laravel. I found it quite interesting, so even though it wasn’t merged into the core, I decided to create a package and named it Laravel Singletonize. Laravel Singletonize is a lightweight package that flips the default behavior of Laravel’s service container so that any class resolved without an explicit binding is treated as a singleton. By reusing implicitly resolved services, you avoid forcing the container to repeat costly reflection work on every request—a noticeable win for larger codebases that lean heavily on auto-wiring. This isn't something entirely unfamiliar: it's actually the default behavior of the Symfony framework when resolving dependencies.

Getting started is straightforward: install via Composer and, if you prefer, register the service provider manually—otherwise package discovery takes care of it. The provider merges a simple configuration file and publishes it for you. You can disable the behavior at runtime through config/laravel-singletonize.php, restoring Laravel’s default per-resolution instantiation whenever you need to troubleshoot or benchmark comparisons.

Singletonize is continuously tested against Laravel 10.x, 11.x, and 12.x, and the bundled test harness confirms that unbound classes, nested dependencies, closure bindings, and parameterized resolutions all reuse the first instance as intended. It also checks that forgetting instances forces fresh objects and that toggling the config flag truly disables the optimization, so you can adopt it with confidence.

Feel free to try it out and let me know your thoughts: https://packagist.org/packages/huynt57/laravel-singletonize

https://redd.it/1oden2r
@r_php
I created a PoC for a web framework that combines PHP & JS

Hello, I created a small experimental framework called Hybrid JavaScript PHP (HJP).
It connects PHP and JavaScript through a shared Virtual DOM, making PHP apps reactive without big frontend libraries.

Features

PHP renders the initial HTML + Virtual DOM
JavaScript syncs the state changes in real-time
Tiny diffing system for updates
No build tools or dependencies - Just PHP and Vanilla JS

It is still a prototype, but it shows how a VDOM can be combined with PHP so you have bi-directional reactive framework. Check it out at this repository: lukevdbroek-nl/hybrid-javanoscript-php

https://redd.it/1ofaf4i
@r_php
PHP Extension Identifier

I created a PHP extension to work with 128 bit Identifiers like UUIDs and ULIDs.

It also contains a Codec inspired in Go's alphabet based encoder.

My dream would be an extension like this should be part of the core, but hey, dreaming is cheap!

Please do take a look and try it! It would be useful for me to know how you find the API and if there are any weird bugs anywhere.

Cheers!

https://redd.it/1ofc9cr
@r_php
How is your experience with Wayfinder so far?

I am doing a Vue/Inertia app and got sick of trying to figure out why Ziggy wasn't playing well with Sail (I was getting a load of CORS errors and couldn't figure out why) so I switched over to Wayfinder.

I know it's still in beta, but so far it's been pretty great. The only real issues I've faced are having to run wayfinder:generate a lot, sometimes via sail and other times not. Yesterday, for example, every time the page refreshed, the actions folder just upped and disappeared, so I was constantly have to regenerate. Then I stepped away from the computer for a few hours, and when I returned, it magically stopped happening.

Any idea how long till version 1? Is this going to be an official Laravel package?

https://redd.it/1oftvzk
@r_php
Proof of Concept: Running Symfony Service Methods Asynchronously with #Async

Hi everyone,

I wanted to share a quick proof of concept I rapidely built for running Symfony service methods asynchronously using a simple #[Async] attribute like with Java Spring.

The idea is to add #[Async] to any service method and have it executed in a background process automatically, without changing the service code itself.

For now, the service has to implement an Interface to use Async the attribute.

GitHub repo: https://github.com/taymour/symfony-async-poc

What it does:

Scans all services at container compilation.
Generates a proxy class for any service that has an #[Async] method.
When such a method is called, it triggers a console command in a separate PHP process.
The background command ((for now in php but could be done with Go for example) then executes the original method asynchronously.

Important note:
This is only a quick technical experiment to start a discussion. The code is far from clean or production-ready. It’s just meant to illustrate the concept and open a debate about whether this approach could be improved or made practical within Symfony.

I'd love to hear your feedback, alternative ideas, or existing tools/libraries that could make this approach cleaner or safer.

Thanks!

https://redd.it/1ofus0u
@r_php
PHP library for handling large CSV files efficiently (stream-based + callable support)

Good day, everyone!

I’d like to share an open-source library I’ve been working on recently: csv-manager.
This library is designed to handle very large CSV files efficiently using a stream-based approach, so it doesn’t load the entire file into memory.

It also supports passing a callable function as a parameter, which allows you to apply your own logic while the file is being read — for example, transforming rows, filtering data, or running validations on the fly.

You can find basic usage examples in the README.

I’d really appreciate your opinions, feedback, or suggestions for improvement!

Repo: https://gitlab.com/jcadavalbueno/csv-manager

Thanks for reading, and have a great day!

https://redd.it/1ogf8pm
@r_php
What are you using for monitoring? Or searching for EU alternative of Nightwatch

Well, topic speaks for itself. I'm using (testing, actually) the Laravel Nightwatch and it's quite good with the free plan, but when the app grows, free plan won't be enough. So looking for EU-based alternatives of Laravel monitoring: exceptions, query stats, mail monitoring, etc.

Heard about "Oh Dear" (ohdear.app), but not sure if they provide the same level as Nightwatch.

Any ideas?

https://redd.it/1ogg7yb
@r_php
Security review request — Laravel app (MVC + API) with rich-text editor: how to test & harden against XSS and common Laravel attacks?

Hi eweryone! I just deployed a Laravel application that exposes both an MVC frontend and an API. The app includes a rich-text editor, and I want to perform a focused security review before going wider. ’m looking for advanced/practical advice: how to test for XSS (reflected, stored, DOM) and other Laravel-specific risks.

https://redd.it/1ogfd03
@r_php
Concepts i should master before diving into frameworks

Hi,i'm someone with a goal to become a really good PHP developer. Im currently in the making some very basic beginner projects with pure PHP and haven't touched a framework yet like Laravel or Symphony.Can someone please give me some extra advice and a decent list of concepts i need to master before diving into frameworks.Its true that i may not need to get really deep into pure php to dive into frameworks because i have heard other people who succeeded becoming laravel devs without deep diving first into pure PHP,but i really want to become a great at it before touching frameworks. Any advice is greatly aprecciated along the way and i would love if someone could just list me some concepts i must master to make framework learning and then development a lot easier and also just help me as a developer,maybe some resources,anything welcomed and apreciated.

https://redd.it/1ogkcy1
@r_php
What's the best way to implement a Tag entity?

Hey,

Let's say you're making an app with many Users who can all create Properties and Documents with any number of Tags each.

e.g. Property tags would include stuff like "south-facing". Documents might have "rental agreement". Some tags could exist on either like "renovation".

How would you set that up? I can't come up with an optimal solution :(

With a ManyToMany setup:

\- By having only one Tag entity you might see "south-facing" appear in the Document's auto-complete which makes no sense. But by having PropertyTag and DocumentTag you duplicate the "renovation" value.

\- If every user has its own tags, you'll end up with 100 versions of "renovation", "renovated", "RENOVATED", "recently renovated", "restored", "refurbished"... Even though one shared tag would serve them all just fine. So if 10 standard tags all have 100 variants thats 1000 entries instead of 10.

\- But if all users share one tag, they can't edit it and would have to remove "renovation" and add instead "renovated in 2025" on all their properties if they want to edit in that detail. Unless I make the edit action auto-handle foreign key re-assignment, which sounds messy.

With an array field setup, the duplicates are maxed and it's not performant in queries' filter/order operations.

--> How to implement tags without ending up with thousands of entries, many of which are duplicates?

I understand that SQL can handle the load just fine but I'd love a more elegant solution \^\^



https://redd.it/1oglnuh
@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/1ogps9n
@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/1oh3yso
@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/1oh7pgr
@r_php