PHP Reddit – Telegram
PHP Reddit
34 subscribers
292 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
Pre-RFC Associated Types

Posting this on Reddit, because why not.

A few weeks ago, motivated by the RFC about allowing never as a parameter type, I started writing a proof of concept for "Associated Types" which are "generics"/"template" types limited to interfaces as they do not have a lot of the complexity relating to generic types on concrete classes, as the bound type can be determined at compile time rather than run-time.

Internals email post is: https://externals.io/message/127165

PoC on GitHub is: https://github.com/php/php-src/pull/18260

https://redd.it/1k571ns
@r_php
Large/enterprise inertia examples

Looking for some large-enterprise level inertia projects as I’m interested in seeing what different design patterns others are using in their projects. I lead a very small development team so don’t get a lot of exposure to well written large scale Laravel code.

I’m assuming most of the good stuff will be private, so if anyone is open, I’d be happy to pay consulting cost/sign whatever to run me through it.

Otherwise if anyone knows any good public gh repos?


https://redd.it/1k5u80p
@r_php
I've never extended a class or used the protected function.

Hi all,

Edit: I program in OOP. At least I think I do? Every new tool has a class, view and controller. I include classes I reuse over and over again such as database class.

I've been trying to diversify my knowledge and fill in gaps as I've been at my current company 5 years and have self taught a lot of the knowledge I have regarding PHP and full stack dev work. I've never really found a use case for extending classes or sub classes but I generally follow an MVC structure.

Could someone link me a case study for using these techniques as when I look it up and see the explanation I still struggle to apply it to my daily work. I also have an innate feeling that being self taught I'm lacking a lot of knowledge that might come in useful later down the line.

Or perhaps something thats like a codex of whats industry standard coding in php backend these days?

https://redd.it/1k61910
@r_php
Livewire Starter Kit

I know this sounds petty but it’s kinda sucks that if you want the rest of the UI elements, you need to pay for it. I know folks worked hard on it but at this point, I thought Laravel would bring out their own at least.

Anyone sign up for Flux UI? I think I might bite the bullet.



https://redd.it/1k6ixrg
@r_php
What does "Core PHP" means ?

I got call for the job opening of PHP Developer. HR manager asked my if know core php. I don't what that's mean. Please elaborate from a development perspective.

https://redd.it/1k6pc9k
@r_php
I am a PHP developer, not a Vue Developer

Sick of seeing jobs for “PHP Laravel Developer” then in the requirements they also want Vue and Inertia experience.

I purposely don’t do frontend, I work really hard and keep up to the date with the latest in the PHP world.

Some jobs even want Kubernetes / Terraform in top of PHP and Vue. So you want me to manage the servers and infrastructure, write the code, maintain the database and also build the frontend?

From experience people who try to do everything in a role aren’t the best developers.

I made my developers choose between frontend and backend and sent them on their way to be the best they could in that area. It made a huge different to quality and output.

In my opinion trying to build teams with full stacks in every area of the codebase is a recipe for disaster.


https://redd.it/1k6rcgt
@r_php
Monitor Slow Queries using Laravel Build in Features

Did you know that you can monitor slow queries without using any packages or tools?

//AppServiceProvider

public function boot(): void
{
$maxTimeLimit = 500;
// in milliseconds


if (!$this->app->isProduction()) {
DB::
listen
(static function (QueryExecuted $event) use ($maxTimeLimit): void {
if ($event->time > $maxTimeLimit) {
throw new QueryException(
$event->connectionName,
$event->sql,
$event->bindings,
new Exception(message: "Individual database query exceeded {$maxTimeLimit}ms.")
);
}
});
}
}

With this method, you don’t need to look away. An exception is thrown every time a request exceeds the threshold. You can make it to log queries instead of throwing an exception which is useful in production.

public function boot(): void
{
$maxTimeLimit = 500;
// in milliseconds


if ($this->app->isProduction()) {
DB::
listen
(static function (QueryExecuted $event) use ($maxTimeLimit): void {
if ($event->time > $maxTimeLimit) {
Log::warning(
'Query exceeded time limit',

'sql' => $event->sql,
'bindings' => $event->bindings,
'time' => $event->time,
'connection' => $event->connectionName,

);
}
});
}
}

https://redd.it/1k6tewm
@r_php
Show & Tell Relaticle - An Open Source Laravel-based CRM I've Been Building (+ Questions About Plugin Licensing)

# Hey r/laravel!

I've been working on Relaticle, an open-source CRM built entirely with Laravel 12 and Filament 3. After months of development, I'm excited to share it with the community that has taught me so much over the years.

# What is Relaticle?

Relaticle is a comprehensive CRM platform focusing on simplicity and customization. Built for teams managing client relationships, sales pipelines, and collaboration workflows, it includes:

People/company management with custom fields
Kanban-style sales pipeline for opportunities
Task management with assignments and due dates
Team workspace organization

# Technical Stack

Laravel 12
PHP 8.3 (with strict typing throughout)
Filament 3 for the admin panel and UI components
Livewire 3 for reactivity
Alpine.js for frontend interactions
PostgreSQL (though configurable)
Comprehensive test suite with Pest
Architecture that enforces single responsibility, readonly classes, and clear abstractions

I've focused heavily on developer experience, with comprehensive documentation, thorough type hints, and consistent patterns.

# The Custom Fields Challenge

Here's where I'd love the community's input. The core of Relaticle's flexibility comes from a Custom Fields package I developed. It's robust enough to be used independently, allowing any model to have completely customizable fields and sections (similar to how Notion allows custom properties).

Initially, I planned to sell this package separately (it's listed in composer.json as a premium component from a private Composer repository). However, I'm questioning this approach since:

1. It feels against the spirit of open source to have a core functionality behind a paywall
2. Yet it represents hundreds of hours of development and testing

My question: What do you think is the right approach here? Some options I'm considering:

Open source it entirely
Dual license (OSS for Relaticle, commercial license for standalone use)
Keep it as a premium component with a free tier
Provide it fully free but offer paid support/implementation

# Why I Built This

I was dissatisfied with existing CRMs - either too complex, too expensive, or not customizable enough. Laravel and Filament make it possible to build something that's both powerful and elegant.

The repo is available at https://github.com/Relaticle/relaticle . I'd love your thoughts on the approach, code quality, and especially the Custom Fields licensing question.

Thanks for being such a supportive community!

https://redd.it/1k6x0t2
@r_php
Why is latestOfMany() orders of magnitude slower than using a manual subquery?

For context, a hasOne(ModelName::class)->latestOfMany() relationship creates a complex aggregate WHERE EXISTS() subquery with another nested (grouped) subquery, and in some cases it can be extremely slow, even if you've added every conceivable index to the table.

In some cases it performs a full table scan (millions of rows) even though the "outer/parent" query is constrained to only a few rows.

With this manual "hack", calling count() on this relationship went from 10 seconds to 7 milliseconds

return $this->hasOne(ModelName::class)->where('id', function ($query) {
$query->selectRaw('MAX(sub.id)')
->from('tablename AS sub')
->whereColumn('sub.lead
id', 'tablename.leadid');
});

Which is nice I guess, but it annoys me that I don't understand why. Can any of you explain it?


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