Twig sandbox evaluate expression and filter the values
I have this in my twig:
$twig->render(
'{{ x + y }}',
'x' => 10, 'y' => 2
);
How to change Twig sandbox to evaluate
I tried to add a filter, like this:
$twig->addFilter(new TwigFilter('checkNull', function (string $value) {
}));
but I dont understand how to check the single values also if I pass them to the callback.
How can I check the two values before the expression is executed?
x + y|checkNull
I cannot find a good example onlline. Thanks for any help.
https://redd.it/1iumh5k
@r_php
I have this in my twig:
$twig->render(
'{{ x + y }}',
'x' => 10, 'y' => 2
);
How to change Twig sandbox to evaluate
x + y as an empty string if either x or y are empty (null)?I tried to add a filter, like this:
$twig->addFilter(new TwigFilter('checkNull', function (string $value) {
}));
but I dont understand how to check the single values also if I pass them to the callback.
How can I check the two values before the expression is executed?
x + y|checkNull
I cannot find a good example onlline. Thanks for any help.
https://redd.it/1iumh5k
@r_php
Reddit
From the symfony community on Reddit
Explore this post and more from the symfony community
Form login with user+password giving 302code upon success
Is this correct behavior?
I tried form login. While successfully routing to intended page, the profiler shows 302 status code. And bootstrap css and js didnt work. I have to manually refresh the page for bootstrap css and js to work.
Same case happens with logout. It redirect to login page as intended but with 302status code and bootstrap js/css didnt work. The usernamefield also empty. It s supposed to be filled with last username. Upon refreshing the page, the bootstrap css/js work and last username appears.
https://redd.it/1iumgae
@r_php
Is this correct behavior?
I tried form login. While successfully routing to intended page, the profiler shows 302 status code. And bootstrap css and js didnt work. I have to manually refresh the page for bootstrap css and js to work.
Same case happens with logout. It redirect to login page as intended but with 302status code and bootstrap js/css didnt work. The usernamefield also empty. It s supposed to be filled with last username. Upon refreshing the page, the bootstrap css/js work and last username appears.
https://redd.it/1iumgae
@r_php
Reddit
From the symfony community on Reddit
Explore this post and more from the symfony community
Documenting multitenant API in Laravel with Scramble
https://scramble.dedoc.co/blog/multitenant-apis
https://redd.it/1iunrcd
@r_php
https://scramble.dedoc.co/blog/multitenant-apis
https://redd.it/1iunrcd
@r_php
scramble.dedoc.co
Documenting multitenant API in Laravel with Scramble - Scramble
OpenAPI (Swagger) documentation generator for Laravel. Without manual PHPDoc annotations.
Mastering Laravel: Where to Put Your Custom Code (And Why)
https://backpackforlaravel.com/articles/tutorials/mastering-laravel-where-to-put-your-custom-code-and-why
https://redd.it/1iuudts
@r_php
https://backpackforlaravel.com/articles/tutorials/mastering-laravel-where-to-put-your-custom-code-and-why
https://redd.it/1iuudts
@r_php
Backpack for Laravel
Mastering Laravel: Where to Put Your Custom Code (And Why)
Laravel has plenty of built-in features and conventions to keep your code clean. But let’s be real: sooner or later, you’ll need to wri...
Best PHP Framework for developing middleware/microservice/API layer
Looking for recommendations! (Please don't recommend Go/Nodejs, only PHP based) 🚀
We're planning to develop a microservice in PHP and are considering async frameworks for better performance. In your experience, which PHP async framework is the fastest and most efficient for handling high-load scenarios?
Some of the short-listed candidates:
Laravel Octane (w/ Swoole)
Symfony w/ Swool runtime
Would love to hear your thoughts—any suggestions or real-world insights would be super helpful! 🙌
https://redd.it/1iux03n
@r_php
Looking for recommendations! (Please don't recommend Go/Nodejs, only PHP based) 🚀
We're planning to develop a microservice in PHP and are considering async frameworks for better performance. In your experience, which PHP async framework is the fastest and most efficient for handling high-load scenarios?
Some of the short-listed candidates:
Laravel Octane (w/ Swoole)
Symfony w/ Swool runtime
Would love to hear your thoughts—any suggestions or real-world insights would be super helpful! 🙌
https://redd.it/1iux03n
@r_php
Reddit
From the PHP community on Reddit
Explore this post and more from the PHP community
PHP is the best
I have come to the conclusion that PHP is better when you use a framework or (better yet) when you write your own OOP framework.
The best WebDev programming language of all times
https://redd.it/1iuymbn
@r_php
I have come to the conclusion that PHP is better when you use a framework or (better yet) when you write your own OOP framework.
The best WebDev programming language of all times
https://redd.it/1iuymbn
@r_php
Reddit
From the PHP community on Reddit
Explore this post and more from the PHP community
Playlist of Laracon EU 25 recordings is available on youtube
https://www.youtube.com/playlist?list=PLMdXHJK-lGoBWLQkMSyUORJkGk3ou27YI
https://redd.it/1iv3l1o
@r_php
https://www.youtube.com/playlist?list=PLMdXHJK-lGoBWLQkMSyUORJkGk3ou27YI
https://redd.it/1iv3l1o
@r_php
YouTube
LARACON EU 2025
Amsterdam, Netherlands Muziekgebouw Feb 3-4, 2025 Laracon is an annual gathering of passionate web developers that love building software using Laravel. Whet...
Audio analysis
Hello,
I'm not a developer myself, so I don't have a lot of knowledge, but I manage some projects in my company and I'm the contact person for the developers of our site (which runs on a Symfony framework), so I often need to understand more precisely the prerequisites and feasibility of a project before submitting it to them.
Here's my specific question. I'm working on a component that allows the user to upload audio (a meeting recording) and that indicates a quality score for this audio (voice intelligibility). I want to mix two techniques. I've already mastered the first, which consists of sending an audio extract to the Assembly API to obtain a trannoscription, and measuring an intelligibility result based on the confidence score of the transcribed words.
On the other hand, I want to weight this score by means of an analysis of the audio signal itself: the first score will therefore be lowered, for example, if the audio is saturated, or if there is significant reverberation.
Is there a specific library or function that would enable me to obtain an audio signal quality score for an extract analyzed after upload by the user?
Thank you !
https://redd.it/1iv5ujq
@r_php
Hello,
I'm not a developer myself, so I don't have a lot of knowledge, but I manage some projects in my company and I'm the contact person for the developers of our site (which runs on a Symfony framework), so I often need to understand more precisely the prerequisites and feasibility of a project before submitting it to them.
Here's my specific question. I'm working on a component that allows the user to upload audio (a meeting recording) and that indicates a quality score for this audio (voice intelligibility). I want to mix two techniques. I've already mastered the first, which consists of sending an audio extract to the Assembly API to obtain a trannoscription, and measuring an intelligibility result based on the confidence score of the transcribed words.
On the other hand, I want to weight this score by means of an analysis of the audio signal itself: the first score will therefore be lowered, for example, if the audio is saturated, or if there is significant reverberation.
Is there a specific library or function that would enable me to obtain an audio signal quality score for an extract analyzed after upload by the user?
Thank you !
https://redd.it/1iv5ujq
@r_php
Reddit
From the symfony community on Reddit
Explore this post and more from the symfony community
Why is Padding faster than Looping?
I recently compared two methods for generating unique keys in PHP, modeled after the Facebook User ID system.
One using a for loop and the other using string padding.
Spoiler alert: The padding method proved faster.
Here's a quick overview: https://pastebin.com/xc47LFy4
Can someone explain me why this is the case?
Is it due to reduced function call overhead, more efficient string manipulation, or something else?
https://redd.it/1iv4bhr
@r_php
I recently compared two methods for generating unique keys in PHP, modeled after the Facebook User ID system.
One using a for loop and the other using string padding.
Spoiler alert: The padding method proved faster.
Here's a quick overview: https://pastebin.com/xc47LFy4
Can someone explain me why this is the case?
Is it due to reduced function call overhead, more efficient string manipulation, or something else?
https://redd.it/1iv4bhr
@r_php
Pastebin
Looping vs Padding - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
React PHP
Has anyone used React library for PHP? It seems to have same features as JavaScript asynchronous programming. If you did, was there noticed improvement performance?
https://redd.it/1iv8s0t
@r_php
Has anyone used React library for PHP? It seems to have same features as JavaScript asynchronous programming. If you did, was there noticed improvement performance?
https://redd.it/1iv8s0t
@r_php
Reddit
From the PHP community on Reddit
Explore this post and more from the PHP community
API Authentication
Hey r/laravel
I wanted to get a general idea of how people are handling API authentication in their Laravel APIs atm.
Personally I've never been 100% happy with the options available, and have been designing a potential solution - but want to make sure it's not just me having the problem first!
https://redd.it/1ivh243
@r_php
Hey r/laravel
I wanted to get a general idea of how people are handling API authentication in their Laravel APIs atm.
Personally I've never been 100% happy with the options available, and have been designing a potential solution - but want to make sure it's not just me having the problem first!
https://redd.it/1ivh243
@r_php
Reddit
From the laravel community on Reddit
Explore this post and more from the laravel community
I want to give back
Laravel is growing rapidly, and I've seen firsthand how much transformative it can be for projects & businesses. After 6 years in another industry, I transitioned into software. Over the past year, I've worked commercially with Laravel and learned many lessons that I never encountered during 10+ years of building side projects.
At this milestone, I want to give back to the community by sharing some practical experiences and tips that you might not easily find online. I'm thinking about creating content on the following topics and would love your feedback on whether a video or a written post would be more helpful:
Shipping with Laravel: What to consider when deploying to production and h.ow maintain your app efficiently.
Debugging in Production & Locally: Tracing exceptions using tools like Sentry.io and other platforms.
Establishing Proper Observability: Techniques for effective logging and using request IDs and trace tools.
Containerisation with Docker: H.ow docker works for PHP and how it can simplify your development workflow.
If you have been struggling with something or would like to understand how commercial companies deal with these problems then please comment!
https://redd.it/1ivhvmg
@r_php
Laravel is growing rapidly, and I've seen firsthand how much transformative it can be for projects & businesses. After 6 years in another industry, I transitioned into software. Over the past year, I've worked commercially with Laravel and learned many lessons that I never encountered during 10+ years of building side projects.
At this milestone, I want to give back to the community by sharing some practical experiences and tips that you might not easily find online. I'm thinking about creating content on the following topics and would love your feedback on whether a video or a written post would be more helpful:
Shipping with Laravel: What to consider when deploying to production and h.ow maintain your app efficiently.
Debugging in Production & Locally: Tracing exceptions using tools like Sentry.io and other platforms.
Establishing Proper Observability: Techniques for effective logging and using request IDs and trace tools.
Containerisation with Docker: H.ow docker works for PHP and how it can simplify your development workflow.
If you have been struggling with something or would like to understand how commercial companies deal with these problems then please comment!
https://redd.it/1ivhvmg
@r_php
Sentry
Application Performance Monitoring & Error Tracking Software
Application performance monitoring for developers & software teams to see errors clearer, solve issues faster & continue learning continuously. Get started at sentry.io.
I would like to know your opinion about migrating GH repo.
https://ko-fi.com/polls/Should-php-bolt-driver-be-transfered-from-neo4j-ph-A0A51AZ7I6
https://redd.it/1ivmtx9
@r_php
https://ko-fi.com/polls/Should-php-bolt-driver-be-transfered-from-neo4j-ph-A0A51AZ7I6
https://redd.it/1ivmtx9
@r_php
Ko-fi
Should php bolt driver be transfered from neo4j-php GH organization? - Click to view on Ko-fi
Michal Štefaňák added a poll on Ko-fi
InertiaJS deferred props with lazy load relationships
I'm trying to workout what the "best" way is to send/return the data associated for the model that is using route model binding with InertiaJS?
There appear to be a few options, I'm wondering if anyone has any ideas on what is optimal?
I'm likely going to want to use **polling** in some instances as well as **partial reloads**.
**Example:**
````
class ShowController extends Controller {
public function __invoke(TeamShowRequest $request, Team $team) {
$team->load(['LAZY', 'RELATED', 'DATA]); ???
return Inertia::render('Team/Show', [
'team' => $team,
'LAZY' => ???
'RELATED' => ???
'DATA' => ???
]);
}
````
The way I see it there are the following options:
**Options:**
`$team->load(['results', 'players', 'coaches']);`
`'players' => fn () => $team->players()->get(),`
`'coaches' => Inertia::lazy(fn () => Coach::where('team_id', $team->id)->get()),`
https://redd.it/1ivpa7c
@r_php
I'm trying to workout what the "best" way is to send/return the data associated for the model that is using route model binding with InertiaJS?
There appear to be a few options, I'm wondering if anyone has any ideas on what is optimal?
I'm likely going to want to use **polling** in some instances as well as **partial reloads**.
**Example:**
````
class ShowController extends Controller {
public function __invoke(TeamShowRequest $request, Team $team) {
$team->load(['LAZY', 'RELATED', 'DATA]); ???
return Inertia::render('Team/Show', [
'team' => $team,
'LAZY' => ???
'RELATED' => ???
'DATA' => ???
]);
}
````
The way I see it there are the following options:
**Options:**
`$team->load(['results', 'players', 'coaches']);`
`'players' => fn () => $team->players()->get(),`
`'coaches' => Inertia::lazy(fn () => Coach::where('team_id', $team->id)->get()),`
https://redd.it/1ivpa7c
@r_php
Reddit
From the laravel community on Reddit
Explore this post and more from the laravel community
Any detailed and in-depth resource for Symfony?
Hello everyone. I decided to switch from Java to PHP and mess around with Symfony and try to understand what is it and how it works. I decided to clone this repo: https://github.com/Sylius/Sylius try to run it, maybe develop something and take a look at it, google what i dont understand and so on. But I noticed that theres no proper explanation for Symfony framework. For example what is "package", "bundle", "component", and other stuff? Why is there "Kernel.php" and what is it there? What Symfony has to do with Linux kernel? Why there are multiple ".gitignore" files? Whats the purpose of "bin" folder (in docs its said "The bin/ directory contains the main CLI entry point: console. You will use it all the time." but it leaves you with more questions than answers)? Why there is JS stuff in PHP project? And so on. Is there a proper tutorial/guide/resource that explains Symfony from the step 0?
Any help appreciated
https://redd.it/1ivrv1z
@r_php
Hello everyone. I decided to switch from Java to PHP and mess around with Symfony and try to understand what is it and how it works. I decided to clone this repo: https://github.com/Sylius/Sylius try to run it, maybe develop something and take a look at it, google what i dont understand and so on. But I noticed that theres no proper explanation for Symfony framework. For example what is "package", "bundle", "component", and other stuff? Why is there "Kernel.php" and what is it there? What Symfony has to do with Linux kernel? Why there are multiple ".gitignore" files? Whats the purpose of "bin" folder (in docs its said "The bin/ directory contains the main CLI entry point: console. You will use it all the time." but it leaves you with more questions than answers)? Why there is JS stuff in PHP project? And so on. Is there a proper tutorial/guide/resource that explains Symfony from the step 0?
Any help appreciated
https://redd.it/1ivrv1z
@r_php
GitHub
GitHub - Sylius/Sylius: Headless open-source eCommerce platform on top of PHP/Symfony/API Platform
Headless open-source eCommerce platform on top of PHP/Symfony/API Platform - Sylius/Sylius
Should php bolt driver be transfered from neo4j-php GH organization?
What is Bolt?
Neo4j has published the Bolt network protocol specification for graph database communication. Its use is unrestricted by any license, making it public and free. It is currently used by graph databases like Neo4j, Memgraph, Amazon Neptune, and others.
GitHub organization?
At some point, Neo4j recognized the growing interest from the PHP community and created the GitHub organization https://github.com/neo4j-php to gather community projects. However, Neo4j does not provide official support for these projects, nor does it offer financial support to members of this community.
What is all this about?
I wrote and maintain a PHP library for Bolt, which I transferred to this organization some years ago. My driver is low-level and works with any system that supports Bolt, regardless of version. However, keeping this project within the "official" Neo4j PHP organization has become restrictive.
Should I transfer my project back to me away from this organization?
View Poll
https://redd.it/1ivrqkl
@r_php
What is Bolt?
Neo4j has published the Bolt network protocol specification for graph database communication. Its use is unrestricted by any license, making it public and free. It is currently used by graph databases like Neo4j, Memgraph, Amazon Neptune, and others.
GitHub organization?
At some point, Neo4j recognized the growing interest from the PHP community and created the GitHub organization https://github.com/neo4j-php to gather community projects. However, Neo4j does not provide official support for these projects, nor does it offer financial support to members of this community.
What is all this about?
I wrote and maintain a PHP library for Bolt, which I transferred to this organization some years ago. My driver is low-level and works with any system that supports Bolt, regardless of version. However, keeping this project within the "official" Neo4j PHP organization has become restrictive.
Should I transfer my project back to me away from this organization?
View Poll
https://redd.it/1ivrqkl
@r_php
GitHub
Neo4j PHP Community
Projects for using Neo4j from PHP. Neo4j PHP Community has 10 repositories available. Follow their code on GitHub.
An Unnecessary PHP Project to Obfuscate Frontend Code in the Backend (Only to Decode It on the Client Side)"
The idea is to obfuscate frontend code (like HTML, CSS, JS) in the backend using PHP, and then simply decode it back on the client side. It's like hiding a secret message in plain sight, but with extra steps. 🤷♂️
Why?
For fun? Maybe.
To confuse bots that doesn't render javanoscript? Possibly.
To make your life unnecessarily complicated? Definitely!!
Here's the project: https://github.com/gokaybiz/Obfuscator-class
https://redd.it/1ivve62
@r_php
The idea is to obfuscate frontend code (like HTML, CSS, JS) in the backend using PHP, and then simply decode it back on the client side. It's like hiding a secret message in plain sight, but with extra steps. 🤷♂️
Why?
For fun? Maybe.
To confuse bots that doesn't render javanoscript? Possibly.
To make your life unnecessarily complicated? Definitely!!
Here's the project: https://github.com/gokaybiz/Obfuscator-class
https://redd.it/1ivve62
@r_php
GitHub
GitHub - gokaybiz/Obfuscator-class: Yet Another PHP Obfuscator (for your frontend)
Yet Another PHP Obfuscator (for your frontend). Contribute to gokaybiz/Obfuscator-class development by creating an account on GitHub.
Could someone please recommend in-depth resources on PHP basics and internals?
Hello. Im trying to learn PHP and currently its hell on earth. All videos and reads are the same "This is a variable, this is a loop, this is how you connect to DB". But no one talks about what the hell is php.ini, the order in which the php code is read and executed, no one even mentions that you can run php from the command line. Im coming from Java, and when I was learning it, I was explained the internals, how the code is being executed, that there is a Java code, that there is a compiler, what happens when you click "Run" in your IDE. Why theres no one who knows/teaches about the same things in PHP?
Thanks for any help
https://redd.it/1ivwtaz
@r_php
Hello. Im trying to learn PHP and currently its hell on earth. All videos and reads are the same "This is a variable, this is a loop, this is how you connect to DB". But no one talks about what the hell is php.ini, the order in which the php code is read and executed, no one even mentions that you can run php from the command line. Im coming from Java, and when I was learning it, I was explained the internals, how the code is being executed, that there is a Java code, that there is a compiler, what happens when you click "Run" in your IDE. Why theres no one who knows/teaches about the same things in PHP?
Thanks for any help
https://redd.it/1ivwtaz
@r_php
Reddit
From the PHP community on Reddit
Explore this post and more from the PHP community
PHP 8.4 brings CSS selectors :)
[https://www.php.net/releases/8.4/en.php](https://www.php.net/releases/8.4/en.php)
RFC: [https://wiki.php.net/rfc/dom\_additions\_84#css\_selectors](https://wiki.php.net/rfc/dom_additions_84#css_selectors)
**New way:**
$dom = Dom\HTMLDocument::createFromString(
<<<'HTML'
<main>
<article>PHP 8.4 is a feature-rich release!</article>
<article class="featured">PHP 8.4 adds new DOM classes that are spec-compliant, keeping the old ones for compatibility.</article>
</main>
HTML,
LIBXML_NOERROR,
);
$node = $dom->querySelector('main > article:last-child');
var_dump($node->classList->contains("featured")); // bool(true)
**Old way:**
$dom = new DOMDocument();
$dom->loadHTML(
<<<'HTML'
<main>
<article>PHP 8.4 is a feature-rich release!</article>
<article class="featured">PHP 8.4 adds new DOM classes that are spec-compliant, keeping the old ones for compatibility.</article>
</main>
HTML,
LIBXML_NOERROR,
);
$xpath = new DOMXPath($dom);
$node = $xpath->query(".//main/article[not(following-sibling::*)]")[0];
$classes = explode(" ", $node->className); // Simplified
var_dump(in_array("featured", $classes)); // bool(true)
https://redd.it/1iw1q94
@r_php
[https://www.php.net/releases/8.4/en.php](https://www.php.net/releases/8.4/en.php)
RFC: [https://wiki.php.net/rfc/dom\_additions\_84#css\_selectors](https://wiki.php.net/rfc/dom_additions_84#css_selectors)
**New way:**
$dom = Dom\HTMLDocument::createFromString(
<<<'HTML'
<main>
<article>PHP 8.4 is a feature-rich release!</article>
<article class="featured">PHP 8.4 adds new DOM classes that are spec-compliant, keeping the old ones for compatibility.</article>
</main>
HTML,
LIBXML_NOERROR,
);
$node = $dom->querySelector('main > article:last-child');
var_dump($node->classList->contains("featured")); // bool(true)
**Old way:**
$dom = new DOMDocument();
$dom->loadHTML(
<<<'HTML'
<main>
<article>PHP 8.4 is a feature-rich release!</article>
<article class="featured">PHP 8.4 adds new DOM classes that are spec-compliant, keeping the old ones for compatibility.</article>
</main>
HTML,
LIBXML_NOERROR,
);
$xpath = new DOMXPath($dom);
$node = $xpath->query(".//main/article[not(following-sibling::*)]")[0];
$classes = explode(" ", $node->className); // Simplified
var_dump(in_array("featured", $classes)); // bool(true)
https://redd.it/1iw1q94
@r_php
www.php.net
PHP 8.4 Released
PHP 8.4 is a major update of the PHP language. It contains many new features, such as property hooks, asymmetric visibility, an updated DOM API, performance improvements, bug fixes, and general cleanup.
Feedback needed - new package (LarAgent)
Hey! I recently released a new package which aims to simplify AI Agent development in Laravel. Please check it out: https://github.com/MaestroError/LarAgent
The docs aren't fully finished yet, but there is pretty enough to get some insight, install and try it out.
Your ideas and suggestions are crucial. Any feedback will appreciated!
https://redd.it/1iw6b7a
@r_php
Hey! I recently released a new package which aims to simplify AI Agent development in Laravel. Please check it out: https://github.com/MaestroError/LarAgent
The docs aren't fully finished yet, but there is pretty enough to get some insight, install and try it out.
Your ideas and suggestions are crucial. Any feedback will appreciated!
https://redd.it/1iw6b7a
@r_php
GitHub
GitHub - MaestroError/LarAgent: Power of AI Agents in your Laravel project
Power of AI Agents in your Laravel project. Contribute to MaestroError/LarAgent development by creating an account on GitHub.
A Week of Symfony #947 (17-23 February 2025)
https://symfony.com/blog/a-week-of-symfony-947-17-23-february-2025?utm_source=Symfony%20Blog%20Feed&utm_medium=feed
https://redd.it/1iw7plj
@r_php
https://symfony.com/blog/a-week-of-symfony-947-17-23-february-2025?utm_source=Symfony%20Blog%20Feed&utm_medium=feed
https://redd.it/1iw7plj
@r_php
Symfony
A Week of Symfony #947 (17-23 February 2025) (Symfony Blog)
This week, development activity focused on new security features. The upcoming Symfony 7.3 version added support for security voters to explain their vote, improved the IsGranted attribute to allow us…