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
Anyone using HTMx on your PHP project?

I applied HTMx to my WordPress project (PHP). When a user clicks an item on the image, the details of the Item show instantly. I like HTMx! https://setupflex.com/

Who else is using HTMx in their project?

https://redd.it/1jv5ldf
@r_php
Symfony developers in brasil

Aqui da comunidade quem é do brasil?

Who here in the community is from Brazil?

https://redd.it/1jvb5w6
@r_php
Time to make a basic program in PHP for WordPress

Hello. I wish to make a basic program in PHP that takes product attributes and can make Woo commerce combos based on product attributes. I wish to have this be my first program even though there maybe another on the market.

So how long to learn PHP coding to do a simple program such as this one?

https://redd.it/1jvinui
@r_php
After All This Time, ChatGPT Still Blows My Mind and Sometimes Freaks Me Out (context in comments)
https://redd.it/1jvw56m
@r_php
PHP RFC: Change default value for zend.exception_ignore_args
https://wiki.php.net/rfc/exception_ignore_args_default_value

https://redd.it/1jvxadr
@r_php
Please review my new bundle, RICH, for building robust applications in Symfony

I've been using Symfony since 2012, and last year, I needed to build a new application that had both web and REST API components.

I was familiar with hexagonal architecture, domain driven design, CQRS, and event sourcing, but they all seemed overly complicated. I also knew about API Platform, but it seemed like overkill for basic REST APIs. Plus, I needed my application to support standard HTML web views and JSON API responses.

Through a lot of experimentation, I came up with a similar but simpler architecture I've named RICH: Request, Input, Command, Handler.

A request (from anywhere) is mapped onto an input object, once validated, the input object creates a command object, which is passed (either manually or via message queue) to a handler object which performs the actual business logic.

It's nothing groundbreaking, but I believe it's more flexible than the #[MapRequestPayload] attribute that comes bundled with Symfony, and allows you to build robust applications easily.

I've written a lot more in the README and would love your thoughts and feedback.

https://github.com/1tomany/rich-bundle

https://redd.it/1jw1j51
@r_php
Symfony Mailer and Mailgun

Hello we are switching from SMTP to API for our mailer and mailgun.
Since SMTP is getting blocked by digitalocean.

https://preview.redd.it/dtveu9llx6ue1.png?width=1148&format=png&auto=webp&s=29a2addf94902156d0dcd2b87abdc4de9c2aa1ad

I am trying to establish connection but i always get errors.
We made Api key and domain Sending key ( api key ) we tested both but we cannot receive connection.


Any help is appreciated

MAILER_DSN=mailgun+api://api:8e459c1***************-******-*******@default?domain=example.eu




https://redd.it/1jwni3b
@r_php
Http Requests

Javanoscript / Node

fetch(file)
.then(x => x.text())
.then(y => myDisplay(y));

source: https://www.w3schools.com/js/js\_api\_fetch.asp

\------------------------

Python

import requests

x = requests.get('https://w3schools.com/python/demopage.htm')

source: https://www.w3schools.com/python/module\_requests.asp

\------------------------

PHP (w3school not available)

<?php

$ch = curlinit("http://www.example.com/");
$fp = fopen("example
homepage.txt", "w");

curlsetopt($ch, CURLOPTFILE, $fp);
curlsetopt($ch, CURLOPTHEADER, 0);

curlexec($ch);
if(curl
error($ch)) {
fwrite($fp, curlerror($ch));
}
curl
close($ch);
fclose($fp);

Source: https://www.php.net/manual/en/curl.examples-basic.php

\------------------------------------------------

Unfortunately I can't make this into a meme for higher popularity, but decided to post anyway in case it sparks any community conversation. I really appreciate all of the improvements PHP has had between 7.0 up to 8.3 and I find it extremely dishonest when people want to talk shit about PHP when all they know is PHP from 2010 before Composer even existed. However, I've seen internals discussion around this subject and its often brushed off as "let userland do it".

I'm working on enhancements of PHP hosted on AWS Lambda and we can't install or assume Guzzle (or any HTTP library) is available. We have to rely on vanilla PHP and the complexity of trying to make a simple POST request using PHP is something that is intimidating for me with 15 years of experience working with PHP, imagine a newcomer that sees a comparison like this? How would they ever choose a PHP career over something else?

Thanks for listening to my rant.

https://redd.it/1jwogce
@r_php
What's the common practice for naming resource routes? I like singular form, but /notification doesn't make much sense for "index" (List of resource)
https://redd.it/1jwr9t4
@r_php
HTTP Fixtures to use in tests

I was working on a project recently where I had to integrate with several different APIs. In my tests, I didn’t want to hit all the APIs every time I ran them, so I saved the API responses to JSON files. Then, in my Pest tests, I was loading the JSON files like this:

$json = filegetcontents(dirname(FILE) . '/../../Fixtures/response.json');
Http::preventStrayRequests();
Http::fake(
"https://example.com/api" => Http::response($json, 200)
);

I wanted to remove all sensitive data from the responses and also have more control over their contents. So, I decided to create a package that works similarly to a Laravel Factory. After a few days, I came up with Laravel HTTP Fixtures.

A fixture looks like this and can be generated with an Artisan command by passing a JSON file:

class ExampleHttpFixture extends HttpFixture
{
public function definition(): array
{
return
'status' => Arr::random(['OK', 'NOK'),
'message' => $this->faker->sentence,
'items' =>
[
'identifier' => Str::random(20),
'name' => $this->faker->company,
'address' => $this->faker->address,
'postcode' => $this->faker->postcode,
'city' => $this->faker->city,
'country' => $this->faker->country,
'phone' => $this->faker->phoneNumber,
'email' => $this->faker->email,

],
];
}
}

You can use this in your tests like so:

Http::fake(
"https://www.example.com/get-user/harry" => Http::response(
(new ExampleHttpFixture())->toJson(),
200),
);

For more information, check out the GitHub repo:

👉 https://github.com/Gromatics/httpfixtures



https://redd.it/1jwr31l
@r_php
The James Brooks' interview

https://preview.redd.it/737lytcapdue1.jpg?width=1280&format=pjpg&auto=webp&s=fb1aa68b54d8781544c01ac41d9c3f5336c4977c

Hello devs !

If you'd like to read the interview with James Brooks in my newsletter and find out more about his work at Laravel , here's the link :

https://go.itanea.fr/wud6

Please, tell me which other member of the Laravel team you'd like to see interviewed in a future episode?

https://redd.it/1jxe1dr
@r_php
I didn't think this would work while typing it, but apparently |= is a thing! TIL
https://redd.it/1jxil66
@r_php
🚀 New Tool: Lact – Call Laravel Controller Methods Directly from the Frontend

Hey everyone,

Just wanted to introduce a new open-source tool called Lact, designed to simplify the connection between JavaScript/TypeScript frontends and Laravel backends.

Lact allows frontend developers to call Laravel controller methods directly from the frontend, without manually defining routes or writing repetitive fetch/Ajax logic.

### Key Features:
- 🔁 Skip routes/calling boilerplate – directly invoke controller methods from JS/TS
- 📦 Automatic route generation
- 📘 Works seamlessly with React, Vue, or any JS framework

Inspired by WayFinder the idea behind Lact is to streamline Laravel + JS development and make the backend feel just as accessible as calling a local function.

📚 Documentation: getlact.com
💻 GitHub: msamgan/lact

If you're building Laravel apps with a modern frontend, this might save you some time.
Would love your thoughts – and if you like it, please consider starring the repo to support the project!

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