PHP Reddit
31 subscribers
309 photos
40 videos
25.3K links
Channel to sync with /r/PHP /r/Laravel /r/Symfony. Powered by awesome @r_channels and @reddit2telegram
Download Telegram
Symfony 6 book

I'm new to Symfony. Is the Symfony book 6 still a good learning resource or should I skip it? I plan to start with version 7.4.

https://redd.it/1sdgq8f
@r_php
Weekly /r/Laravel Help Thread

Ask your Laravel help questions here. To improve your chances of getting an answer from the community, here are some tips:

What steps have you taken so far?
What have you tried from the documentation?
Did you provide any error messages you are getting?
Are you able to provide instructions to replicate the issue?
Did you provide a code example?
Please don't post a screenshot of your code. Use the code block in the Reddit text editor and ensure it's formatted correctly.

For more immediate support, you can ask in the official Laravel Discord.

Thanks and welcome to the r/Laravel community!

https://redd.it/1sd8txj
@r_php
Improved markdown quality, code intelligence for 248 formats, and more in Kreuzberg v4.7.0

Kreuzberg v4.7.0 is here. Kreuzberg is an open-source Rust-core document intelligence library with bindings for Python, TypeScript/Node.js, Go, Ruby, Java, C#, PHP, Elixir, R, C, and WASM. 

We’ve added several features, integrated OpenWEBUI, and made a big improvement in quality across all formats. There is also a new markdown rendering layer and new HTML output, which we now support. And many other fixes and features (find them in our the release notes).

The main highlight is code intelligence and extraction. Kreuzberg now supports 248 formats through our tree-sitter-language-pack library. This is a step toward making Kreuzberg an engine for agents. You can efficiently parse code, allowing direct integration as a library for agents and via MCP. AI agents work with code repositories, review pull requests, index codebases, and analyze source files. Kreuzberg now extracts functions, classes, imports, exports, symbols, and docstrings at the AST level, with code chunking that respects scope boundaries. 

Regarding markdown quality, poor document extraction can lead to further issues down the pipeline. We created a benchmark harness using Structural F1 and Text F1 scoring across over 350 documents and 23 formats, then optimized based on that. LaTeX improved from 0% to 100% SF1. XLSX increased from 30% to 100%. PDF table SF1 went from 15.5% to 53.7%. All 23 formats are now at over 80% SF1. The output pipelines receive is now structurally correct by default. 

Kreuzberg is now available as a document extraction backend for OpenWebUI, with options for docling-serve compatibility or direct connection. This was one of the most requested integrations, and it’s finally here. 

In this release, we’ve added unified architecture where every extractor creates a standard typed document representation. We also included TOON wire format, which is a compact document encoding that reduces LLM prompt token usage by 30 to 50%, semantic chunk labeling, JSON output, strict configuration validation, and improved security. GitHub: https://github.com/kreuzberg-dev/kreuzberg

Contributions ar always very welcome!

https://kreuzberg.dev/

https://redd.it/1scvo2u
@r_php
Content negotiation in PHP: your website is already an API without knowing it (Symfony, Laravel and Temma examples)

I'm preparing a talk on APIs for AFUP Day, the French PHP conference. One of the topics I'll cover is content negotiation, sometimes called "dual-purpose endpoint" or "API mode switch."

The idea is simple: instead of building a separate API alongside your website, you make your website serve both HTML and JSON from the same endpoints. The client signals what it wants, and the server responds accordingly.

A concrete use case

You have a media site or an e-commerce platform. You also have a mobile app that needs the same content, but as JSON. Instead of duplicating your backend logic into a separate API, you expose the same URLs to both your browser and your mobile app. The browser gets HTML, the app gets JSON.

The client signals its preference via the Accept header: Accept: application/json for JSON, Accept: text/html for HTML. Other approaches exist (URL prefix, query parameter, file extension), but the Accept header is the standard HTTP way.

The same endpoint in three frameworks

Symfony

<?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Attribute\Route;

class ArticleController extends AbstractController
{
#Route('/articles', requirements: ['_format' => 'html|json')]
public function list(Request $request)
{
$data = 'message' => 'Hello World';
if ($request->getPreferredFormat() === 'json') {
return new JsonResponse($data);
}
return $this->render('articles/list.html.twig', $data);
}
}

In Symfony, the route attribute declares which formats the action accepts. The data is prepared once, then either passed to a Twig template for HTML rendering, or serialized as JSON using JsonResponse depending on what the client requested.

Laravel

Laravel has no declarative format constraint at the route level. The detection happens in the controller.

routes/web.php

<?php

use App\Http\Controllers\ArticleController;
use Illuminate\Support\Facades\Route;

Route::get('/articles', ArticleController::class, 'list');

Unlike Symfony, there is no need to declare accepted formats in the route. The detection happens in the controller via expectsJson().

app/Http/Controllers/ArticleController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Routing\Controller;

