PHP Reddit – Telegram
PHP Reddit
34 subscribers
293 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
Effortless Laravel & Inertia Data and Type Sync

Hey Laravel Devs 👋

If you're using Laravel with Inertia.js, you know the struggle of keeping your backend data structures and frontend TypeScript types in sync. It's tedious and error-prone.

Here's what you'll learn:

Backend configuration with Spatie Data
Frontend integration for automatic type generation
Tips and Tricks

https://www.alializadehdev.com/blogs/effortless-laravel-and-inertia-data-and-type-sync-dto-magic

https://redd.it/1jchvzv
@r_php
City State Registration

What is the best way to allow users selected a city once a state has been chosen during their user registration ? Is creating a City table referencing the state table feasible? Or would it be too large of a table and slow down website ?

https://redd.it/1jcjipj
@r_php
React.js in PHP?

I've been too preoccupied with whether I could, that I haven't cared the slightest about whether I should, and thus I've been chipping away at a PHP to JS transpiler which is now capable of just about enough that I have a very basic React.js app running in the browser, written in PHP.

This is the PHP code that makes it run: https://github.com/nomaphp/js/blob/main/examples/complex/react.php

This is the resulting JS: https://github.com/nomaphp/js/blob/main/examples/complex/react.js

And the whole thing put together: https://github.com/nomaphp/js/blob/main/examples/complex/test.php

So to be clear - it is not PHP running the front-end, it's JavaScript, but you write PHP which gets transpiled to JavaScript. My test example does run-time transpilation, but of course for performance reasons you'd probably want to cache it or just write the resulting JS into a .js file or something.

Been having a lot of fun with this! Why would anyone use this? Well for me the benefits are statically typed code (though you lose runtime validation of course) and the ability to share code, so if I have a utility function in PHP I can then also use the same exact function for my front-end. It's an extremely basic proof of concept, so don't think of it as anything serious just yet.

https://redd.it/1jcpbb8
@r_php
Shaping the Future of Laravel's API Starter Kit – What Should It Include?

Hey everyone!

With Laravel working on its own API starter kit, now is a great time for the community to define what a modern, well-architected REST API should look like. I’m starting a freelance project that involves building a large-scale REST API for a web and mobile ecosystem, as well as third-party integrations as a paid service. I want to align my approach with best practices and contribute to the broader discussion on what should be included in Laravel’s API tooling.

Here’s my initial list of must-have features:

* **JSON:API specification** as a baseline, with additional standards for dates (ISO 8601), country/currency codes, etc.
* **Stateless design** with proper HTTP verbs, status codes, semantic versioning in the URL, and cacheability (`Cache-Control`).
* **Rate limiting** to ensure fair usage and prevent abuse.
* **Comprehensive documentation** using OpenAPI.
* **CI/CD pipeline** with GitHub Actions for automated testing and deployment.

For those who have built APIs with Laravel, what else would you consider essential? What conventions, packages, or best practices should Laravel’s API starter kit include? Let’s make this a solid reference for modern API development in Laravel!

https://redd.it/1jcsh7k
@r_php
Building a State-of-the-Art REST API – What would you include?

Hi there!

I'm starting a new freelance project (with Laravel) - a large-scale REST API designed to power an ecosystem of web and mobile applications, as well as serve third-party integrations as a paid service. My goal is to make this API state-of-the-art by implementing best practices from the start.

I'm compiling a list of essential features and design principles, and I'd love to hear your thoughts! If you were given a chance to build the next "perfect API", what would you include?

Here’s my initial list:

* **JSON:API specification** as the baseline, with additional standards for dates (ISO 8601), country/currency codes, etc.
* **Stateless design** with proper use of HTTP verbs, status codes, semantic versioning in the URL, and cacheability (via `Cache-Control`).
* **Rate limiting** to prevent abuse and ensure fair usage.
* **Comprehensive documentation** using OpenAPI.
* **CI/CD pipeline** with GitHub Actions for automated testing and deployment.

What would you add to this list? Any best practices, tools, or lessons learned from your own experience?

Thanks!

https://redd.it/1jcsb03
@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/1jcq1wj
@r_php
Q: AI to make php layout from word.doc

Like the noscript says. Is there an AI program, or any program/website that can convert a word.doc or PDF into a php ready web layout? I would map the back end parameters.

The source docs would be forms with check boxes and text fields.

I found a site that converts PDFs to HTML format but that didn't really help. I would need the layout.php ya?

Thanks all for any suggestions.

https://redd.it/1jcxgsq
@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/1jd3bg8
@r_php
Laravel 12 + Sail Docs Removed?

It seems like a lot of the documentation for Sail has been removed for Laravel 12x.

For example, there used to be instructions for a fresh Laravel Sail install without installing PHP/Composer locally, choosing your services, etc.

https://laravel.com/docs/11.x/installation

It looks like they include Sail by default with 12.x or something?

But it is weird they would remove this info and laravel.build URL from the docs, as well as that command for developers to run everything within the container locally to get started.

Sail is still the easiest way to get started with Laravel, even with all this https://php.new bullshit. I would hate to see it get sidelined by Herd and other things.

https://redd.it/1jd6fh5
@r_php
Dutch PHP Conference 2025

