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/1pycb04
@r_php
Feel free to ask any questions you think may not warrant a post. Asking for help here is also fine.
https://redd.it/1pycb04
@r_php
Reddit
From the symfony community on Reddit
Explore this post and more from the symfony community
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/1pyfh2q
@r_php
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/1pyfh2q
@r_php
Reddit
From the PHP community on Reddit
Explore this post and more from the PHP community
Weird text "8194460" appearing on many laravel websites
Crossposting is not allowed, but I wanted to share this post by Maskedman1022000.
Basically, multiple websites have the number 8194460 appearing. When googling I was able to find a few pages that appear to have the number indexed by Google, but all of them just redirected to a login form.
Even https://filamentapps.com/ has it at the top of the website right now.
u/Maskedman1022000 experienced it on his site, but haven't been able to reproduce it in his dev environment.
This is a reminder to check if your pages contain the same bug, and to hear if anyone has more information on the issue.
https://redd.it/1pyhkqa
@r_php
Crossposting is not allowed, but I wanted to share this post by Maskedman1022000.
Basically, multiple websites have the number 8194460 appearing. When googling I was able to find a few pages that appear to have the number indexed by Google, but all of them just redirected to a login form.
Even https://filamentapps.com/ has it at the top of the website right now.
u/Maskedman1022000 experienced it on his site, but haven't been able to reproduce it in his dev environment.
This is a reminder to check if your pages contain the same bug, and to hear if anyone has more information on the issue.
https://redd.it/1pyhkqa
@r_php
Reddit
From the webdev community on Reddit: Weird text "8194460" appearing on many laravel websites
Explore this post and more from the webdev community
Should it still use global, static and associative array?
dumb question should i still use global, static and associateive array?
https://redd.it/1pykn6w
@r_php
dumb question should i still use global, static and associateive array?
https://redd.it/1pykn6w
@r_php
Reddit
From the PHP community on Reddit
Explore this post and more from the PHP community
Do you prefer
Hey folks,
Kind of a dumb question, but it’s been bugging me more than it should 😅
Do you prefer having
I know it doesn’t really matter functionally, but seeing
So what I did was this:
I have an
- index.php
- style.css
Instead of
I mainly did this to hide the
GitHub repo: https://github.com/SurajRaika/artifact/
Live site: https://artifact.wuaze.com
Feel free to roast it
---
Another question while I’m here (would really love some advice):
When working with Core PHP, how do you usually structure your project?
What I’m currently trying is:
- Making small “components”
- Each component lives in a single folder
- That folder contains PHP, CSS, and JS related to that component
Something like:
component/
index.php
style.css
noscript.js
What are the pros and cons of doing it this way?
Is this a bad idea long-term?
Is there a better or more common approach when not using a framework?
I’m mostly experimenting and learning, but I feel like I might be reinventing some bad patterns
---
Also,:
I’m kind of looking for a PHP job, so I built this project as practice and something to show.
If anyone has advice, feedback, or even a referral (though I doubt it 🥲), I’d really appreciate it.
Thanks, and sorry if these are beginner-ish questions.
Just asking because most of you probably have way more experience than I do.
https://redd.it/1pyk3xi
@r_php
.php in URLs or hiding it? Also… am I structuring Core PHP wrong?Hey folks,
Kind of a dumb question, but it’s been bugging me more than it should 😅
Do you prefer having
.php in your app URLs, or keeping them clean without it?I know it doesn’t really matter functionally, but seeing
.php in URLs just bothers me for some reason.So what I did was this:
I have an
/authenticate route that contains:- index.php
- style.css
Instead of
/authenticate/index.php, when a user visits /authenticate/, they see the page directly. I mainly did this to hide the
.php part. I know this can also be handled properly using .htaccess (Apache) or Nginx rewrite rules, but this felt like a simple and clean solution to me.GitHub repo: https://github.com/SurajRaika/artifact/
Live site: https://artifact.wuaze.com
Feel free to roast it
---
Another question while I’m here (would really love some advice):
When working with Core PHP, how do you usually structure your project?
What I’m currently trying is:
- Making small “components”
- Each component lives in a single folder
- That folder contains PHP, CSS, and JS related to that component
Something like:
component/
index.php
style.css
noscript.js
What are the pros and cons of doing it this way?
Is this a bad idea long-term?
Is there a better or more common approach when not using a framework?
I’m mostly experimenting and learning, but I feel like I might be reinventing some bad patterns
---
Also,:
I’m kind of looking for a PHP job, so I built this project as practice and something to show.
If anyone has advice, feedback, or even a referral (though I doubt it 🥲), I’d really appreciate it.
Thanks, and sorry if these are beginner-ish questions.
Just asking because most of you probably have way more experience than I do.
https://redd.it/1pyk3xi
@r_php
GitHub
GitHub - SurajRaika/artifact
Contribute to SurajRaika/artifact development by creating an account on GitHub.
I modernized a decade-old PHP noscript for importing large MySQL dumps - now it's a full MVC app with 10-50x faster imports
Hello,
I've been working on BigDump, a staggered MySQL dump importer. The original noscript was created by Alexey Ozerov back in 2013, and I've completely refactored it into a modern PHP 8.1+ application.
The problem it solves:
phpMyAdmin times out on files >50MB on shared hosting. BigDump breaks imports into sessions that complete within your server's execution limit.
What's new in v2+:
- Full MVC architecture with PSR-12 compliance
- INSERT batching that groups simple INSERTs into multi-value queries (10-50x speedup)
- Auto-tuning based on available PHP memory
- SSE (Server-Sent Events) for real-time progress streaming
- Session persistence - resume after browser refresh or server restart
- Support for .sql, .gz, and .csv files
Technical highlights:
- Strict type declarations throughout
- Dependency injection via constructors
- Optimized SQL parsing using strpos() jumps instead of char-by-char iteration
- 64KB read buffer for reduced I/O overhead
GitHub: https://github.com/w3spi5/bigdump
It's MIT licensed. I'd love feedback on the architecture, and contributions are welcome. The roadmap includes parallel import streams and a REST API.
Has anyone else dealt with importing multi-GB dumps on constrained hosting? What solutions have you used?
https://redd.it/1pymls1
@r_php
Hello,
I've been working on BigDump, a staggered MySQL dump importer. The original noscript was created by Alexey Ozerov back in 2013, and I've completely refactored it into a modern PHP 8.1+ application.
The problem it solves:
phpMyAdmin times out on files >50MB on shared hosting. BigDump breaks imports into sessions that complete within your server's execution limit.
What's new in v2+:
- Full MVC architecture with PSR-12 compliance
- INSERT batching that groups simple INSERTs into multi-value queries (10-50x speedup)
- Auto-tuning based on available PHP memory
- SSE (Server-Sent Events) for real-time progress streaming
- Session persistence - resume after browser refresh or server restart
- Support for .sql, .gz, and .csv files
Technical highlights:
- Strict type declarations throughout
- Dependency injection via constructors
- Optimized SQL parsing using strpos() jumps instead of char-by-char iteration
- 64KB read buffer for reduced I/O overhead
GitHub: https://github.com/w3spi5/bigdump
It's MIT licensed. I'd love feedback on the architecture, and contributions are welcome. The roadmap includes parallel import streams and a REST API.
Has anyone else dealt with importing multi-GB dumps on constrained hosting? What solutions have you used?
https://redd.it/1pymls1
@r_php
GitHub
GitHub - w3spi5/bigdump: An evolution of PHP noscript written by Alexey Ozerov in 2013
An evolution of PHP noscript written by Alexey Ozerov in 2013 - w3spi5/bigdump
The latest version of AuditTrailBundle
The latest version of AuditTrailBundle introduces a complete and production-ready auditing solution for Symfony applications.
you get:
Reliable core auditing for entity create, update, delete, and soft-delete operations
Attribute-based and YAML-based configuration options
Support for multiple audit transports, including chained transports
Transaction-level grouping of audit records for better traceability
Seamless EasyAdmin integration for audit inspection
A structured Audit Reader API for querying and filtering audit logs
A clear audit diff viewer showing old and new values
Safe and explicit revert capability based on audit history
Built-in support for Gedmo SoftDeleteable entities
Configurable retention policies for long-term audit data management
For detailed documentation and configuration examples, please refer to the README.
https://redd.it/1pym147
@r_php
The latest version of AuditTrailBundle introduces a complete and production-ready auditing solution for Symfony applications.
you get:
Reliable core auditing for entity create, update, delete, and soft-delete operations
Attribute-based and YAML-based configuration options
Support for multiple audit transports, including chained transports
Transaction-level grouping of audit records for better traceability
Seamless EasyAdmin integration for audit inspection
A structured Audit Reader API for querying and filtering audit logs
A clear audit diff viewer showing old and new values
Safe and explicit revert capability based on audit history
Built-in support for Gedmo SoftDeleteable entities
Configurable retention policies for long-term audit data management
For detailed documentation and configuration examples, please refer to the README.
https://redd.it/1pym147
@r_php
GitHub
AuditTrailBundle/README.md at main · rcsofttech85/AuditTrailBundle
A lightweight Symfony bundle that automatically tracks and stores Doctrine ORM entity changes for audit logging and compliance. - rcsofttech85/AuditTrailBundle
Content management for laravel apps
Hi all! I have several laravel apps out there but the problem with the clients remains the same. They need a way to manage the marketing end of their app. Basically they need an advanced ‘editor’ like wordpress’ elementor but in the laravel ecosystem.
So far I’ve tried grapejs, ckeditor, filament’s v4 editor and even markdown editor. The clients seem to like tinymce which is what i have as default right now. I hate how tinymce works but it seems its the most feature rich editor (according to the clients at least). I have several opinionated clients that moonlight as designers.
So how do you guys handle such cases?
https://redd.it/1pypy6t
@r_php
Hi all! I have several laravel apps out there but the problem with the clients remains the same. They need a way to manage the marketing end of their app. Basically they need an advanced ‘editor’ like wordpress’ elementor but in the laravel ecosystem.
So far I’ve tried grapejs, ckeditor, filament’s v4 editor and even markdown editor. The clients seem to like tinymce which is what i have as default right now. I hate how tinymce works but it seems its the most feature rich editor (according to the clients at least). I have several opinionated clients that moonlight as designers.
So how do you guys handle such cases?
https://redd.it/1pypy6t
@r_php
Reddit
From the laravel community on Reddit
Explore this post and more from the laravel community
Job Middleware Patterns: Database transactions, distributed locking, and domain-specific logic
https://queuewatch.io/blog/job-middleware-patterns-database-transactions-distributed-locking-and-domain-specific-logic
https://redd.it/1pyperr
@r_php
https://queuewatch.io/blog/job-middleware-patterns-database-transactions-distributed-locking-and-domain-specific-logic
https://redd.it/1pyperr
@r_php
Queuewatch
Job Middleware Patterns: Database transactions, distributed locking, and domain-specific logic - Queuewatch
Laravel's job middleware system is one of the framework's most powerful yet underutilized features. While most developers know about RateLimited and WithoutOverlapping, the middleware pipeline enables sophisticated patterns that transform how jobs interact…
I recently launched 2 laravel package , how should i promote it
I recently created and launched 2 laravel package, 1 a laravel installer package and another one is laravel health package. but both having less than 30 stars in github and less installs.
i created the packages , uploaded to github and packagist and waiting for people to use it. but whats the best way to let the developers know about the packages ?
please share your suggestions
https://redd.it/1pytiuy
@r_php
I recently created and launched 2 laravel package, 1 a laravel installer package and another one is laravel health package. but both having less than 30 stars in github and less installs.
i created the packages , uploaded to github and packagist and waiting for people to use it. but whats the best way to let the developers know about the packages ?
please share your suggestions
https://redd.it/1pytiuy
@r_php
Reddit
From the laravel community on Reddit
Explore this post and more from the laravel community
i refactored 2,400 lines of 2015 php spaghetti and the client’s app went from 8s load times to 1.2s
I took on a client project last month. saas app built in 2015, never touched since. php 7.2, laravel 5.something, zero tests, one 800-line controller, and page load times that made users think their wifi died.
client's exact words: "we're scared to change anything because we don't know what breaks."
so i treated the refactor like defusing a bomb: slow, methodical, with safety checks at every step.
the nightmare i inherited
here's what i was dealing with:
* one `OrderController.php` with 847 lines handling checkout, invoices, emails, pdf generation, and webhook callbacks in the same file
* n+1 queries everywhere (one page was hitting the db 340+ times)
* no service classes, no jobs, everything crammed into controllers
* blade templates with raw sql and business logic mixed in
* zero automated tests
* comments like `// TODO: fix this later (2016)`
load times averaged 6–8 seconds for the dashboard. client was losing signups because the checkout page took 12 seconds to render.
step 1: break it into phases instead of yolo refactoring
first mistake most devs make: trying to refactor everything at once.
i dumped the entire checkout flow into traycer and asked it to reverse-engineer what the code actually does and break it into phases. while i was using cursor to scaffold and refactor, i also had coderabbit reviewing the changes in real time so it could flag risky edits and edge cases as the code was being rewritten.
traycer gave me:
* phase 1: extract payment logic into service class
* phase 2: move email/pdf generation into queued jobs
* phase 3: fix n+1 queries with eager loading
* phase 4: split 800-line controller into smaller ones
* phase 5: clean up blade templates (remove business logic)
each phase was small enough that if i broke something, i'd know exactly where.
step 2: the before/after safety trick
here's what saved me from breaking everything:
before touching code in a phase:
* ran a local review on the old code, asked it: "what does this code do, what edge cases does it handle, what breaks if X happens"
* saved the response as `phase1-before.txt`
after refactoring:
* ran the same review on the new code
* saved as `phase1-after.txt`
* compared them
if the behavior denoscriptions didn't match = i broke something.
if they matched = safe to move on.
caught 3 bugs this way that i would've missed otherwise:
* weird timezone handling for EU orders
* silent error swallow that was actually preventing duplicate charges
* race condition with concurrent webhook callbacks
step 3: cursor doing the actual heavy lifting
for each phase, i fed cursor the spec from traycer and let it scaffold the new structure.
phase 1 example:
* cursor created the `PaymentService` class
* moved all stripe/payment logic from controller into service
* updated controller to use the service
* fixed all the imports automatically
did this in composer mode so it could edit multiple files at once. saved me hours of copy-paste-fix-imports hell.
then i'd run the before/after check, fix anything that diverged, write a few quick tests, and move to next phase.
step 4: fixing the performance disasters
once behavior was safe, i did a performance-focused review pass on each phase:
prompt i used:
>"scan for n+1 queries, missing indexes, heavy loops, and unnecessary db calls. show me file:line and a one-liner fix."
fed that back into cursor and let it optimize.
biggest win: the order listing page went from 340 db queries to 8 with proper eager loading. that alone dropped load time from 8s to 2s.
the results after 6 days
before:
* 2,400 lines across 4 files
* 6–8s average dashboard load
* 12s checkout page render
* zero tests
* client losing conversions because of speed
after:
* 1,850 lines across 14 cleaner files
* 1.2s dashboard load (83% faster)
* 2.8s checkout render (77% faster)
* 40+ tests covering critical paths
* client's conversion rate up 34% week one (pricing page was loading so slow)
https://redd.it/1pyvsls
@r_php
I took on a client project last month. saas app built in 2015, never touched since. php 7.2, laravel 5.something, zero tests, one 800-line controller, and page load times that made users think their wifi died.
client's exact words: "we're scared to change anything because we don't know what breaks."
so i treated the refactor like defusing a bomb: slow, methodical, with safety checks at every step.
the nightmare i inherited
here's what i was dealing with:
* one `OrderController.php` with 847 lines handling checkout, invoices, emails, pdf generation, and webhook callbacks in the same file
* n+1 queries everywhere (one page was hitting the db 340+ times)
* no service classes, no jobs, everything crammed into controllers
* blade templates with raw sql and business logic mixed in
* zero automated tests
* comments like `// TODO: fix this later (2016)`
load times averaged 6–8 seconds for the dashboard. client was losing signups because the checkout page took 12 seconds to render.
step 1: break it into phases instead of yolo refactoring
first mistake most devs make: trying to refactor everything at once.
i dumped the entire checkout flow into traycer and asked it to reverse-engineer what the code actually does and break it into phases. while i was using cursor to scaffold and refactor, i also had coderabbit reviewing the changes in real time so it could flag risky edits and edge cases as the code was being rewritten.
traycer gave me:
* phase 1: extract payment logic into service class
* phase 2: move email/pdf generation into queued jobs
* phase 3: fix n+1 queries with eager loading
* phase 4: split 800-line controller into smaller ones
* phase 5: clean up blade templates (remove business logic)
each phase was small enough that if i broke something, i'd know exactly where.
step 2: the before/after safety trick
here's what saved me from breaking everything:
before touching code in a phase:
* ran a local review on the old code, asked it: "what does this code do, what edge cases does it handle, what breaks if X happens"
* saved the response as `phase1-before.txt`
after refactoring:
* ran the same review on the new code
* saved as `phase1-after.txt`
* compared them
if the behavior denoscriptions didn't match = i broke something.
if they matched = safe to move on.
caught 3 bugs this way that i would've missed otherwise:
* weird timezone handling for EU orders
* silent error swallow that was actually preventing duplicate charges
* race condition with concurrent webhook callbacks
step 3: cursor doing the actual heavy lifting
for each phase, i fed cursor the spec from traycer and let it scaffold the new structure.
phase 1 example:
* cursor created the `PaymentService` class
* moved all stripe/payment logic from controller into service
* updated controller to use the service
* fixed all the imports automatically
did this in composer mode so it could edit multiple files at once. saved me hours of copy-paste-fix-imports hell.
then i'd run the before/after check, fix anything that diverged, write a few quick tests, and move to next phase.
step 4: fixing the performance disasters
once behavior was safe, i did a performance-focused review pass on each phase:
prompt i used:
>"scan for n+1 queries, missing indexes, heavy loops, and unnecessary db calls. show me file:line and a one-liner fix."
fed that back into cursor and let it optimize.
biggest win: the order listing page went from 340 db queries to 8 with proper eager loading. that alone dropped load time from 8s to 2s.
the results after 6 days
before:
* 2,400 lines across 4 files
* 6–8s average dashboard load
* 12s checkout page render
* zero tests
* client losing conversions because of speed
after:
* 1,850 lines across 14 cleaner files
* 1.2s dashboard load (83% faster)
* 2.8s checkout render (77% faster)
* 40+ tests covering critical paths
* client's conversion rate up 34% week one (pricing page was loading so slow)
https://redd.it/1pyvsls
@r_php
Reddit
From the PHP community on Reddit
Explore this post and more from the PHP community