PHP Reddit – Telegram
PHP Reddit
34 subscribers
289 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
What are some unusual coding style preferences you have?

For me, it's the ternary operators order.

Most resources online write it like this...

$test > 0 ?
'foo' :
'bar';

...but it always confuses me and I always write it like this:

$test > 0
? 'foo'
: 'bar';

I feel like it is easier to see right away what the possible result is, and it always takes me a bit more time if it is done the way I described it in the first example.

https://redd.it/1m73bzn
@r_php
Built a PHP framework that plays nice with legacy code - hope someone finds it useful

I've been working on a PHP framework called Canvas that I think solves a real problem many of us face: how do you modernize old PHP applications without breaking everything?

The core idea: Instead of forcing you to rewrite your entire codebase, Canvas uses a "fallthrough" system. It tries to match Canvas routes first, and if nothing matches, it automatically finds your existing PHP files, wraps them in proper HTTP responses, and handles legacy patterns like exit() and die() calls gracefully.

## How it works

You create a new bootstrap file (like public/index.php) while keeping your existing structure:

<?php
use Quellabs\Canvas\Kernel;
use Symfony\Component\HttpFoundation\Request;

require_once __DIR__ . '/../vendor/autoload.php';

$kernel = new Kernel([
'legacy_enabled' => true,
'legacy_path' => __DIR__ . '/../'
]);

$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();


Now your existing URLs like /users.php or /admin/dashboard.php continue working exactly as before, but you can start writing new features using modern patterns:

class UserController extends BaseController {
/**
* @Route("/api/users/{id:int}")
*/
public function getUser(int $id) {
return $this->json($this->em->find(User::class, $id));
}
}


## What you get immediately

- ObjectQuel ORM - A readable query syntax inspired by QUEL
- Annotation-based routing
- Dependency injection
- Built-in validation and sanitization
- Visual debug bar with query analysis
- Task scheduling

But here's the key part: you can start using Canvas services in your existing legacy files right away:

