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
Livewire/blade Nvim setup

Currently work mainly with Laravel+inertia+react but want to have a play with livewire. Does anyone have any good plugin/config repo suggestions for neovim (specifically for blade w livewire components)

https://redd.it/1jaz5mx
@r_php
🚀 Laravel 12 + React API Token Management – Watch This! 🔑

Hey Devs! If you're using Laravel 12 with the React Starterkit and need a simple way to handle API token management, you’ll want to check out this video! 🎥

I walk you through Keysmith React, a package I built to make API key generation, management, and permissions super easy with Laravel Sanctum and React components.

# 🔎 What You’ll Learn:

Installing & setting up Keysmith React
Choosing between Page or Settings templates
Generating & managing API tokens with Laravel Sanctum
Customizing permissions and authentication flow
Running tests to ensure everything works smoothly

🎥 Watch the full tutorial here: https://youtu.be/cUyYTp\_eapI

Let me know what you think, and feel free to drop questions in the comments! 🙌

https://redd.it/1jb3pj8
@r_php
Proper way of non permitted action

Let say i hav use case in which only employees that have passed certain condition can be assigned some work.

So inside WorkController assignWork() method I do :

If(!$employee->pass()) {
//what should I do here?
//do i create exception?
//or use flash message to inform and reroute?
}else{
//create form and proceed as usual
}

Preferably i would like to show modal dialog to inform user. So what s best n proper way?

1. Exception or
2. Flash message?
3. Do checking in twig and hide button?

https://redd.it/1jb619p
@r_php
Suggest a best template for building a SDK PHP/Laravel ?

hi,

i recently launched a web screenshot API, i am looking for a template to create a PHP/Laravel SDK for my API, i am good In JavaScript, Haven't used PHP in last few years, can anyone suggest a starter template for a SDK.

https://redd.it/1jbbdbd
@r_php
I took the PHPill

For a while now my default way of building full stack web apps has been Flask + Sqlite + Whatever frontend I felt like. This usualy resulted in bloated, JS-full unmainanble mess. I have dabbled in using Go (Excellent) and Rust (Too type-happy) for my back-end but my front-end usually ended up being the thing that dragged me down. A minor epiphany of mine was discovering HTMX. But recently I got my mind blown by one of my friends who made a whole "smart map" (won't get into more detail) app whilst staying entirely Web 1.0 compliant. This prompted me to try PHP (though she was also using Flask but I didn't know it).

Honestly, the most fun I've had programming in years. In the span of an hour I had made a simple bulletin board app with nothing but html, PHP and SQL. It just blew my mind that you could put the code relevant to a page in the page rather than using templating (though I must concede that Jinja is excellent). I even started to re-learn all of the HTML that years of ChatGPT copy-pasting made me forget. You also get all of the benefits that Go has as a Web first language: the session system just blew my damn mind the first time around: I had no idea cookies without JavaScript were even a thing. Not dreading the inevitable JS blunders or the slog of having to find what part of my code is relevant was awesome.

Plus, I'm not a big framework guy, I don't like using Rails or the likes (Flask is still too pushy for me at times), so I was scared at first that Laravel was a requirement but raw, pure PHP just work, it clicked in my brain, the syntax (apart from the semicolons that aren't used for anything interesting) just clicked with me. Don't even get me started with arrays, its like they copied Lua in advance.

Anyway, what I mean to say is that PHP is a fast, easy to use, and sensical language everyone should absolutely give a shot to. I will definitely be using it in every single one of my projects for the foreseeable future.

https://redd.it/1jbe066
@r_php
Explicit nullable type vs Type Hinting

Are there any technical differences between these?

public function Foo(?int $int = null) {}

and:

public function Foo(int|null $int) {}

https://redd.it/1jbh2ok
@r_php
Using AI for code reviews

Anyone using AI for PHP code reviews? If so, what are you using and how?

I've had a go at it using ChatGPT and my own custom prompts but feels clunky and quite manual. Can't help feeling that there's people out there that are doing it better.

https://redd.it/1jbsabn
@r_php
Community Starter Kits GALLERY update

https://preview.redd.it/1t5x5t02uwoe1.png?width=1413&format=png&auto=webp&s=ebcc033f44461d4da12248a90f8c6db2b033187b



Hey ya!

Some of you might have seen my previous post about a project I was working on a couple days ago

Application here

>TLDR:
Laravel installer now supports community starter kits through the laravel new --using command. While this is a great feature, finding and evaluating different starter kits on GitHub can be time-consuming.
This opensource platform aims to solve that by providing a central place to:

Discover community starter kits
Share starter kits with the community



Since that post, I've made a few additions, including:

Tags to filter through available starterkits (e.g. stripe, vue etc..)

Bookmark your favourites

Ranking system based on number of bookmarks

Layout changes and dark mode fixed

I want to keep the app as usable as possible, while keeping it pretty minimal.


So yeah, if you wanna try out the app or even submit your favourite starterkits, feel free!

If you want to report issues, or feature requests, you can either DM me, or do it via github, either one is fine!


Github ( feel free to star it :D )

https://redd.it/1jc3ys9
@r_php
Build an open-source project to help new people collaborate on PHP open source

I built this system using 'Good First Issue' as a reference, but instead of showing repositories, I prefer to show issues directly, focusing on the PHP language. What do you think about it? I'm new to the open-source world, and this is my first contribution.

Github repository : https://github.com/Danielopes7/php-contributing

Link: https://phpcontributing.com/

https://redd.it/1jcaplx
@r_php
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