PHP Reddit – Telegram
PHP Reddit
34 subscribers
291 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
Symfony/Doctrine Randomly Deleting Data

I'm very new to symfony/doctrine so I'm probably doing something stupid. Sometimes (seemingly at random) data just disappears from my mysql database. Does anyone have any idea what might be happening?

Maybe I'm using the entity manager interface incorrectly? Most of the time everything works fine.

https://redd.it/1kw2ytg
@r_php
Optimizing MySQL queries in Symfony apps

Hi Symfony developers,

Vlad Mihalcea shared some interesting findings after running the Spring PetClinic app under load and analyzing query performance.

The tool he used flagged high-latency queries, suggested index changes, helped reduce resource usage and improve query performance.

Link if you want to skim: https://vladmihalcea.com/mysql-query-optimization-releem/

Just curious - anyone here use tools for automatic identification and optimization of inefficient SQL queries in your workflow?

https://redd.it/1kw4wwb
@r_php
Made something cool, HTML5 truncation library called chophper

Built this a while back and we use it in some WordPress plugins at scale. It has handled all the dynamic content thrown at it in the wild world of WP, felt like it might be useful to others as well as a general PHP tool.

Feel free to trash it if its dumb, but it only has 1 dependency, and no real PHP minimum requirements like others did.

https://github.com/code-atlantic/chophper

Truncate chars, optionally respecting word boundaries
Truncate words, optionally respecting sentence boundaries
Truncate sentences, optionally respecting block boundaries
Truncate blocks (paragraphs, lists, etc.)
Preserving HTML tags
Preserving HTML entities

​

// Full is built to fully support HTML5 without breaking the HTML structure.
use Chophper\Full as Chophper;

$options
// ... see options below.
;

Chophper::truncate($html, $length, $options);

https://redd.it/1kw5s4g
@r_php
PHPVerse 2025 afterparty 🎉 (Amsterdam)

Hey folks,

If you’re in or near Amsterdam, NL, mark your calendar for Tuesday, June 17!

Right after the PHPVerse 2025 conference, we’re hosting a special edition of the AmsterdamPHP meetup, featuring some of the speakers from the event, including:

Nils Adermann (Co-founder, Packagist)
Nicolas Grekas (Core Developer, Symfony) …and more to be announced.

We’ll have a short talk, a panel discussion on the past and future of PHP, and plenty of time to chat over 🍕 pizza.

📍 Location: Café Restaurant Dauphine, Amsterdam
🕒 Time: Doors open 18:30, talks start 19:30
🎟️ Free event – open to everyone

RSVP here:
👉 https://www.meetup.com/amsterdamphp/events/307306474/

If you’re around for the conference, or just in town and into PHP, come hang out. And feel free to share the link with anyone who might be interested.

We're all very much looking forward to meeting other people in the PHP community :)

Hope to see some of you there!

https://redd.it/1kwjmro
@r_php
I built Laravel AI Factory a package for generating realistic test data using AI models

Hello guys, I've had this thought that it would be quite cool to be able to create test data using AI, instead of plain Faker which Laravel provides. So I created a package for this called laravel-ai-factory, you can check it out on https://github.com/fdomgjoni99/laravel-ai-factory .

I’d love to hear your thoughts and what you think should be added next!

https://redd.it/1kwspwo
@r_php
What the best strategy to handle multiple possible different exceptions?

Considering a scenario in which we need to perform several relative operations on a service, what is the best alternative to manage multiple exceptions, returning to the user the specific step in which the problem occurred?

<?php

namespace App\Services\Auth;

use App\DTOs\Auth\RegisterDTO;
use App\Models\User;
use RuntimeException;
use Throwable;

