PHP Reddit
34 subscribers
297 photos
39 videos
25K links
Channel to sync with /r/PHP /r/Laravel /r/Symfony. Powered by awesome @r_channels and @reddit2telegram
Download Telegram
Moving from Laravel to Symfony after several years — how hard is it really?

Hi everyone,

I’ve been working almost exclusively with Laravel for several years. Recently I received a really good job offer, but the stack there is based on Symfony.

Over time I’ve moved away from relying heavily on Laravel’s “magic”. In most of my projects I use my own abstraction layers and architecture, and Laravel is mostly used as a boilerplate with routing, Eloquent ORM, and some framework utilities.

Because of that, I’m hoping the transition might not be too painful, but I’m still a bit unsure.

Has anyone here gone through a similar transition from Laravel to Symfony? How difficult was it in practice?

I’d also appreciate any advice on:

* What concepts in Symfony I should focus on first
* What parts usually feel the most unfamiliar for Laravel developers
* Anything that tends to be unexpectedly difficult during the switch

Thanks!

https://redd.it/1rrnqx0
@r_php
99.9% type coverage, PHPStan strict, zero N+1 — building a production CRM in PHP 8.4

Hey r/php, I just shipped v3.0 of an open-source CRM I've been building (Relaticle). Wanted to share some PHP-specific engineering decisions, since this community appreciates that kind of thing.

PHP 8.4 strict mode in production: Every class is final. Every file uses strict_types. Typed properties and return types everywhere:

