Code Quality
Hi guys, I hope you are all doing good.
How do you guys ensure code quality on your PHP application?
I am currently leading(a one man team🤣) the backend team for a small startup using PHP and Laravel on the backend.
Currently, we write integration test(with Pest), use PHPstan for static analysis(level 9), Laravel Pint for code style fixing.
I have recently been wondering how else to ensure code quality on the backend.
How else do you guys enforce / ensure code quality on your applications?
Are there specific configurations you use alongside these tools, or are there even some other tools you use that isn't here?
Thanks in advance, guys.
https://redd.it/1mi53j1
@r_php
Hi guys, I hope you are all doing good.
How do you guys ensure code quality on your PHP application?
I am currently leading(a one man team🤣) the backend team for a small startup using PHP and Laravel on the backend.
Currently, we write integration test(with Pest), use PHPstan for static analysis(level 9), Laravel Pint for code style fixing.
I have recently been wondering how else to ensure code quality on the backend.
How else do you guys enforce / ensure code quality on your applications?
Are there specific configurations you use alongside these tools, or are there even some other tools you use that isn't here?
Thanks in advance, guys.
https://redd.it/1mi53j1
@r_php
Reddit
From the PHP community on Reddit
Explore this post and more from the PHP community
Do you update flex recipes when upgrading Symfony version?
I just updated my app from Symfony 7.2 to 7.3. When using the `composer recipes:update` command, i get a big list of recipes to update. However, the process is annoying as i have to do it one by one with a commit after each. How important is this step and how do you do it?
https://redd.it/1mia8eh
@r_php
I just updated my app from Symfony 7.2 to 7.3. When using the `composer recipes:update` command, i get a big list of recipes to update. However, the process is annoying as i have to do it one by one with a commit after each. How important is this step and how do you do it?
https://redd.it/1mia8eh
@r_php
Reddit
From the symfony community on Reddit
Explore this post and more from the symfony community
scout:queue-import: Faster Indexing in Laravel Scout
https://nabilhassen.com/scoutqueue-import-faster-indexing-in-laravel-scout
https://redd.it/1miez6x
@r_php
https://nabilhassen.com/scoutqueue-import-faster-indexing-in-laravel-scout
https://redd.it/1miez6x
@r_php
Nabilhassen
scout:queue-import: Faster Indexing in Laravel Scout
The new scout:queue-import command splits your model’s ID range into chunks and queues jobs for each, enabling faster parallel indexing of large datasets.
Excessive micro-optimization did you know?
Some built-in functions have compiler optimized versions that avoid a lot of the internal overhead of the PHP engine. By importing them in source files (e.g.,
<?php
namespace SomeNamespace;
$now1 = microtime(true);
for ($i = 0; $i < 1000000; $i++) {
$result1 = strrev("Hello, World!");
}
$elapsed1 = microtime(true) - $now1;
echo "Without import: " . round($elapsed1, 6) . " seconds\n";
$now2 = microtime(true);
for ($i = 0; $i < 1000000; $i++) {
$result2 = \strrev("Hello, World!");
}
$elapsed2 = microtime(true) - $now2;
echo "With import: " . round($elapsed2, 6) . " seconds\n";
For this tight loop, it results in an 86.2% performance increase. This was tested with OPcache enabled. You will se smaller performance gains with it disabled.
Will this affect real world applications? Most likely not by much.
https://redd.it/1milupj
@r_php
Some built-in functions have compiler optimized versions that avoid a lot of the internal overhead of the PHP engine. By importing them in source files (e.g.,
use function array_map) or by prefixing them with the global namespace separator, for example \is_string($foo):<?php
namespace SomeNamespace;
$now1 = microtime(true);
for ($i = 0; $i < 1000000; $i++) {
$result1 = strrev("Hello, World!");
}
$elapsed1 = microtime(true) - $now1;
echo "Without import: " . round($elapsed1, 6) . " seconds\n";
$now2 = microtime(true);
for ($i = 0; $i < 1000000; $i++) {
$result2 = \strrev("Hello, World!");
}
$elapsed2 = microtime(true) - $now2;
echo "With import: " . round($elapsed2, 6) . " seconds\n";
For this tight loop, it results in an 86.2% performance increase. This was tested with OPcache enabled. You will se smaller performance gains with it disabled.
Will this affect real world applications? Most likely not by much.
https://redd.it/1milupj
@r_php
PHP.Watch
Function Inlining in Zend Engine
A list of special PHP functions that Zend Engine can inline and optimize.
AI & Programming
PHPStorm, my preferred IDE uses AI to predict what I’m writing. It works quite well but it does have me questioning the future of my job security and hobby.
While currently AI produces often buggy and difficult to maintain spaghetti, how much longer until this is no longer the reality?
Is there anything I should be doing to prepare for this?
https://redd.it/1mingtk
@r_php
PHPStorm, my preferred IDE uses AI to predict what I’m writing. It works quite well but it does have me questioning the future of my job security and hobby.
While currently AI produces often buggy and difficult to maintain spaghetti, how much longer until this is no longer the reality?
Is there anything I should be doing to prepare for this?
https://redd.it/1mingtk
@r_php
Reddit
From the PHP community on Reddit
Explore this post and more from the PHP community
SymfonyCon Amsterdam 2025: Join the Symfony Hackathon: Collaborate, Contribute, Create
https://symfony.com/blog/symfonycon-amsterdam-2025-join-the-symfony-hackathon-collaborate-contribute-create?utm_medium=feed&utm_source=Symfony%20Blog%20Feed
https://redd.it/1mj0eml
@r_php
https://symfony.com/blog/symfonycon-amsterdam-2025-join-the-symfony-hackathon-collaborate-contribute-create?utm_medium=feed&utm_source=Symfony%20Blog%20Feed
https://redd.it/1mj0eml
@r_php
Symfony
SymfonyCon Amsterdam 2025: Join the Symfony Hackathon: Collaborate, Contribute, Create (Symfony Blog)
Ready to contribute to Symfony? On Nov 29, we’re hosting a Hackday in Amsterdam focused on mentoring, roadmap planning, testing, and more. Come shape the future of Symfony!
assetMapper and fonts
Hi,
I'm trying to import a google font.
php bin/console importmap:require @fontsource/oswald
This works fine, but after, i need to replace this with the local version, in my css
import url('https://fonts.googleapis.com/css2?family=Oswald:wght@200..700&display=swap');
i've tried
@import url('@fontsource/oswald/index.min.css');
or
@import url('@fontsource/oswald');
But it does not work..
How can i do that ?
https://redd.it/1miy6l1
@r_php
Hi,
I'm trying to import a google font.
php bin/console importmap:require @fontsource/oswald
This works fine, but after, i need to replace this with the local version, in my css
import url('https://fonts.googleapis.com/css2?family=Oswald:wght@200..700&display=swap');
i've tried
@import url('@fontsource/oswald/index.min.css');
or
@import url('@fontsource/oswald');
But it does not work..
How can i do that ?
https://redd.it/1miy6l1
@r_php
Reddit
From the symfony community on Reddit
Explore this post and more from the symfony community
PHP development with FrankenPHP and Docker
https://sevalla.com/blog/modern-php-with-frankenphp-and-docker/
https://redd.it/1mj2ueo
@r_php
https://sevalla.com/blog/modern-php-with-frankenphp-and-docker/
https://redd.it/1mj2ueo
@r_php
Sevalla
Modern PHP development with FrankenPHP and Docker
A hands-on guide to deploying PHP applications with FrankenPHP and Docker, from simple containers to standalone binaries.
PhpStorm 2025.2 Is Now Available
https://blog.jetbrains.com/phpstorm/2025/08/phpstorm-2025-2-is-now-available/
https://redd.it/1mj3lrx
@r_php
https://blog.jetbrains.com/phpstorm/2025/08/phpstorm-2025-2-is-now-available/
https://redd.it/1mj3lrx
@r_php
The JetBrains Blog
PhpStorm 2025.2 Is Now Available | The PhpStorm Blog
Along with making Laravel Idea free for PhpStorm users, this release brings improvements to the remote development experience, JetBrains AI tools, and more. Download PhpStorm 2025.2 Junie co
Configuring Renovatebot for upgrading Symfony?
I'm setting up Renovatebot to update my packages in a Symfony app, but i'm a bit confused about the Symfony packages.
I want to make a group so it will update them all together when doing Symfony upgrade. But how to make it change this part? eg. when upgrading from 7.2 to 7.3
"extra": {
"symfony": {
"allow-contrib": false,
"require": "7.2.*"
}
}
https://redd.it/1mj6r1f
@r_php
I'm setting up Renovatebot to update my packages in a Symfony app, but i'm a bit confused about the Symfony packages.
I want to make a group so it will update them all together when doing Symfony upgrade. But how to make it change this part? eg. when upgrading from 7.2 to 7.3
"extra": {
"symfony": {
"allow-contrib": false,
"require": "7.2.*"
}
}
https://redd.it/1mj6r1f
@r_php
Learning Symfony & Twig: Components, Conventions, and IDE Pains
Hi everyone,
I'm currently learning Symfony and Twig, and I’ve run into a few questions regarding best practices for structuring Twig components and improving developer experience. I’d really appreciate your input:
1. Where should I place Twig components ? I already have a folder structure for my templates, so if I need to move everything into a specific folder, that could be inconvenient.
2. What’s the convention for distinguishing between PascalCase and kebab-case? (I get the impression that everything that isn’t a class is written in kebab-case. However, in the case of templates vs TwigComponents, this creates a bit of an awkward inconsistency. So I’m not sure if I can use PascalCase for everything, or if I should keep using kebab-case for templates that aren't Twig components.),
3. Is it forbidden to have files prefixed with an underscore? Do they always have to start with a letter, or sometimes even an uppercase letter?,
4. What’s the naming convention regarding the “s” at the end of file or folder names? For example, sometimes we see "templates" (with an “s”), but for "api", it's usually singular.,
5. I’m working on VS Code, but auto-import doesn’t work, and incorrect paths aren’t being detected either. Yet I’ve installed all the recommended extensions, including PHP Intelephense and PHP Namespace Resolver, and according to various LLMs, my settings.json is correctly configured. Another feature that would be interesting is automatic reference updating when a file is moved. Is that even possible in PHP/Twig?, I’ve seen quite a few similar issues online — some people recommend switching to PhpStorm, which apparently has fewer problems. Would that really be the better solution?
6. Is there a GitHub repository that shows a realistic example of best practices and usage of Twig components?
Thanks in advance for any guidance, tips, or resources. 🙏
https://redd.it/1mjb92n
@r_php
Hi everyone,
I'm currently learning Symfony and Twig, and I’ve run into a few questions regarding best practices for structuring Twig components and improving developer experience. I’d really appreciate your input:
1. Where should I place Twig components ? I already have a folder structure for my templates, so if I need to move everything into a specific folder, that could be inconvenient.
2. What’s the convention for distinguishing between PascalCase and kebab-case? (I get the impression that everything that isn’t a class is written in kebab-case. However, in the case of templates vs TwigComponents, this creates a bit of an awkward inconsistency. So I’m not sure if I can use PascalCase for everything, or if I should keep using kebab-case for templates that aren't Twig components.),
3. Is it forbidden to have files prefixed with an underscore? Do they always have to start with a letter, or sometimes even an uppercase letter?,
4. What’s the naming convention regarding the “s” at the end of file or folder names? For example, sometimes we see "templates" (with an “s”), but for "api", it's usually singular.,
5. I’m working on VS Code, but auto-import doesn’t work, and incorrect paths aren’t being detected either. Yet I’ve installed all the recommended extensions, including PHP Intelephense and PHP Namespace Resolver, and according to various LLMs, my settings.json is correctly configured. Another feature that would be interesting is automatic reference updating when a file is moved. Is that even possible in PHP/Twig?, I’ve seen quite a few similar issues online — some people recommend switching to PhpStorm, which apparently has fewer problems. Would that really be the better solution?
6. Is there a GitHub repository that shows a realistic example of best practices and usage of Twig components?
Thanks in advance for any guidance, tips, or resources. 🙏
https://redd.it/1mjb92n
@r_php
Reddit
From the symfony community on Reddit
Explore this post and more from the symfony community
Symfony vs Laravel
The post "Symfony vs Laravel - Understanding the Differences" on kodmatrix.com is an insightful resource for developers who want to compare these two leading PHP frameworks. It highlights key aspects such as learning curve, performance, modularity, scalability, and ease of use.
https://redd.it/1mjfj2z
@r_php
The post "Symfony vs Laravel - Understanding the Differences" on kodmatrix.com is an insightful resource for developers who want to compare these two leading PHP frameworks. It highlights key aspects such as learning curve, performance, modularity, scalability, and ease of use.
https://redd.it/1mjfj2z
@r_php
KodMatrix
Symfony vs Laravel: Differences, Strengths & Best Uses (2025)
Compare Symfony and Laravel frameworks. Discover their strengths, differences, and use cases to pick the right PHP framework for your project.
alexmacarthur/laravel-loki-logging: Send your Laravel logs to a Grafana Loki server.
https://github.com/alexmacarthur/laravel-loki-logging
https://redd.it/1mjl10k
@r_php
https://github.com/alexmacarthur/laravel-loki-logging
https://redd.it/1mjl10k
@r_php
GitHub
GitHub - alexmacarthur/laravel-loki-logging: Send your Laravel logs to a Grafana Loki server.
Send your Laravel logs to a Grafana Loki server. Contribute to alexmacarthur/laravel-loki-logging development by creating an account on GitHub.
Magicless PHP framework?
First I'd like to say that I have nothing against the modern frameworks full of reflection and other dark magic, but I'm wondering if there's a PHP framework that is rather explicit than implicit in how it works, so that I don't need extra editor plugins to understand things such as type hints or what methods a class has.
Laravel, while great, often feels like programming in a black box. Methods on many of the classes don't exist (unless you use PHPStorm and Laravel Idea, or other extra plugins), data models have magic properties that also don't exist, and so on and so on, which makes me constantly go back and forth between the DB and the code to know that I'm typing a correct magic property that corresponds to the db column, or model attribute, or whatever ... and there's a ton of stuff like this which all adds up to the feeling of not really understanding how anything works, or where anything goes.
I'd prefer explicit design, which perhaps is more verbose, but at least clear in its intent, and immediately obvious even with a regular PHP LSP, and no extra plugins. I was going to write my own little thing for my own projects, but before I go down that path, thought of asking if someone has recommendations for an existing one.
https://redd.it/1mjvdxw
@r_php
First I'd like to say that I have nothing against the modern frameworks full of reflection and other dark magic, but I'm wondering if there's a PHP framework that is rather explicit than implicit in how it works, so that I don't need extra editor plugins to understand things such as type hints or what methods a class has.
Laravel, while great, often feels like programming in a black box. Methods on many of the classes don't exist (unless you use PHPStorm and Laravel Idea, or other extra plugins), data models have magic properties that also don't exist, and so on and so on, which makes me constantly go back and forth between the DB and the code to know that I'm typing a correct magic property that corresponds to the db column, or model attribute, or whatever ... and there's a ton of stuff like this which all adds up to the feeling of not really understanding how anything works, or where anything goes.
I'd prefer explicit design, which perhaps is more verbose, but at least clear in its intent, and immediately obvious even with a regular PHP LSP, and no extra plugins. I was going to write my own little thing for my own projects, but before I go down that path, thought of asking if someone has recommendations for an existing one.
https://redd.it/1mjvdxw
@r_php
Reddit
From the PHP community on Reddit
Explore this post and more from the PHP community
What's your preferred deployment strategy today with AI?
https://www.deployhq.com/blog/5-powerful-ways-to-deploy-php-applications-with-deployhq
https://redd.it/1mk0z15
@r_php
https://www.deployhq.com/blog/5-powerful-ways-to-deploy-php-applications-with-deployhq
https://redd.it/1mk0z15
@r_php
Deployhq
5 Powerful Ways to Deploy PHP Applications with DeployHQ
Master PHP application deployment with DeployHQ. Learn 5 powerful ways to automate Git-driven deployments, manage dependencies, use SSH commands, achieve zero-downtime releases, and handle multiple environments.
Switch Between Personas in Laravel With the MultiPersona Package
https://laravel-news.com/laravel-multipersona
https://redd.it/1mk1ots
@r_php
https://laravel-news.com/laravel-multipersona
https://redd.it/1mk1ots
@r_php
Laravel News
Switch Between Personas in Laravel With the MultiPersona Package - Laravel News
The Laravel MultiPersona package is a lightweight context-layer system for Laravel users. It allows a single user to switch between different roles, accounts, or tenants dynamically, without creating multiple logins or sessions.
How do you handle exceptions which you expect not to be thrown?
This question bugs me for a long time.
Often times an exception could be theoretically thrown but this will never happen in practice because the codepath is basically static.
Thats also wouldnt be a Problem if IDEs like PHPStorm wouldnt warn you about every unhandled exception through the complete stack trace.
So what patterns are you using to handle stuff like `DateMalformedException`, `RandomException` etc. which you no wont throw and if so it should crash.
For example given the following method:
/**
* @return $this
* @noinspection PhpDocMissingThrowsInspection // if removed doccomment also triggers warning
*/
public function expire(): self
{
$this->expirationDate = new DateTime();
$this->expirationDate->modify("-1 day"); // Unhandled \DateMalformedStringException
return $this;
}
Because the values are static you can expect that it works. More dynamic example would be:
function addDays(DateTime $date, int $days): DateTime
{
$date = clone $date;
$date->modify("+$days days"); // Even in this case we can safely assume the format is always correct because days is an int.
return $date;
}
Another candidate is `random_int`
random_int(1, 10); // Unhandled \Random\RandomException
https://redd.it/1mk3xzd
@r_php
This question bugs me for a long time.
Often times an exception could be theoretically thrown but this will never happen in practice because the codepath is basically static.
Thats also wouldnt be a Problem if IDEs like PHPStorm wouldnt warn you about every unhandled exception through the complete stack trace.
So what patterns are you using to handle stuff like `DateMalformedException`, `RandomException` etc. which you no wont throw and if so it should crash.
For example given the following method:
/**
* @return $this
* @noinspection PhpDocMissingThrowsInspection // if removed doccomment also triggers warning
*/
public function expire(): self
{
$this->expirationDate = new DateTime();
$this->expirationDate->modify("-1 day"); // Unhandled \DateMalformedStringException
return $this;
}
Because the values are static you can expect that it works. More dynamic example would be:
function addDays(DateTime $date, int $days): DateTime
{
$date = clone $date;
$date->modify("+$days days"); // Even in this case we can safely assume the format is always correct because days is an int.
return $date;
}
Another candidate is `random_int`
random_int(1, 10); // Unhandled \Random\RandomException
https://redd.it/1mk3xzd
@r_php
Reddit
From the PHP community on Reddit
Explore this post and more from the PHP community