class RegisterService
{

/**
* u/throws Throwable
*/
public function execute(RegisterDTO $registerDTO)
{
try {
/*
* Operation X: First exception possibility
* Consider a database insert for user, can throw a db error
*/

/*
* Operation Y: Second exception possibility
* Now, we need to generate a token to user verify account,
* for this, we save token in db, can throw another db error, but in different step
*/

/*
* Operation Z: Third exception possibility
* Another operation with another exception
*/
} catch (Throwable $e) {

}

// OR another method, works, but it is extremelly verbose

try {
/*
* Operation X: First exception possibility
*/
} catch (Throwable $e) {

}

try {
/*
* Operation X: Second exception possibility
*/
} catch (Throwable $e) {

}
}
}

https://redd.it/1kx07me
@r_php
Kinda like Time, but this time, with distance

I’ve just released yet another distance library but using the same tricks I’ve learned from my Time Library. So you can be sure that 100 centimeters is triple-equal to 1 meter. You also have some type-safety so that you aren’t relying on bare ints/floats for distance, and then someone puts in centimeters instead of meters.

This also has some (de)serialization support for Crell's Serde library, for when you want to serialize a distance to a specific number in a certain unit.

Note: this uses micrometers as the base unit; that means 64-bit systems are limited to around the size of the solar system, while 32-bit systems are limited to a couple of meters.

https://redd.it/1kx0q42
@r_php
I just published the first draft of my course on building high-performance PHP apps with Swoole

Hi everyone!

I've been working on this course to teach how to build high-performance, coroutine-based apps in PHP using Swoole. It covers architecture, async patterns, real-time APIs, and a full example project called Paw Salon.

This is the first release draft. It’s not polished, but it’s complete enough to show the ideas, and I’d love feedback from other PHP devs. Ah, it will be available for free until I finish it.

If you’re curious about Swoole and async programming with PHP, DM me and I'll send you the download link.

Thanks!

https://redd.it/1kx26ik
@r_php
Pipe Operator RFC passed

Voting is closed for the pipe operator.

This (taken directly from the RFC) will be legal code in 8.5:

$result = "Hello World"
|> htmlentities(...)
|> str_split(...)
|> fn($x) => array_map(strtoupper(...), $x)
|> fn($x) => array_filter($x, fn($v) => $v != 'O');


https://redd.it/1kx872h
@r_php
How do you guys version your Laravel app?
https://redd.it/1kxcgyo
@r_php
NODEJS CAN RUN PHP !!!

based from the tweet of matteo collina : https://x.com/matteocollina/status/1927395639698096313


i was wondering if it's only like for dummy noscripts or is it legitimately a thing???




https://redd.it/1kxcpgz
@r_php
How I can make/configure make:command to place my comands into a specific directory instead of the default one?

If I need a command I type:

php bin/console make:command mycommand:dosmething


In order to make a command upon ./src/Console but a coleague of mine does a refactor ans places the commands upon ./src/Infrastructure/Console instead of the default path. Is there a way to override the make:command in order to place the generated commands upon the desired path?

https://redd.it/1kxghve
@r_php
Built a full WebRTC implementation in PHP – Feedback welcome!

Hey everyone!

I've been working on a full WebRTC implementation in PHP and just released a set of packages that handle everything from ICE, DTLS, SCTP, RTP, and SRTP to signaling and statistics.

It’s built entirely in PHP (no Node.js or JavaScript required on the backend), using PHP FFI to interface with native libraries like OpenSSL and VPX when needed. The goal is to make it easy to build WebRTC-based apps in pure PHP – including media servers, video conference web app, SFUs, and peer-to-peer apps.

GitHub: https://github.com/PHP-WebRTC

Features:

Full WebRTC stack: ICE, DTLS, SRTP, SCTP, RTP
Adapter-based signaling (WebSocket, TCP, UDP, etc.)
PHP-native SDP and stats
SFU-ready architecture
Fully asynchronous with ReactPHP

I'm actively looking for:

Feedback on architecture or API design
Suggestions for real-world use cases
Contributions, issues, or ideas from the community

If you're interested in media streaming or real-time communication with PHP, I'd love your thoughts. Also happy to answer any technical questions!

Thanks 🙏

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