declare(stricttypes=1);
final class People extends Model implements HasCustomFields
{
/** @use HasFactory<PeopleFactory> */
use HasFactory;
use HasUlids;
use SoftDeletes;
use UsesCustomFields;

/** @var list<string> */
protected $fillable = ['name', 'creation
source'];

/ @return BelongsTo<Company, $this> /
public function company(): BelongsTo
{
return $this->belongsTo(Company::class);
}
}

Spatie's laravel-data for typed DTOs:

final class SubscriberData extends Data
{
public function __construct(
public string $email,
public ?string $first_name = '',
public ?string $last_name = '',

# PHP 8.4 with strict_types everywhere is genuinely a joy to write. The language has come so far.

99.9% type coverage: I run PHPStan at level 7 (via Larastan). Every method signature is typed. Every return type is explicit. CI fails on any violation — no exceptions, no baselines.

/
@param Collection<int, Contact> $contacts /
public function processImport(Collection $contacts): ImportResult
{
}

# Is it overkill? Maybe. But in a CRM where data integrity matters (contacts, deals, money), catching type mismatches at static analysis time is cheaper than catching them in production.

N+1 query prevention: One line in AppServiceProvider:

Model::preventLazyLoading(!app()->isProduction());

# Strict lazy loading enabled globally. Forget an eager load? Exception in development. This alone caught 10-20 performance issues before they shipped.

PostgreSQL over MySQL: Migrated from MySQL to PostgreSQL 17+ in v3.0. Key reason: JSONB. I built no-code custom fields — users create fields without touching code. All stored as JSONB with GIN indexes:

-- PostgreSQL JSONB with proper indexing
CREATE INDEX idxcustomfields ON contacts USING GIN (customfields);
-- Partial path queries that MySQL JSON can't do efficiently
SELECT * FROM contacts WHERE custom
fields->>'industry' = 'SaaS';

# MySQL's JSON type can't do proper indexing or partial path queries at this level. For a CRM with dynamic schemas, PostgreSQL is the better fit.

Testing with Pest: Comprehensive test suite — unit, feature, and browser tests. Pest's syntax makes test writing feel less like a chore:

arch('strict types')
->expect('App')
->toUseStrictTypes();

arch('avoid open for extension')
->expect('App')
->classes()
->toBeFinal();
});

# Architecture tests prevent structural issues at CI time. If someone accidentally breaks a convention, CI catches it.

Import wizard (the hardest problem): Real-world CSVs are chaos:

Automatic date format detection (uses Laravel's date validator under the hood)
Fuzzy + exact column matching
Relationship mapping (person → company linkage)
Chunked processing for large files
Granular error reporting (which rows failed, why) If anyone's solving CSV import in PHP, happy to discuss approaches.

Stack:

PHP 8.4 + Laravel 12
PostgreSQL 17+ + Redis
Filament 5 + Livewire 4
Docker + docker-compose Links:
GitHub: https://github.com/Relaticle/relaticle (1.2K stars)
Free hosted: [https://relaticle.com](https://relaticle.com) (no credit card)
License: AGPL-3.0. For internal use — no restrictions.



What PHP 8.4 features have you found most useful in production? Curious what patterns this community is adopting

https://redd.it/1rru8yy
@r_php
Appel à settings/password depuis mon front SPA Nuxt

Hello,

mon front SPA Nuxt fait un appel PUT à l'endpoint de Laravel Fortify /settings/password lorsque le user connecté veut modifier son mot de passe depuis son dashboard. Le mot de passe est bien enregistré mais la réponse est une redirection alors que je veux que ce soit une réponse JSON avec un message de succès ou d'erreur.
Comment faire ?
Merci

Voici mes bouts de code:

Fonction appelée par le formulaire:

const resetPassword = async () => {
loading.value = true

try {
const data = await api('/settings/password', {
method: 'PUT',
body: {
currentpassword: currentPassword.value,
password: password.value,
password
confirmation: passwordConfirmation.value,
}
})
status.value = 'success'
message.value = 'Mot de passe modifié avec succès'
currentPassword.value = ''
password.value = ''
passwordConfirmation.value = ''
} catch (err: any) {
console.log(err);
status.value = 'error'
message.value = err.data?.message || 'Une erreur est survenue'
} finally {
loading.value = false
}
}

Le composable useApiFetch:

export function useApiRequest() {
const config =
useRuntimeConfig
()
const xsrfToken =
useCookie
('XSRF-TOKEN')

return
$fetch
.create({
baseURL: config.public.apiBase,
credentials: 'include',
headers: {
'Accept': 'application/json',
'X-XSRF-TOKEN': xsrfToken.value || '',
},
})
}

La Response de l'appel à l'endpoint contient un Header Location qui entraîne la tentative de redirection.




https://redd.it/1rrxwgz
@r_php
Livestream: Road to Laracon with Aaron Francis and Zuzana Kunckova

I often see people asking about getting started with conference speaking and eventually speaking at larger conferences like a Laracon, so I figured it was time to actually dig into it.

Tomorrow (3/12) at 12pm EDT (4pm UTC), I'm going live with Aaron Francis and Zuzana Kunckova to talk about the road to conference speaking. We'll be covering where talk ideas come from, CFP submissions, what goes into preparing a talk, and working your way up from meetups to a Laracon. Aaron and Zuzana will also be sharing their own paths to the Laracon stage.

Would love to see you there! Drop any questions here ahead of time or ask in chat during the stream.

Stream link: https://www.youtube.com/watch?v=FuQjSPBIHlo

https://redd.it/1rr61vr
@r_php
AuditTrailBundle: symfony profiler support

AuditTrailBundle now includes a Symfony Web Profiler integration, allowing developers to inspect audit logs recorded during a request directly from the debug toolbar and profiler panel.

The integration is fully optional — the collector is only registered when WebProfilerBundle is present, so there is zero overhead for applications that don't use it.

Looking for early community feedback: is this a useful addition, or does the Doctrine profiler panel already cover your needs? Would love to hear from anyone who has worked with audit logging in Symfony before shipping this.

https://preview.redd.it/sxtoxhwxb1qg1.png?width=1221&format=png&auto=webp&s=f6892f51bfecd5d9a7d1a58ad8824aca7e81f2bc



https://redd.it/1ry6lgw
@r_php
Laravel Nestedset: Effective tree structures for SQL databases

Version 7.1 of the aimeos/laravel-nestedset package for managing trees using nested sets is now available. It's an improved version of the popular kalnoy/nestedset package which, unfortunately, has been virtually abandoned by its owner.

Repo: [https://github.com/aimeos/laravel-nestedset](https://github.com/aimeos/laravel-nestedset)

The 7.1 release contains:

Support for Laravel 13
Implemented siblings relation
Delete descendants correctly
Fixed infinite recursion with serialization
Tests for all supported databases

To dig deeper into the package, please check:

https://laravel-nestedset.org

If you like our package, leave a star :-)

https://redd.it/1ryubp5
@r_php
Who's hiring/looking

This is a bi-monthly thread aimed to connect PHP companies and developers who are hiring or looking for a job.

Rules

No recruiters
Don't share any personal info like email addresses or phone numbers in this thread. Contact each other via DM to get in touch
If you're hiring: don't just link to an external website, take the time to describe what you're looking for in the thread.
If you're looking: feel free to share your portfolio, GitHub, … as well. Keep into account the personal information rule, so don't just share your CV and be done with it.

https://redd.it/1rxvavn
@r_php
What would you do if you had to quickly review the basics of Symfony?

I have an interview coming up, which will likely include a bunch of questions and coding in the context the Symfony framework.

I've been working with a piece of software written on top of Symfony for the past two years so I'm not starting from zero by any means. However, there are definitely subsets of Symfony that I've been exposed to more than others.

Ideally, I would want to have a good coverage of all underlying concepts that are actually relevant and being actively used in development, without having to read through the entire docs.

How would you approach a situation like this? Are there any good up-to-date study plans that cover all relevant aspects in a sufficient depth.

It's worth noting that I'm more or less fluent in php itself.

Any help is greatly appreciated.

Kind regards



https://redd.it/1rycbp5
@r_php
Wondering if an AI agent such as Claude can help me update an older website

I'm helping a small company that has a heavily customized Opencart 2.0 site that won't run on anything beyond php 5.6.

I looked at the code thinking that maybe I could just upgrade it but it would be a monumental task given the extent of customizations.

I've always hand-coded everything I've built and never used an AI agent to help me with programming tasks. I was an old-school StackOverflow kind of person.

This is way too much for me, however.

Any thoughts on using an AI agent such as Claude (or others) to run through the code and make it compatible to run on php8+?

I appreciate any advice. Thanks in advance.

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