PHP Reddit – Telegram
PHP Reddit
34 subscribers
287 photos
36 videos
24.7K links
Channel to sync with /r/PHP /r/Laravel /r/Symfony. Powered by awesome @r_channels and @reddit2telegram
Download Telegram
Are you using FFI, and how?

Hey everyone!

Been writing PHP for years, and recently got a bit deeper into C. While poking around, I stumbled across PHP's FFI (Foreign Function Interface), something I've totally overlooked til now. Great to be learning new things about PHP everyday.

Seems like a powerful feature to offload C functions straight from PHP, I've got a few ideas, such as offloading performance-heavy stuff, playing with native libraries, etc. But I'm curious of others experience with this feature, and if it's all that.

So, yeah, if you've used it:
\- What kinds of things have you built?
\- Anything made it into production?
\- Is it a feature that is production-ready or more for experimental usecases?
\- Heaven/Horror stories using it?

Would love to hear people's stories and what kind of use cases people have found for it.

https://redd.it/1optg8a
@r_php
I built a static site generator in pure php

I've been working on PHPSSG recently, it's a pure php static site generator with cool features like component based routing, lifecycle hooks, caching, incremental builds, etc. Take a look, you might get some use out of it. It's minimal in design and completely configurable. It leaves a lot of decisions up to you. Templates are written in plain php but you can easily overwrite the renderer and use something like twig or blade instead if you want. PHPSSG can be your entire codebase or just a small part of it, I built it playing to PHP's strengths. I would really appreciate any feedback you have about the project, I'm completely open to suggestions and criticism.

https://redd.it/1opy148
@r_php
Is adding declare(strict_types=1) increase code performance?

In Laravel and Symfony projects, I add `declare(strict_types=1);` at the top of my Controllers and Services.I know that it improves code reliability. But my teammate says it also increase code performance. Is this correct?

https://redd.it/1oqrboa
@r_php
Just published Multitron 1.0 - MIT-licensed beautiful CLI PHP Task Orchestrator library for large processes, exports, synchronizations, etc. Please give me your feedback!
https://github.com/riki137/multitron

https://redd.it/1oqt7tk
@r_php
🚀 I built a WebAuthn plugin for Laravel Jetstream + Livewire!

Hey everyone 👋

I’ve just released an open-source package I’ve been working on:
👉 [**r0073rr0r/laravel-webauthn**](https://github.com/r0073rr0r/laravel-webauthn)

It adds full **WebAuthn (passkeys, biometrics, USB keys)** support for **Laravel Jetstream + Livewire** — no external controllers, just native Livewire components.

# 🔧 What it does

* Register WebAuthn devices (fingerprint, Face ID, USB key, etc.)
* Login via WebAuthn directly through Livewire
* Works seamlessly with Jetstream (Livewire stack)
* Supports **Laravel 12**, **Livewire 3**, **Jetstream 5**, **PHP 8.2+**

# ⚙️ Installation

composer require r0073rr0r/laravel-webauthn
php artisan vendor:publish --provider="r0073rr0r\WebAuthn\WebAuthnServiceProvider"
php artisan migrate

Then include the JS file:

<noscript src="{{ asset('vendor/webauthn/webauthn/webauthn.js') }}"></noscript>

# 🧩 Usage

For registration (e.g., in your Jetstream profile page):

<livewire:webauthn-register />

For login (e.g., in your login page):

<livewire:webauthn-login />

That’s it — the components handle the WebAuthn challenge/response flow automatically.

# 💡 Why I built it

I love using Jetstream + Livewire for full-stack Laravel apps, but I couldn’t find a simple WebAuthn package that fit naturally into that ecosystem.
So I built one — fully Livewire-based, no JS frameworks, no extra controllers.
It’s lightweight, secure, and built to “feel native” inside Jetstream.

# 🛠️ Features

* Clean integration with Jetstream UI
* Configurable components (can publish & customize views)
* Works with existing user accounts
* Passkeys ready 🔐
* Open source (MIT)

💬 Feedback, ideas, and PRs are very welcome!

👉 [GitHub repo here](https://github.com/r0073rr0r/laravel-webauthn)

https://redd.it/1oqwcmc
@r_php
Just published event4u/data-helpers

During my time as a PHP developer, I often worked with DTOs. But there were always some problems:

Native DTOs don’t offer enough functionality, but they’re fast
Laravel Data has many great features, but it’s Laravel-only and quite slow
Generators aren’t flexible enough and have too limited a scope

So I developed my own package: `event4u/data-helpers`
You can find it here [
https://github.com/event4u-app/data-helpers](https://github.com/event4u-app/data-helpers)
And the documentation here [
https://event4u-app.github.io/data-helpers/](https://event4u-app.github.io/data-helpers/)

The goal was to create easy-to-use, fast, and type-safe DTOs.
But also to make it simple to map existing code and objects, map API responses directly to classes/DTOs, and easily access deeply nested data.

Here is an example, how the Dto could look like

// Dto - clean and type-safe
class UserDto extends SimpleDto
{
public function __construct(
#[Required, StringType, Min(3)]
public readonly string $name,

#[Required, IntegerType, Between(18, 120)]
public readonly int $age,

#[Required, Email]
public readonly string $email,
) {}
}

But that is not all. It also has a `DataAccessor` Class, that uses dot notations with wildcards to access complex data structures in one go.

// From this messy API response...
$apiResponse = [
'data' => [
'departments' => [
['users' => [['email' => '
alice@example.com'], ['email' => 'bob@example.com']]],
['users' => [['email' => '
charlie@example.com']]],
],
],
];

// ...to this clean result in a few lines
$accessor = new DataAccessor($apiResponse);
$emails = $accessor->get('data.departments.
.users..email');
// $emails = ['
alice@example.com', 'bob@example.com', 'charlie@example.com']

Same for Dto's

But that is not all. It also has a `DataAccessor` Class, that uses dot notations with wildcards to access complex data structures in one go.

$userDto = UserDto::create(...); // or new UserDto(...)
$userDto->get('roles.
.name'); // returns all user role names

Or just use the DataMapper with any Object

class UserModel
{
public string $fullname;
public string $mail;
}

$userModel = new UserModel(
fullname: 'Martin Schmidt',
mail: 'martin.s@example.com',
);

class UserDTO
{
public string $name;
public string $email;
}

$result = DataMapper::from($source)
->target(UserDTO::class)
->template(
'name' => '{{ user.fullname }}',
'email' => '{{ user.mail }}',
)
->map()
->getTarget(); // Returns UserDTO instance

There are a lot of features, coming with this package. To much for a small preview.
That's why i suggest to read the documentation.

I would be happy to hear your thoughts.

https://redd.it/1orkcty
@r_php
Just published Multitron 1.0 - MIT-licensed beautiful CLI PHP Task Orchestrator library for large processes, exports, synchronizations, etc. Please give me your feedback!
https://github.com/riki137/multitron

https://redd.it/1orpuwd
@r_php
Livewire Workflows

I just released my first package, Livewire Workflows, for easily creating multi-step workflows and form wizards from full-page Livewire components. The package provides for easy definition of workflows and guards, and handles route definition, navigation, and state management, offering helper methods for manual management. How can I improve this package to make it the most beneficial for you?

https://github.com/pixelworxio/livewire-workflows

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