PHP Reddit – Telegram
PHP Reddit
34 subscribers
286 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
Would a pure php template engine be useful?

Lately I'm thinking about a template engine that just wraps html in classes, so you would write

(new Html(lang: 'en'))(

(new Head())(...),

(new Body(class: 'xxx', data: ['xxx':'yyy'])( ...))

)


making it would be as simple as

class Html implements \Stringable {

public $lang;

public function __construct(public Head $head, public Body $body) {}

public function __toString {

return "<html lang=\"{$this->lang}\">{$this->head}{$this->body}<html>";

}

}

I see some cool features: auto complete for html tags and parameters, template is testable, would be easy to create for example a Product class that extends or wraps Div and can be reused, should be easy to cache as everything is stringable.

The drawbacks I see are that could be not super easy to read and you need some architectural knowledge to not create a super huge class or countless not-easy-to-find sparse mini templates. Probably a tool to translate from html to this would be useful. also, I don't know how it would scale with speed and memory, as you will have several classes nested into each other.

What do you think? Would it be useful or just a waste of time?

https://redd.it/1ps9837
@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/1pscozl
@r_php
A guide on dockerizing a Laravel + Inertia (React) app

Hey everyone!

I wrote a guide on dockerizing a Laravel + Inertia (React) application, it covers local development with Docker Compose, handling permissions and queues properly, multi-stage builds for a production image, testing the production image locally, and using Docker Compose with prebuilt images for deployment.

Feedback is welcome, hope you guys find it useful!

Link : https://aabidk.dev/blog/dockerizing-a-laravel-and-inertia-app/

https://redd.it/1psds71
@r_php
I work for a small to medium sized Japanese company and all our products use Laravel. However, I noticed something with the coding styles of my coworkers and want to ask if this is normal in other teams and companies. It's about coding style in a Laravel project.

You see, my coworkers never use collections at all. I want to emphasize the word "never." I understand not everything, collections and its functions should be used, but having researched about Laravel, it has felt weird for me that my coworkers never use it in any situation. My coworkers almost always use query builder and in every query they write regardless if it's eloquent or query builder, always call toArray() function after calling get(), and exclusively use arrays and array functions together with foreach loops.

Meanwhile, I've come across the Laravel Way and started using Eloquent and collections and its functions. I still use arrays and query builder but only in what I believe to be necessary situations.

Is this raw PHP style of coding in Laravel prevalent? Would you consider this irrelevant since it's all preference at the end of the day or is it wrong coding style when using Laravel?

https://redd.it/1pskj9x
@r_php
Weekly Ask Anything Thread

Feel free to ask any questions you think may not warrant a post. Asking for help here is also fine.

https://redd.it/1psq6cx
@r_php
Help! React CV layout breaks when exporting to PDF (Tried html2canvas and dompdf)

Hi everyone,

I’m building a CV generator in React. The UI looks perfect on the frontend, but I’m struggling to export it to PDF.

I first tried html2canvas (with jsPDF), but the quality was blurry and the scaling was off. Then I tried dompdf on the backend, but it doesn't support modern CSS (Flexbox/Grid), so the layout completely falls apart.

Does anyone have a proven way to get a "What You See Is What You Get" (WYSIWYG) PDF export from a React component? I need it to respect my exact CSS. Thanks!

https://redd.it/1pst80w
@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/1pst3z3
@r_php
Spikard v0.5.0 Released

Hi peeps,

I'm glad to announce that [Spikard](https://github.com/Goldziher/spikard) v0.5.0 has been released. This is the first version I consider fully functional across all supported languages.

## What is Spikard?

Spikard is a *polyglot web toolkit* written in Rust and available for multiple languages:

- Rust
- Python (3.10+)
- TypeScript (Node/Bun)
- TypeScript (WASM - Deno/Edge)
- PHP (8.2+)
- Ruby (3.4+)

## Why Spikard?

I had a few reasons for building this:

