PHP Reddit – Telegram
PHP Reddit
34 subscribers
289 photos
37 videos
24.8K links
Channel to sync with /r/PHP /r/Laravel /r/Symfony. Powered by awesome @r_channels and @reddit2telegram
Download Telegram
Why is using DTOs such a pain?

I’ve been trying to add proper DTOs into a Laravel project, but it feels unnecessarily complicated. Looked at Spatie’s Data package, great idea, but way too heavy for simple use cases. Lots of boilerplate and magic that I don’t really need.

There's nested DTOs, some libraries handle
validation, and its like they try to do more stuff than necessary. Associative arrays seem like I'm gonna break something at some point.

Anyone here using a lightweight approach for DTOs in Laravel? Do you just roll your own PHP classes, use value objects, or rely on something simpler than Spatie’s package?

https://redd.it/1oe6gda
@r_php
My production architecture for Laravel build with Docker compose, Traefik and FrankenPhp

Hi, everyone, for my little product, coz.jp I completed an architecture that I'm proud of. Using the tech mentioned in the noscript I managed to prepare a stable, fast and easy to maintain infrastructure.
Here the full article with the files templates too. if you have any questions or more importantly suggesitons feel free to ask me here or on the linked article: https://coz.jp/TGzzQa

https://redd.it/1oe2q1b
@r_php
What is the difference between a bus and a transport

In my project I have these settings:

framework:
messenger:
transports:
async: '%env(MESSENGER_TRANSPORT_DSN)%'
failed: 'doctrine://default?table_name=failed_messages'
sql_channel_manager_dlq:
dsn: '%env(SQS_CHANNEL_MANAGER_TRANSPORT_DLQ_DSN)%'
options:
access_key: '%env(AWS_ACCESS_KEY_ID)%'
secret_key: '%env(AWS_SECRET_ACCESS_KEY)%'
region: '%env(AWS_REGION)%'
queue_name: '%env(CHANNEL_MANAGER_QUEUE_NAME_DLQ)%'
sqs_channel_manager:
failure_transport: sql_channel_manager_dlq
dsn: '%env(SQS_CHANNEL_MANAGER_TRANSPORT_DSN)%'
serializer: App\Infrastructure\Messenger\ChannelManagerSerializer
options:
access_key: '%env(AWS_ACCESS_KEY_ID)%'
secret_key: '%env(AWS_SECRET_ACCESS_KEY)%'
region: '%env(AWS_REGION)%'
queue_name: '%env(CHANNEL_MANAGER_QUEUE_NAME)%'
failure_transport: failed
default_bus: command.bus
buses:
event.bus: ~
command.bus:
middleware:
- 'App\Infrastructure\Middleware\RequestIdMiddleware'
routing:
App\Message\TestQueue: async
App\Domain\Event\ChannelManager\ChannelManagerEventHasReceived: sqs_channel_manager


As you can see I have the follwoing transports:

async
failed
sql_channel_manager_dlq
sqschannelmanager

And the following buses:

event.bus
command.bus

But I have trouble inderstanding the difference between buses and transports.

My google-fu leads me only to generic info regarding on how to setup the queue listener: https://symfony.com/doc/current/messenger.html

But I fail to comperhend the difference between bus and transport. What is the difference between these 2?

So far I understood that a bus is some sort of road that transport uses it to handle a message, if it is true in my example how I can define that all messages passed through sqs_channel_manager would be handled upon event.bus?

https://redd.it/1oe3ocx
@r_php
Introducing Nimbus: An integrated, in-browser API client for Laravel with a touch of magic
https://redd.it/1odpprx
@r_php
NativePHP Mobile: What's your dev workflow? Do you rebuild every time?

I'm working with NativePHP for mobile and I'm struggling to figure out an efficient development workflow.

I did my first build and deployed it to my phone, but rebuilding the entire app every time I want to see changes is painfully slow. I've searched online but couldn't find any documentation or discussions about mobile development workflows with NativePHP.

Do you rebuild the full app for every change, or is there a way to get live/hot reload working?

https://redd.it/1oejwmv
@r_php
I need PHP courses, but the most advanced...

I want to improve as a PHP developer, and I'd like more courses. However, I'd appreciate recommendations for classes, instructors, courses, and platforms.

Thank you in advance.

https://redd.it/1oewa9x
@r_php
Are there Forge provisioning logs somewhere

Provisioning a server is continually failing at the “making final touches” stage. Everything is installed and running on the server, so I don’t know what the issue is.

I also can’t seem to find any forge error logs in my server. I looked in root and in var/log. Not in either place.

Any tips on where I can find out why provisioning fails?

In case this matters, I am bringing a fresh ec2 instance to Forge to provision. I haven’t been able to launch an ec2 directly from forge dashboard in a while, so this is not my first time doing this but it’s my first since the redesign.

https://redd.it/1of2yr8
@r_php
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