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
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/1kvn2q8
@r_php
Optimized PHP Images for Laravel

# 🚀 Optimized PHP Images for Laravel! 🐳

Hey Laravel devs! I’ve built PHP-Optimized Docker Images for Laravel 10-12, hosted on GHCR (ghcr.io/redfieldchristabel/laravel). 🐘 These images are fine-tuned for performance, security (non-root laravel user), and follow Docker best practices (one process per container, stdout logs). Includes pre-installed PHP extensions and a scaffolding noscript for easy setup! 😄

laravel container registry

https://redd.it/1kvy6me
@r_php
Send a WhatsApp Message with Just a 3 Lines of PHP

**Send WhatsApp Messages with Just 3 Lines of PHP (No Twilio, No Complexity)**

If you're a PHP dev and want to send WhatsApp messages effortlessly, this is probably the cleanest way to do it.

All it takes is 3 lines (once Guzzle is installed):

phpCopyEdit$client = new \GuzzleHttp\Client();
$response = $client->post('https://www.wasenderapi.com/api/send-message', [
'headers' => ['Authorization' => 'Bearer YOUR_API_KEY', 'Content-Type' => 'application/json'],
'json' => ['to' => '+1234567890', 'text' => 'Hello, here is your update.']
]);
echo $response->getBody();


* No SDKs
* No bloated libraries
* Just drop it into any Laravel, Symfony, or plain PHP project

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