// In your existing users.php file
$em = canvas('EntityManager');
$users = $em->executeQuery("
range of u is App\\Entity\\User
retrieve (u) where u.active = true
sort by u.createdAt desc
");


## Why I built this

This framework grew out of real pain points I've experienced over 20+ years. I've been running my own business since the early 2000s, and more recently had an e-commerce job where I was tasked with modernizing a massive legacy spaghetti codebase.

I got tired of seeing "modernization" projects that meant rewriting everything from scratch and inevitably getting abandoned halfway through. The business reality is that most of us are maintaining applications that work and generate revenue - they just need gradual improvement, not a risky complete overhaul that could break everything.

The framework is MIT licensed and available on GitHub: https://github.com/quellabs/canvas. I hope someone else finds this approach useful for their own legacy PHP applications.

https://redd.it/1m75j9a
@r_php
PHP learning material for beginners

Hello, guys, I want to start learning php to be able to build relatively simple web sites with databases, user authentication, cookies etc. I don't strive for becoming php guru, I just want to understand backend basics and server-side processes.

Are there any good beginner-friendly, up-to-date learning material like books or websites with tutorials that cover php, database handling, authentication and other relevant stuff?

I found out about the book "PHP and MySQL web development" by Luke Welling, but the last edition was released in 2016-2017 and I don't know whether it's outdated or not.

Thanks in advance


https://redd.it/1m7czpa
@r_php
Finding Fullstack wannabe community

Now im in the 2nd year of college, lately im on my self-portfolio project. So i wonder if i can find some friends from community where we can share, help, or team up with whom has the same interest to be fullstack dev in future.

https://redd.it/1m7tgkt
@r_php
Why can't we unregister a shutdown function?

When I was developing Sword (merging Symfony and Wordpress), I found that Wordpress and several plugins such as WooCommerce register some shutdown functions, which are conflicting with the Symfony profiler.

I tried to make an extension to add a `unregister_shutdown_function()` function but as I understand it, since PHP 8 it's impossible to access the shutdown functions list, therefore no userland extension can implement this feature.

What are the reasons why it's designed to be register-only and closed API?

https://redd.it/1m7zhi9
@r_php
Is Laravel cloud down for anyone else?

https://status.laravel.com/ isn't showing anything (doesn't even have cloud listed)

But I'm getting an inertia error and can't log in.

Edit, now getting a cloudflare error message showing "Gateway time-out" / cloud.laravel.com Host Error

https://redd.it/1m7zpal
@r_php
Symfony Bundle for Elasticsearch

Hello fellow Symfony devs,

This is my first time posting on this subreddit, hopefully I'm doing this right.

I have just released a Symfony bundle that drastically simplifies working with Elasticsearch :

\- Create indexes with just two PHP classes
\- Auto-generate routes for indexing, updating, deleting, and searching documents
\- Provides a full feature search engine (query searching, filtering, aggregations, sortings)
\- Developer-friendly API with zero Elasticsearch knowledge required
\- Built-in validation, filtering, sorting, and aggregations

You can be up and running in minutes, whether via REST endpoints or using provided PHP clients.

The whole thing is also entirely customizable as it works with interfaces. You can create your own elasticsearch components and behavior if you feel the need to and the system will be able to work with it transparently.

You can find this bundle here https://github.com/AdriBalla/symfony-search-bundle with a pretty detailed readme.

I would love feedback from the Symfony community — and contributions are welcome!

Cheers

https://redd.it/1m81v11
@r_php
Why I Prefer Procedural PHP

There’s a reason I keep reaching for plain, procedural PHP when I build. It’s not about being old-school or resisting frameworks. It’s about clarity, control, and getting the job done without the overhead.

# 🧱 1. I Don’t Need Fancy Terms

In procedural PHP, I don’t have to wrestle with abstract terms like "model," "resource," or "controller."

I write a function: that’s my logic.
I fetch some rows: that’s my data.
I display it in a table: that’s my output.

That’s it. No mental gymnastics. Just code that does what I want.

# 🔍 2. I See Everything That’s Happening

No magic. No hidden behavior. When I write procedural PHP, I know exactly what’s running and in what order. Every query, every echo, every variable — it’s all mine to control.

Frameworks can be helpful, but they often hide a lot. With procedural, I don’t need to trace through middleware or abstract classes just to understand what’s going on.

# 🪶 3. It’s Lightweight and Fast

I can spin up a full feature — like a data table with CRUD — using just a few PHP files and a database connection. No installations, no package managers, no artisan commands. It just works.

For admin panels, dashboards, internal tools, or teaching — procedural PHP gets me there faster.

# 📄 4. The Architecture Still Exists — It’s Just Natural

I may not call them "models" or "resources," but I still use the same ideas:

I separate logic into functions (model behavior)
I write clean HTML output (view)
I structure files by purpose (controller-like)

It’s MVC — just without the ceremony.

# 🧠 5. It Teaches You What’s Actually Happening

When students start with procedural PHP, they learn how things work, not just how to use a framework. They see SQL. They understand what $_POST means. They learn to debug raw errors and fix their own queries.

That’s powerful. And it's real learning.

# 🚀 Final Thought

I don’t need a framework to write good code. I need clear logic, a direct path to the data, and full control of the output. And that’s exactly what procedural PHP gives me.

It’s not outdated. It’s not primitive.

It’s honest, practical, and perfectly suited to many of the things I build.

>



https://redd.it/1m8ubvl
@r_php
The world is going insane!

I feel like the world has become so bat shit crazy, as IRL, i keep running into developers who insist on using node.js over LAMP...

to me this is a sure fire indicator of a failing society; something in the water is making people dumb and illogical.

i've been a programmer for 20+ years now... and IRL i haven't met a single dev who sticks to LAMP over node.js... meanwhile, i've replaced many of their failed node.js apps (including mobile apps) with LAMP, where they can sit for years without breaking or updates. i'm semi-retired on retainer and i don't have time for fixing all of their broken crap all the time!

https://redd.it/1m90zgm
@r_php
Implementing SCIM?

Does anyone have any experience+recommendations for implementing SCIM?

This will be for Entra and possibly Okta.

TIA!

https://redd.it/1m934dy
@r_php
Go-to for testing local Laravel projects on your phone?

I didn't keep track... but I tried a bunch of stuff with no success.

Is there any simple go-to Lavavel setup for this? We want to adjust our style-guide while all looking at our phones live.

https://redd.it/1m9a13w
@r_php
Laracon Denver roll call

Who is bound for Denver in the coming days? I'm about to set off from New Zealand in the next few hours here.

Looking forward to the golf on Monday and then of course seeing old friends and making new ones.

https://redd.it/1m9ey7s
@r_php
Going all-in on modularized, event-driven development?

I’ve been working with Laravel for over 5 years now, mostly solo, so I know my way around Laravel fairly well. The majority of my projects are fairly simple request/response API’s, and I’ve never had much of a problem maintaining or scaling them. I already try to keep code decoupled where possible, and I also try to keep files as small as possible.

However, I’m currently planning on a somewhat larger project. Still solo, but more external services involved, and more internal aspects as well. One thing that kind of bothered me on a recent project, was that all classes were grouped together inside ‘/app’ by type, and not by module. So I watched the Modular Laravel course on Laracasts, and I really like the concept of having the whole code as decoupled as possible using events & listeners, and grouping the classes per module.

I’ve already worked out a proof of concept that integrates Nwidart’s laravel-modules package with Spatie’s laravel-multitenancy package, and to be honest, I think that it absolutely works great. On the other side however, I think that I might be making things too complex for myself. Especially now, at the beginning, it took quiet some time to get everything set up properly, and I’m not sure whether it’ll actually be saving me time and headaches in the future.

Again, on the other hand, the project involves messaging and communication with external services (including AI generated responses), so many processes are async, which of course goes well with an event driven approach.

Any recommendations on what I should watch out for, or any tips that I need to know before really getting started? Or should I just get started quickly using my traditional methods and refactor later if it gets complex or messy?


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