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
Would you prefer namespace-level privacy?

In some programming languages like Java you get more flexibility in your levels of privacy e.g.- a “protected” method can be accessed by any class in the same “package” (in PHP we use the term “namespace” instead of package but it’s the same idea).

Also a whole class itself in Java can be declared protected or private and this will affect its visibility in useful, subtle ways.

In PHP it’s possible to use attributes combined with static analysis to simulate this but it’s not as desirable as having the features built into the language.
I’m a real stickler for the defensive style of programming so that only certain classes can see/access other classes. Also, it’s good for DDD when one class can see the internal properties of another class in the same namespace (e.g.- for persistence or presentation) without needing lots of “getter” methods.

I’m interested in hearing the thoughts of the wider PHP community on this.

https://redd.it/1k9ccu0
@r_php
Question about TwigMarkup Extra bundle and league/commonmark

I am trying to put together a document from markup using the TwigExtra Markdown package with league/commonmark for the trasnpiler. I have several tables that need to be implemented from the markdown, and I need to tell commonmark to use the TableExtension. However, I cannot find a suitable piece of documentation to even start trying to figure out how to configure this. Anybody have any solutions? Thank you.

https://redd.it/1k9h798
@r_php
Weekly Ask Anything Thread

Feel free to ask any questions you think may not warrant a post. Asking for help here is also fine.

https://redd.it/1k9lvaa
@r_php
Weekly help thread

Hey there!

This subreddit isn't meant for help threads, though there's one exception to the rule: in this thread you can ask anything you want PHP related, someone will probably be able to help you out!

https://redd.it/1k9ojug
@r_php
Interviewing for a PHP & Etc. Developer without knowledge?

To cut the story short, I have a business and recently started looking for new developers for my site. My site is mostly coded in PHP, Laravel MVC, and SQL. I used to have a developer, however we are no longer in good terms anymore.

How would I go about hiring a new developer? I have no idea anything about PHP and everything, and I definitely don’t want to get ripped off by people just claiming to know PHP and such.

Note: Sorry if this is the wrong place to ask for this. Help redirect myself to the right resources. TIA!

https://redd.it/1k9pd6s
@r_php
Distribute tests across multiple GitHub Action workers

In collaboration with u/localheinz I've build a small \#github \#actions utility workflow. It describes how to segment a projects phpunit overall test-suite and distribute the load over parallel running github actions jobs


https://github.com/staabm/phpunit-github-action-matrix

https://redd.it/1k9rdnk
@r_php
Breaking File Layout Conventions—Does It Make Sense?


Hey everyone, I’ve been a hobbyist coder for almost 20 years and I’ve always become stuck trying to appease to everybody else’s standards and opinions.

I'm interested in hearing your thoughts on deviating from conventional file layouts. I’ve been experimenting with my own structure and want to weigh the pros and cons of breaking away from the norm.

Take traits, for example: I know they’re commonly placed in app/Traits, but I prefer separating them into app/Models/Traits and app/Livewire/Traits. It just feels cleaner to me. For instance, I have a Searchable trait that will only ever be used by a Livewire component—never a model. In my setup, it’s housed in app/Livewire/Traits, which helps me immediately identify its purpose.

To me, the logic is solid: Why group unrelated traits together when we can make it clear which context they belong to? But I know opinions might differ, and I’m curious to hear from you all—are unconventional layouts worth it, or do they just create headaches down the line?

Let me know what you think. Are there other ways you've tweaked your file structures that have worked (or backfired)?

https://redd.it/1kai52q
@r_php
HELP ME I am stuck in the email sending system of WooCommerce WordPress

My functions.php:


add_filter('woocommerce_email_classes', 'add_custom_order_status_emails');