class ArticleController extends Controller
{
public function list(Request $request)
{
$data = 'message' => 'Hello World';
if ($request->expectsJson()) {
return response()->json($data);
}
return view('articles.list', $data);
}
}

The data is prepared once, then either serialized as JSON via response()->json(), or passed to a Blade template for HTML rendering.

Temma controllers/Article.php

<?php

use \Temma\Attributes\View as TµView;

class Article extends \Temma\Web\Controller {
#TµView(negotiation: 'html, json')
public function list() {
$this'message' = 'Hello World';
}
}

In Temma, the approach is different from Symfony and Laravel: the action doesn't have to check what format the client is asking for. Its code is always the same, regardless of whether the client wants HTML or JSON. A view attribute handles the format selection automatically, based on the Accept header sent by the client.

Here, the attribute is placed on the action, but it could be placed on the controller instead, in which case it would apply to all
Bootgly v0.12.0-beta — HTTP/1.1 compliance + Router improvements (pure PHP HTTP server, zero extensions)

Hey r/PHP,

Just released [**Bootgly v0.12.0-beta**](https://github.com/bootgly/bootgly/releases/tag/v0.12.0-beta) — focused on **Router improvements** and **HTTP/1.1 protocol compliance** for the built-in HTTP Server CLI.

For those unfamiliar: Bootgly is a PHP framework with a native, event-driven, multi-worker HTTP server built entirely in PHP — no extensions required (just `php-cli`). It uses `stream_select()` \+ `SO_REUSEPORT` \+ PHP Fibers for async. It's [very fast](https://github.com/bootgly/bootgly_benchmarks) in plain text benchmarks.

# What's new in v0.12.0

**Router improvements:**

* **Route caching** — all routes are cached on the first request. Static routes resolve in O(1), dynamic routes use first-segment indexing + regex. Zero Generator overhead after warmup
* **Inline parameter constraints** — validate params at compile-time with zero runtime cost:
* Built-in types: `int`, `alpha`, `alphanum`, `slug`, `uuid`
* **Named catch-all params** — `/:query*` captures everything including `/`:

**HTTP/1.1 compliance - 100%**
**I developed what was missing in this release -> RFC 9110–9112:**

* `Transfer-Encoding: chunked` decoding with incremental chunk reassembly
* `Expect: 100-continue` → sends `100 Continue` before body read
* `Connection: close` management (HTTP/1.1 persistent by default, HTTP/1.0 close by default)
* HEAD body suppression (headers sent, body omitted)
* Mandatory `Host` header validation → `400 Bad Request`
* `TRACE`/`CONNECT` → `501 Not Implemented`
* Unknown methods → `405 Method Not Allowed` with `Allow` header
* `414 URI Too Long` for oversized request targets
* HTTP/1.0 backward compatibility (status-line + no chunked encoding)

All verified with **PHPStan level 9** and **288 test cases** (including 13 HTTP/1.1 compliance-specific tests).

# Links

* GitHub: [github.com/bootgly/bootgly](https://github.com/bootgly/bootgly)
* Release: [v0.12.0-beta](https://github.com/bootgly/bootgly/releases/tag/v0.12.0-beta)
* Docs: [docs.bootgly.com](https://docs.bootgly.com/)
* Website: [bootgly.com](https://bootgly.com/)

Feedback and questions welcome!
I am a maintainer of Bootgly.

https://redd.it/1sdzvps
@r_php
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/1sdqksd
@r_php
How to secure the code?

Hi. So im a degree student that almost graduate and in doing a final year project. I just wanna gain some knowledge. I know that security is one of the most crucial parts in coding. But where and how can i learn that? People always say, "You gotta make it safe and secured", but never tell on where to look and practice. So any of you who are expert, please give me ways on how to do this. In the era of AI, i also use it. But not blindly copy and pasting, i will review and modify code if needed. But for security, i do lack of knowledge. So please redditors out there, enlighten me!

https://redd.it/1se2n97
@r_php
Laravel AI SDK Workflow, Node, Events

Hi everyone 👋🏻

The Laravel AI SDK has been out for a while now. I really appreciate the work that's been done, especially since it's maintained by the Laravel team.

However, I believe it is still quite limited compared to Neuron AI — specifically around workflow logic, nodes, and events, along with the corresponding checkpoints to pause and resume the flow. These are patterns that are essential for production agentic apps: multi-step pipelines, human-in-the-loop approval flows, and stateful orchestration across multiple HTTP requests.

So I decided to start a discussion and offer my support to the development team

👉 https://github.com/laravel/framework/discussions/59338

What do you think? Do you have any ideas on this?

https://redd.it/1se8fnh
@r_php
Laravel SDK for Rapyd payments - full API coverage with Facade, webhooks, and typed DTOs

Rapyd is a fintech-as-a-service platform (payments, payouts, wallets, card issuing, KYC) but has no official Laravel package. I built one.

**saba-ab/rapyd** — a Laravel package wrapping the full Rapyd API with a clean Facade, resource-based architecture, webhook handling, and typed DTOs.

// Create a payment
$payment = Rapyd::payments()->create([
'amount' => 100,
'currency' => 'USD',
'payment_method' => ['type' => 'us_visa_card', 'fields' => [...]],
]);

// Webhook verification is automatic on the registered route

What's included:

* `Rapyd::` Facade with fluent resource accessors (payments, refunds, customers, checkout, subscriptions, payouts, wallets, cards, KYC, fraud)
* HMAC-SHA256 request signing handled internally
* Auto-registered webhook route with signature verification
* Config-driven sandbox/production switching
* Built on `spatie/laravel-package-tools`
* Artisan commands: `rapyd:test-connection`, `rapyd:list-payment-methods`
* PHP 8.2+, Laravel 11/12/13

Install: `composer require saba-ab/rapyd`

GitHub: [https://github.com/saba-ab/rapyd](https://github.com/saba-ab/rapyd)

I also built a Python SDK covering the same API surface (`rapyd-py` on PyPI) and an MCP server is in the works.

https://redd.it/1se7au8
@r_php
PHP developers who stream on Twitch?

There is a post about this already but its from years ago.

"I was wondering if there are any developers from the PHP/Laravel world who stream on Twitch (or any other platform) on a regular basis. I don't necessarily mean core developers, but developers of more or less well-known packages or extensions."

For personal reasons I can't code right now but it would be awesome to follow along someone building a project live :) I would love some recomendations. Thanks!

https://redd.it/1sedh7o
@r_php
I built a Redis-based alternative to Laravel permission systems (140+ installs) – looking for feedback

Hey everyone 👋

I’ve been working on a Redis-based alternative to traditional Laravel permission systems.

The idea is to avoid hitting the database on every permission check and improve performance in high-traffic apps.

It currently has 140+ installs, and I’d really appreciate feedback from people running Laravel at scale.

Repo:

https://github.com/scabarcas17/laravel-permissions-redis

Curious how you all handle permissions in larger applications 🤔

https://redd.it/1sedxwp
@r_php
I built a framework to turn Laravel + Livewire apps into desktop & mobile apps using PHP WebAssembly, no Electron, no React Native

Hey everyone,

I've been working on a side project called NativeBlade and wanted to share it with the community.

The idea is simple: take your Laravel + Livewire app and run it as a native desktop or mobile application. No server needed. No Electron. No JavaScript frameworks. Just PHP and Blade.


How it works

Your entire Laravel application gets bundled and runs inside a PHP WebAssembly runtime, wrapped in a https://v2.tauri.app shell. The architecture looks like this:


\- PHP 8.3 runs in the browser via WebAssembly

\- Blade templates and Livewire components work as-is

\- SQLite database persists to IndexedDB (survives app restarts)

\- Native shell components (header, bottom nav, drawer) render outside the WebView — no flicker during navigation

\- Native OS features (dialogs, notifications, system tray) work through a bridge


The whole thing started as a weekend experiment: "what if I could just composer require something and turn my Laravel app into a desktop app?"


What it can do


\- Desktop: Windows, macOS, Linux with native menus and system tray

\- Mobile: Android & iOS with status bar, safe area, swipe back

\- External HTTP requests: Http::get() works transparently through a JS bridge — PHP signals what it needs, JavaScript makes the real fetch, PHP re-executes with the cached

response. You can even use NativeBlade::pool() to run multiple requests in parallel via Promise.all()


\- 1,512 built-in icons from https://phosphoricons.com/ — works in both shell components and Blade templates

\- Hot reload during development via a Vite plugin that watches PHP/Blade files

\- Offline-first — everything runs client-side, no internet required after install


That's it. Your Laravel app is now a desktop application.


What doesn't work



I want to be upfront about the limitations. Since PHP runs in WebAssembly, there's no real server:


\- No queues/jobs — no background worker process

\- No mail — no SMTP from WASM

\- No MySQL/Postgres — SQLite only

\- No sessions — uses a built-in state management instead

\- No cron/scheduling

\- Http::get() works but through a bridge (not native PHP networking)



It's not meant to replace server-side Laravel. It's for apps that run locally and don't need a backend, think tools, dashboards, utilities, offline apps.



Why I'm sharing this


This started as a learning project and I'd love to get feedback from the PHP community. The codebase touches a lot of interesting areas:


\- PHP WebAssembly internals

\- Tauri 2 (Rust-based alternative to Electron)

\- Livewire's lifecycle inside a non-standard runtime

\- Bridging sync PHP with async JavaScript


If any of this sounds interesting to you — whether you want to contribute, experiment, or just tell me what I'm doing wrong — I'd appreciate it.


GitHub: https://github.com/NativeBlade/NativeBlade



Happy to answer any questions!

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