PHP Reddit – Telegram
PHP Reddit
33 subscribers
293 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
WIP A mini Symfony app that leverages some great features in the perspective of building APIs. Good for beginners.

Hello devs, this is a simple blogging platform https://github.com/abdellahrk/microblog that might be helpful to some beginners. Features are being added and some ideas as well.

While there are tons of resources and guides out there amongst which the Symfony Demo App, this could also complement and be of help.

https://redd.it/1iu5ydj
@r_php
Doubts about validation & doctrine collections

Hey

I am new to Symfony and recently noticed a few issues which are kind of bugging me.

While working on restful apis, I used #MapRequestPayload and #MapQueryString a lot, it seems like a nice feature, however there are unexpected behaviors. For example when you map to dto with required fields, and submit a request without body, you get HttpException from inside PayloadResolver, instead of validation related exception. Is this the most recommended way of handling data validation? I realize I can use ValidatorInterface and populate dtos manually, but this seems ugly and tedious.

Another thing, while working with lists of entities in query results, I noticed that doctrine collection offers very little functionality, and most operations end up being done on plain arrays using built in functions. Is it supposed to be like that in actual projects, or do you tend to install something to enhance collections?

https://redd.it/1iu7ezv
@r_php
I'm Joe Dixon, Engineering Team Lead of Laravel Cloud, Ask Me Anything!

Hey r/Laravel,

Next Monday, February 24, my team is launching Laravel Cloud to the world. Laravel Cloud is a fully managed infrastructure platform optimized specifically for Laravel and PHP.

I'll be hosting an AMA next Thursday, February 27 to answer your questions about Laravel Cloud. Add your questions below and I'll see you then!

https://redd.it/1iu8l8g
@r_php
Finally Integrated PayPal with Laravel—I will make rent this month

Hi everyone,

I’ve been using Paystack for payment processing on Maasai Market Online, but recently, one of my customers couldn’t complete a payment. That was a turning point—I needed a better solution for international payments.

I tried multiple PayPal packages for Laravel, and let’s just say... it wasn’t smooth sailing. Some had outdated docs, others threw weird errors. But after a lot of trial and error, I finally found the right package that works perfectly with Laravel—no issues at all!

Since Stripe isn’t available in my country and Lemon Squeezy doesn’t support physical goods, PayPal was the best option. I’m still a newbie and my project is still at its MVP stage, but every challenge makes me learn and appreciate Laravel even more.

If anyone is struggling with PayPal integration, I put together a GitHub Gist with a step-by-step guide:
PayPal Integration for Laravel 11

Hope it helps! Let me know what payment processors you’re using in your Laravel projects.

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