I am the original author of [Litestar](https://litestar.dev/) (no longer involved after v2), and I have a thing for web frameworks. Following the work done by [Robyn](https://github.com/sparckles/Robyn) to create a Python framework with a Rust runtime (Actix in their case), I always wanted to experiment with that idea.

I am also the author of [html-to-markdown](https://github.com/Goldziher/html-to-markdown). When I rewrote it in Rust, I created bindings for multiple languages from a single codebase. That opened the door to a genuinely polyglot web stack.

Finally, there is the actual pain point. I work in multiple languages across different client projects. In Python I use Litestar, Sanic, FastAPI, Django, Flask, etc. In TypeScript I use Express, Fastify, and NestJS. In Go I use Gin, Fiber, and Echo. Each framework has pros and cons (and some are mostly cons). It would be better to have one standard toolkit that is correct (standards/IETF-aligned), robust, and fast across languages.

That is what Spikard aims to be.

## Why "Toolkit"?

The end goal is a toolkit, not just an HTTP framework. Today, Spikard exposes an HTTP framework built on [axum](https://github.com/tokio-rs/axum) and the Tokio + Tower ecosystems in Rust, which provides:

1. An extremely high-performance core that is robust and battle-tested
2. A wide and deep ecosystem of extensions and middleware

This currently covers HTTP use cases (REST, JSON-RPC, WebSockets) plus OpenAPI, AsyncAPI, and OpenRPC code generation.

The next step is to cover queues and task managers (RabbitMQ, Kafka, NATS) and CloudEvents interoperability, aiming for a full toolkit. A key inspiration here is [Watermill](https://watermill.io/) in Go.

## Current Features and Capabilities

- REST with typed routing (e.g. `/users/{id:uuid}`)
- JSON-RPC 2.0 over HTTP and WebSocket
- HTTP/1.1 and HTTP/2
- Streaming responses, SSE, and WebSockets
- Multipart file uploads, URL-encoded and JSON bodies
- Tower-HTTP middleware stack (compression, rate limiting, timeouts, request IDs, CORS, auth, static files)
- JSON Schema validation (Draft 2020-12) with structured error payloads (RFC 9457)
- Lifecycle hooks (`onRequest`, `preValidation`, `preHandler`, `onResponse`, `onError`)
- Dependency injection across bindings
- Codegen: OpenAPI 3.1, AsyncAPI 2.x/3.x, OpenRPC 1.3.2
- Fixture-driven E2E tests across all bindings (400+ scenarios)
- Benchmark + profiling harness in CI

Language-specific validation integrations:

- Python: msgspec (required), with optional detection of Pydantic v2, attrs, dataclasses
- TypeScript: Zod
- Ruby: dry-schema / dry-struct detection when present
- PHP: native validation with PSR-7 interfaces
- Rust: serde + schemars

## Roadmap to v1.0.0

**Core:**
- Protobuf + protoc integration
- GraphQL (queries, mutations, subnoscriptions)
- Plugin/extension system

**DX:**
- MCP server and AI tooling integration
- Expanded documentation site and example apps

**Post-1.0 targets:**
- HTTP/3 (QUIC)
- CloudEvents support
- Queue protocols (AMQP, Kafka, etc.)

## Benchmarks

We run continuous benchmarks + profiling in CI. Everything is measured on GitHub-hosted machines across multiple iterations and normalized for relative comparison.

Latest comparative run (2025-12-20, Linux x86_64, AMD EPYC 7763 2c/4t, 50 concurrency, 10s, oha):

- spikard-rust: 55,755 avg RPS (1.00 ms avg latency)
- spikard-node: 24,283 avg RPS (2.22 ms avg latency)
- spikard-php: 20,176 avg RPS (2.66 ms avg latency)
- spikard-python: 11,902 avg RPS (4.41 ms avg latency)
- spikard-wasm: 10,658 avg RPS (5.70 ms avg latency)
-
spikard-ruby: 8,271 avg RPS (6.50 ms avg latency)

Full artifacts for that run are committed under `snapshots/benchmarks/20397054933` in the repo.

## Development Methodology

Spikard is, for the most part, "vibe coded." I am saying that openly. The tools used are Codex (OpenAI) and Claude Code (Anthropic). How do I keep quality high? By following an outside-in approach inspired by TDD.

The first major asset added was an extensive set of fixtures (JSON files that follow a schema I defined). These cover the range of HTTP framework behavior and were derived by inspecting the test suites of multiple frameworks and relevant IETF specs.

Then I built an E2E test generator that uses the fixtures to generate suites for each binding. That is the TDD layer.

On top of that, I follow BDD in the literal sense: Benchmark-Driven Development. There is a profiling + benchmarking harness that tracks regressions and guides optimization.

With those in place, the code evolved via ADRs (Architecture Decision Records) in `docs/adr`. The Rust core came first; bindings were added one by one as E2E tests passed. Features were layered on top of that foundation.

## Getting Involved

If you want to get involved, there are a few ways:

1. Join the [Kreuzberg Discord](https://discord.gg/wb8SEWvM)
2. Use Spikard and report issues, feature requests, or API feedback
3. Help spread the word (always helpful)
4. Contribute: refactors, improvements, tests, docs


https://redd.it/1psv4y8
@r_php
Spikard v0.5.0 Released

Hi peeps,

I'm glad to announce that [Spikard](https://github.com/Goldziher/spikard) v0.5.0 has been released. This is the first version I consider fully functional across all supported languages.

## What is Spikard?

Spikard is a *polyglot web toolkit* written in Rust and available for multiple languages:

- Rust
- Python (3.10+)
- TypeScript (Node/Bun)
- TypeScript (WASM - Deno/Edge)
- PHP (8.2+)
- Ruby (3.4+)

## Why Spikard?

I had a few reasons for building this:

I am the original author of [Litestar](https://litestar.dev/) (no longer involved after v2), and I have a thing for web frameworks. Following the work done by [Robyn](https://github.com/sparckles/Robyn) to create a Python framework with a Rust runtime (Actix in their case), I always wanted to experiment with that idea.

I am also the author of [html-to-markdown](https://github.com/Goldziher/html-to-markdown). When I rewrote it in Rust, I created bindings for multiple languages from a single codebase. That opened the door to a genuinely polyglot web stack.

Finally, there is the actual pain point. I work in multiple languages across different client projects. In Python I use Litestar, Sanic, FastAPI, Django, Flask, etc. In TypeScript I use Express, Fastify, and NestJS. In Go I use Gin, Fiber, and Echo. Each framework has pros and cons (and some are mostly cons). It would be better to have one standard toolkit that is correct (standards/IETF-aligned), robust, and fast across languages.

That is what Spikard aims to be.

## Why "Toolkit"?

The end goal is a toolkit, not just an HTTP framework. Today, Spikard exposes an HTTP framework built on [axum](https://github.com/tokio-rs/axum) and the Tokio + Tower ecosystems in Rust, which provides:

1. An extremely high-performance core that is robust and battle-tested
2. A wide and deep ecosystem of extensions and middleware

This currently covers HTTP use cases (REST, JSON-RPC, WebSockets) plus OpenAPI, AsyncAPI, and OpenRPC code generation.

The next step is to cover queues and task managers (RabbitMQ, Kafka, NATS) and CloudEvents interoperability, aiming for a full toolkit. A key inspiration here is [Watermill](https://watermill.io/) in Go.

## Current Features and Capabilities

- REST with typed routing (e.g. `/users/{id:uuid}`)
- JSON-RPC 2.0 over HTTP and WebSocket
- HTTP/1.1 and HTTP/2
- Streaming responses, SSE, and WebSockets
- Multipart file uploads, URL-encoded and JSON bodies
- Tower-HTTP middleware stack (compression, rate limiting, timeouts, request IDs, CORS, auth, static files)
- JSON Schema validation (Draft 2020-12) with structured error payloads (RFC 9457)
- Lifecycle hooks (`onRequest`, `preValidation`, `preHandler`, `onResponse`, `onError`)
- Dependency injection across bindings
- Codegen: OpenAPI 3.1, AsyncAPI 2.x/3.x, OpenRPC 1.3.2
- Fixture-driven E2E tests across all bindings (400+ scenarios)
- Benchmark + profiling harness in CI

Language-specific validation integrations:

- Python: msgspec (required), with optional detection of Pydantic v2, attrs, dataclasses
- TypeScript: Zod
- Ruby: dry-schema / dry-struct detection when present
- PHP: native validation with PSR-7 interfaces
- Rust: serde + schemars

## Roadmap to v1.0.0

**Core:**
- Protobuf + protoc integration
- GraphQL (queries, mutations, subnoscriptions)
- Plugin/extension system

**DX:**
- MCP server and AI tooling integration
- Expanded documentation site and example apps

**Post-1.0 targets:**
- HTTP/3 (QUIC)
- CloudEvents support
- Queue protocols (AMQP, Kafka, etc.)

## Benchmarks

We run continuous benchmarks + profiling in CI. Everything is measured on GitHub-hosted machines across multiple iterations and normalized for relative comparison.

Latest comparative run (2025-12-20, Linux x86_64, AMD EPYC 7763 2c/4t, 50 concurrency, 10s, oha):

- spikard-rust: 55,755 avg RPS (1.00 ms avg latency)
- spikard-node: 24,283 avg RPS (2.22 ms avg latency)
- spikard-php: 20,176 avg RPS (2.66 ms avg latency)
- spikard-python: 11,902 avg RPS (4.41 ms avg latency)
- spikard-wasm: 10,658 avg RPS (5.70 ms avg latency)
-
spikard-ruby: 8,271 avg RPS (6.50 ms avg latency)

Full artifacts for that run are committed under `snapshots/benchmarks/20397054933` in the repo.

## Development Methodology

Spikard is, for the most part, "vibe coded." I am saying that openly. The tools used are Codex (OpenAI) and Claude Code (Anthropic). How do I keep quality high? By following an outside-in approach inspired by TDD.

The first major asset added was an extensive set of fixtures (JSON files that follow a schema I defined). These cover the range of HTTP framework behavior and were derived by inspecting the test suites of multiple frameworks and relevant IETF specs.

Then I built an E2E test generator that uses the fixtures to generate suites for each binding. That is the TDD layer.

On top of that, I follow BDD in the literal sense: Benchmark-Driven Development. There is a profiling + benchmarking harness that tracks regressions and guides optimization.

With those in place, the code evolved via ADRs (Architecture Decision Records) in `docs/adr`. The Rust core came first; bindings were added one by one as E2E tests passed. Features were layered on top of that foundation.

## Getting Involved

If you want to get involved, there are a few ways:

1. Join the [Kreuzberg Discord](https://discord.gg/wb8SEWvM)
2. Use Spikard and report issues, feature requests, or API feedback
3. Help spread the word (always helpful)
4. Contribute: refactors, improvements, tests, docs


https://redd.it/1psv4s6
@r_php
How do you handle simple content websites when your main stack is Laravel?

I have a question for the Laravel community as the year comes to an end, just before logging off for a few days:

What tools, stack, or workflow do you use for projects that would clearly benefit from static hosting?

At Code 16, we regularly have projects like this and we’ve been developing and maintaining a tool for the past 2–3 years specifically for these cases. It let us use our Laravel stack (Laravel, MySQL, Tailwind, Alpine), deploy the website anywhere in one click and manage the content with a custom CMS. The problem it solves is quite complex, and our solution has proven to be very effective for us. We use it in production, including for our own website.

I’m genuinely curious if other Laravel developers have similar needs, and if so, how do you usually address them?

https://redd.it/1psz5gp
@r_php
Easy deployment option for a Laravel Livewire+Octane+Reverb application

Hey, I'm looking for some simple deployment option for my laravel application.

I was thinking about dockerizing everything, which would be the best thing but I've discovered some interesting options... for example VitoDeploy or Deployer.org or Coolify etc...

My application currently uses:

* Livewire

* Octane

* Reverb


I do multiple deployments of this application for each "customer". I am looking for the simplest option.

At the moment I'm using Docker+Caddy as proxy, but every time there is a small change to do I have to wait for the docker container to rebuild and restart.

VitoDeploy looks really cool but at the moment it does not support giving restricted access to only some websites to users.

What are you guys using?

https://redd.it/1pszt44
@r_php
Why Is There So Little Laravel Content on YouTube?

This might annoy some people, but I keep noticing it.

Laravel is huge. Plenty of serious apps running on it. But when you go on YouTube, it feels almost empty unless you are watching something from the Laravel team.

Search Laravel and you mostly get official talks, release stuff, or very basic tutorials. Same few channels over and over.

Compare that to React or Next. Endless videos. Opinions. Deep dives. People arguing about architecture. People building in public.

With Laravel it feels like everyone just goes to work, builds their app, and logs off.

Why is that?

Are Laravel devs just not into making videos?
Is it because most Laravel work is agency or client stuff that you cannot really share?
Is PHP still uncool enough that people do not want to put their face on YouTube talking about it?

I love Laravel, but compared to other ecosystems, the lack of independent YouTube creators is hard to ignore and probably costs it new users.

Does PHP just not get enough views?

https://redd.it/1pt8qag
@r_php
Why no Elasticsearch support in Forge?

Just wondering if this is a legal issue, maintenance cost, or something else.
Forge supported Meilisearch but not Elasticsearch?




https://redd.it/1pt90o5
@r_php
New Job. Awesome People. Terrible Codebase Management.

I recently started at a new place. And I absolutely love 99.9% of it. My co workers are fun to work with (mainly grey beards who’ve been at it for awhile), my boss is easy going and it’s overall very relaxed. But theres a few small things that just keeps eating at me.

1. They don’t update hardly anything. I’m currently working on a large legacy codebase that was born long before my coworkers started there. Buuuttt, no one has made an effort to clean it up, update it, nothing. It works (barely), but it’s running on PHP 7.4, every dependency version is at an unmaintained level. It’s a giant spaghetti mess with absolutely zero tests. There is no style standard or formatting norm. Not to mention it’s all vanilla PHP with Apache handling the routing. It’s bad.

2. Applications they have built in the last few years in Laravel haven’t been updated since they have been scaffolded. One of which isn’t very large, but still running on Laravel 10. This one also has a slight spaghetti feel to it, but is salvageable.

We are going to be starting a rewrite of the legacy app within the next ~6 months. And I’m getting worried that it’s at risk of being a sloppy build. My lead is already talking about how he wants to restructure the directory layout so it’s “easier to maintain”. He is vehemently against frontend frame works even though a large part of the app would really benefit from client side rendering (registration flows, realtime updating tables, dashboards, heavy data things, etc).

So what I want to know is, how do I start trying to turn the ship in the right direction? My boss seems to really latch on to my ideas and likes my approach to work. But my lead is already trying to shoot down any idea I have (like just sticking to normal conventions).

Any advice on any of these ramblings would be greatly appreciated!!

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