function add_custom_order_status_emails($emails) {

$emails['WC_Email_Customer_Doi_Xac_Nhan_Order'] = include get_stylesheet_directory() . '/woocommerce/emails/class-wc-email-customer-doi-xac-nhan-order.php';

$email_admin = include get_stylesheet_directory() . '/woocommerce/emails/class-wc-email-admin-da-cap-nhat.php';

$email_customer = include get_stylesheet_directory() . '/woocommerce/emails/class-wc-email-customer-da-cap-nhat.php';

$emails['WC_Email_Admin_Updated'] = $email_admin;

$emails['WC_Email_Customer_Updated'] = $email_customer;

return $emails;

}

add_action('woocommerce_order_status_changed', 'trigger_custom_order_email', 10, 4);

function trigger_custom_order_email($order_id, $old_status, $new_status, $order) {

if ($new_status === DOI_XAC_NHAN) {

WC()->mailer()->emails['WC_Email_Customer_Doi_Xac_Nhan_Order']->trigger($order_id);

}

if ($new_status === DA_CAP_NHAT) {

$email_admin = WC()->mailer()->emails['WC_Email_Admin_Updated'];

$email_customer = WC()->mailer()->emails['WC_Email_Customer_Updated'];

}

}

theme-child structure
/woocommerce

/emails

- admin-new-order.php

- admin-updated-status.php

- class-wc-email-admin-da-cap-nhat.php

- class-wc-email-customer-da-cap-nhat.php

- class-wc-email-customer-doi-xac-nhan-order.php

- customer-awaiting-confirmation.php

- customer-updated-status.php

/plain


The issue I'm facing is that when I call trigger() to send emails, the second email gets sent but it doesn't have any CSS. I already checked under WooCommerce → Settings → Emails → Template, and my custom email templates all display the correct layout. I've asked ChatGPT and Cursor, but I still haven't been able to fix it.

And when I switched the order of these two lines, the admin email was no longer sent to the admin:
if ($new_status === DA_CAP_NHAT) {

$email_customer = WC()->mailer()->emails['WC_Email_Customer_Updated'];

$email_admin = WC()->mailer()->emails['WC_Email_Admin_Updated'];

}

My code:

file class-wc-email-admin-da-cap-nhat.php
https://textdoc.co/NJPtjVHWwc1RCoyX

file template admin-updated-status.php

https://textdoc.co/WBfPAaELgC9JKGuh

file class-wc-email-customer-da-cap-nhat.php

https://textdoc.co/tEYw4TpK9HSzZ7Gy

file template customer-updated-status.php

https://textdoc.co/KH04c6RbTdB2IMre


Link Image:
email for admin: https://postimg.cc/QH6X4KCN
email for customer: https://postimg.cc/06SPytfr

https://redd.it/1kaj41i
@r_php
This media is not supported in your browser
VIEW IN TELEGRAM
Solved my "one more field" client nightmare in Filament without migrations - looking for feedback

https://redd.it/1kalhrh
@r_php
Why there is programmers hate PHP

Hello developers , I have a question , why there is programmers hate PHP and web development .

https://redd.it/1kasvfn
@r_php
What headaches/limitations have you found with Filament?

I just started learning Filament via Laracasts and wonder how I've lived without it. It's one of the biggest game changers I've found in a long time, if not ever. I'm still working through the video series, and am seeing how I can re-write an existing project using it, and see how powerful it is.

What kinds of limitations and issues have you personally come across?

https://redd.it/1kato5i
@r_php
UX-Autocomplete querybuilder using documentation example not working.

I could use some help checking my understanding of the ux-autocomplete query\
builder documentation, because I don't see how their example of passing extra_options to a query builder will work. I'm using Symfony 7.2 , php 8.4.6, Fedora 42

Following the example here: https://symfony.com/bundles/ux-autocomplete/current/index.html#passing-extra-options-to-the-ajax-powered-autocomplete

I turned my working function:

'querybuilder' => function (EntityRepository $er): QueryBuilder {
return $er->queryActivePeople(null);
},

Into this:





'query
builder' => function (Options $options) {
return function (EntityRepository $er) use ($options) : QueryBuilder {
return $er->queryActivePeople($options'extra_options''extra_people');
};
},
Which results in this error:

