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 your top myths about PHP?

Hey folks!

I’m working on a series of articles about the most common myths surrounding different programming languages.

Would love to hear your favorite myths or misconceptions — drop them below

https://redd.it/1m6c6s7
@r_php
Why don't we break switch cases by default?

Before anything else: This isn't me calling for a revolt, a change, or this being considered a bug or flaw. Neither am I trying to make a case (ha!). I have no issue with how it is, I'm asking out of curiosity. Nothing more :)

I wrote a switch block today. You know, ... switch, case, the action you want to perform, break, ... hm... "break"…? I mean, I know, otherwise it would continue to the next step. I don't think I ever wrote a switch block with breaks exclusively. Not sure if I've ever seen code that was different, though that might just be me not having paid attention or the kind of code I usually deal with. Am I an outlier here, is my perception warped? Why is it this way around, having to explicitly break instead of that being the default?

I may overlook something obvious, something hidden, something historic, ... I can speculate as much as I want, but if somebody actually knows, I'd be interested.

https://redd.it/1m6fnc9
@r_php
PHP the right way, but for testing ?

Hey everyone!
I recently changed companies, and for the first time in my life, I’m seeing what proper, professional use of tests looks like. I’m realizing every day just how weak my understanding of testing has been all along…

I really need to rebuild (or maybe build from scratch) my foundation and then work on advancing my knowledge from there.

Do you know of any great resources that cover the fundamentals of testing, especially in the context of PHP?

P.s. everything

https://redd.it/1m6hhy2
@r_php
Whats the best place to host a simple PHP website?

New to PHP and coming from Ruby on Rails, Python, and Next.js. I've used Vercel before, I've heard of Hertzner, but I'm looking for a free way to deploy a very simple, almost static PHP website and wondering what people use.

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