Hi all; any people from our little corner of the Reddits, other than the esteemed u/brendt_gd as a speaker, joining the Dutch PHP Conference this year? If so, this is an open invite to come and say hi - would love to spend this opportunity meeting some of you face to face.

I'm Sander, part of the Egeniq crew, helping iBuildings run the combined DPC/ADC/WDC conferences. Feel free to ask any of my colleagues to point you in my direction, or come find me after my talk during the 10:55-11:40 timeslot.

https://redd.it/1jd7kvd
@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/1jd6qk1
@r_php
Thoughts on "Laravel as Backend for Frontend"

Hi everyone,

I currently have two APIs built with Laravel, and a centralized authentication system also using Laravel along Passport, Spatie Permission & Socialite.

I'm in the process of migrating my app from Remix v2 to React Router v7. Although everything is going smoothly, some things are bugging me - I am talking about things that in PHP and especially Laravel are easy to solve. For example trying to now set a second cookie on a RR redirect, but nada (https://github.com/remix-run/remix/issues/231). Also an unstable middleware, server and client loaders and actions. It becomes a mess and you are trying to find a workaround for too many things. Your BFF becomes harder than your actual back-end.

Mutations: For multiple on page or component actions, either I have to use TanstackQuery mutations (which I have to handle and do validator.revalidate() so RR will know that it has to re-fetch the data) or I have to name my actions(with an intent or some property) and make a handler in the main action to match the name and the callback. If I want to use the RR7 useFetcher hook for example, I have to make a second abstraction hook on top of the first one(useFetcher, useSubmit) to add callbacks like onSuccess, onError and so on.

So, I was thinking that Laravel along with Inertia can act like a nice BFF. Only fetching data from my APIs, caching, managing the session, refreshing tokens, and more. What are your thoughts on this? Anyone that has already tried it?

P.S I would not add Inertia and views to any of my APIs. I like to separate these two concerns.

https://redd.it/1jdfpng
@r_php
"elePHPant" toy!

I'm having a hard time getting hold of an elePHPant soft toy in the UK.

So apparently this is the official website: https://www.elephpant.com/, but I can't actually buy one from there! Seems like only the origami version is available haha!

I also came across this site: https://www.phpclasses.org/shop/product/eles1/ but that's way too expensive! It's comes to £50 with delivery.

Anyone know where I can get one from that isn't going to cost the earth?

EDIT: I also found this site: https://elephpant.co.uk/, which looks promising. They say they are going to launch later this year, well let's see about that! I've signed up anyhow.

https://redd.it/1jdma7g
@r_php
How do you manage file uploads?

After several months away from my PC, I've started coding again. I'm currently working on a Symfony project (version 7.2) with an administration tool using the EasyAdmin bundle. Until now, I've been managing image uploads with VichUploaderBundle. Not being satisfied with the basic rendering of the Vich field, I want to transform it into a dropzone with a preview, but I'm a little lost, and I have several questions: Is Vich still relevant for managing file uploads to a Symfony project? Which library do you recommend for creating the dropzone? I've tried Filepond, but I can't get the files to be saved correctly. Would it be simpler to simply "dress up" the basic Vich field to make it more aesthetically pleasing/functional?

https://redd.it/1jdnmbv
@r_php
Anyone moved a a laravel app from digital ocean to hetzner?

I've been using digital ocean for years so i'm a little tentative to leave but looking at hetzner's offering it seems I could either save loads of money or massively upgrade my resources for the same amount. Has anyone made the switch and it was worth it?


I have a traditional server side rendered forum (blade etc) that generally has 150k unique visitors per day occasionally peaks upto 500k unique visitors per day.


Currently I have:

£336- Server - CPU-Optimized / 32 GB / 16 vCPUs

$240 - MySQL - Basic 16 GB / 6 vCPU / 290 GB Disk

$300 - 15TB Spaces usage

Total: $860


With Hetzner:

$107 - Server - 64 GB/ 16 vCPUs

$54 - Server (MySQL) - 32GB / 8 vCPUs / 240 GB Disk

$90 - 15TB Object Storage

Total: $251


A crazy 70% discount!


Or I could totally beef up my resources for the same amount


$320 - Server - 192 GB/ 48 vCPUs

$215 - Master MySQL - 128GB / 32 vCPUs / 600 GB Disk

$215 - Read Only MySQL - 128GB / 32 vCPUs / 600 GB Disk

$90 - 15TB Object Storage

Total: $840

Basically the same price with alot more piece of mind and hopefully performance improvements for the end user as well.


Maybe I wouldn't even need the second servers for MySQL and could just go back to having MySQL running on the one server given the huge resources available.


But i'm obviously concerned how long it would take (1 months work $$$ vs $600 a month saving) and the potential downtime. Everything could be copied slowly in the background and it would just be the database that needs to be dumped and imported possibly over an hour or two (50GB database). Which doesn't sound so bad, but then again, disaster could occur.


Has anyone made the transition and have some stories to tell of how you went about it, how long you took etc?


Maybe one month is far more than i'd need and it would only take a day or two to get setup. But ideally i'd like to do a few weeks load testing to make sure all the configs are set up properly.

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