Uncaught PHP Exception TypeError: "App\\Form\\PersonAutocompleteField::{closure:App\\Form\\PersonAutocompleteField::configureOptions():28}(): Argument #1 ($options) must be of type App\\Form\\Options, App\\Repository\\PeopleRepository given,

Which is pretty much what I expected from changing the type of the first closure parameter. Can someone point me to what I am missing, or are the docs just wrong ?

https://redd.it/1kawvoi
@r_php
Looking for a Laravel-Based Shopify Alternative with Multi-Tenancy

Hey folks,

I’m currently exploring self-hosted, Laravel-based e-commerce platforms that are close in functionality to Shopify — especially with support for multi-tenancy (i.e., letting users create their own store under subdomains or custom domains).

I’ve already looked into a few:
• Bagisto – Nice UI, built on Laravel + Vue, seems solid but not sure about multi-tenancy support out of the box.
• Aimeos – Very powerful, but feels a bit enterprise-heavy.
• Lunar – Looks promising and modern, but seems a bit early for production with multi-tenant setups.
• Vanilo – Great Laravel-native option, but still seems single-tenant by default.

Ideally, I’m looking for something that’s:
• Laravel-based
• Multi-tenant (users can manage their own storefronts)
• Has Stripe or similar integration
• Actively maintained
• Open-source (or at least self-hostable)

Has anyone built or seen something like this? Would love recommendations or even success/failure stories if you’ve attempted something similar.

Thanks in advance!


https://redd.it/1kazvjy
@r_php
Serversideup container won't start—need help!

I'm trying to run the serversideup/php stack for 8.4.6-fpm-nginx, but when the stack starts up on 'Localhost', I get a 'File not found' error

docker-compose.yml

services:
  php:
image: serversideup/php:8.4.6-fpm-nginx
ports:
- "80:8080"
environment:
- SSL_MODE=off
volumes:
- ./app:/var/www/html

nginx/default.conf

    server {
        listen 80;
        index index.php index.html;
        server_name localhost;
        root /var/www/html;
        error_log /var/log/nginx/error.log;
        access_log /var/log/nginx/access.log;


        # client_max_body_size 100M; # Se quiser enviar arquivos grandes (upload no Laravel)

        location / {
            try_files $uri $uri/ /index.php?$query_string;
        }

        location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass php:9000;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_noscript_name;
            fastcgi_param PATH_INFO $fastcgi_path_info;
        }

        location ~ /\.(?!well-known).* {
            deny all;
            }
    }

Container log

AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36 Edg/135.0.0.0" "-"



[172.18.0.1](http://172.18.0.1) \- - \[29/Apr/2025:21:41:13 +0000\] "GET / HTTP/1.1" 404 47 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36 Edg/135.0.0.0" "-"




https://redd.it/1kazzna
@r_php
Well now what... PHP expert seeing jobs close within 3 hours

Hopefully posting this screenshot of the issue in question is allowed: PHP jobs stop taking applications after a few hours.

https://imgur.com/a/wsmW20j

Anyway, PHP and its surrounding tech has been my expertise for a decade, and my career seems to have gone dead overnight.

I'm trying to figure out how to make money but it all feels like starting over because I don't have an established online presence. I didn't think I'd need one with how many calls and emails I got and how quickly I got jobs over the years, and now I'm getting mostly a trickle of rejections. I guess I got too comfortable, but I have several months to try to figure something out.

I'm seeing all kinds of things about making money with AI or Shopify or YouTube etc, but it's basically all new to me. I'm currently trying to ramp up a website helping small businesses and entrepreneurs with my expertise (also includes project management and work with surrounding business things like SEO and marketing), but the people I'm talking to (including my business partner) are often making effectively random/brash decisions and statements where I'm having to battle through contradictions and miscommunications and hurt feelings blah blah blah where the slightest misstep is a landmine when I didn't even know there was a minefield.

Anyway, any advice would be helpful, probably, I'm sure.

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