PHP Reddit – Telegram
PHP Reddit
34 subscribers
291 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
Is there any tool that changes PHP's syntax?

Like a tool that would let me write $this.variable and it converts it to $this->variable

https://redd.it/1kp9g7k
@r_php
Two or fewer method/function arguments still ideal

What would you say, is the recommendation to give a method or function as few - in the best case two or fewer - arguments as possible still up to date?

I can understand that it is generally always better to use as few arguments as possible. However, this is often not feasible in practice.

I can also understand that before PHP 8, before named arguments existed, it was just ugly to pre-fill unused arguments.

See the following example function:

function font(string $file, string $color = '#000000',int $size = 12, float $lineHeight = 1, int $rotation = 0)
{
//
}

All arguments had to be filled before PHP 8 in order to create a default font with 90 degree rotation in the example.

// before PHP 8
$font = font('Example.ttf', '#000000', 12, 1, 90);

With PHP 8 there are fortunately named arguments:

// after PHP 8
$font = font('Example.ttf', rotation: 90);

This of course improves readability immensely. For this reason, I would say that there is not necessarily a reason to follow this recommendation. Of course, it still makes sense to split the arguments into higher-level objects if applicable. But not at all costs.

As long as there are only 1 or 2 without a default value, readability should still be guaranteed with named arguments. What do you think?

https://redd.it/1kpi29s
@r_php
Introspect for Laravel - Query your codebase like a database with an Eloquent-like API
https://redd.it/1kpoz7z
@r_php
Weekly /r/Laravel Help Thread

Ask your Laravel help questions here. To improve your chances of getting an answer from the community, here are some tips:

What steps have you taken so far?
What have you tried from the documentation?
Did you provide any error messages you are getting?
Are you able to provide instructions to replicate the issue?
Did you provide a code example?
Please don't post a screenshot of your code. Use the code block in the Reddit text editor and ensure it's formatted correctly.

For more immediate support, you can ask in the official Laravel Discord.

Thanks and welcome to the r/Laravel community!

https://redd.it/1kpoq5b
@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/1kq1t0a
@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/1kq4h8w
@r_php
Who's hiring/looking

This is a bi-monthly thread aimed to connect PHP companies and developers who are hiring or looking for a job.

Rules

No recruiters
Don't share any personal info like email addresses or phone numbers in this thread. Contact each other via DM to get in touch
If you're hiring: don't just link to an external website, take the time to describe what you're looking for in the thread.
If you're looking: feel free to share your portfolio, GitHub, … as well. Keep into account the personal information rule, so don't just share your CV and be done with it.

https://redd.it/1kq67pi
@r_php
PHP on macos

Hi guys,

I was curious in what way you have PHP running locally. Currently using XAMPP but got a new macbook and wanted to a clean proper install.


Its for a custom PHP framework.


What would you recommend and why?

https://redd.it/1kqauqj
@r_php
Moving application logic out of livewire components to service classes. Used service classes to delete records.

Hello All,

I have posted here before about the project I have been working on for some time and have got some valuable feedback suggestions from you all.

I had got suggestion here to move the application/business logic from livewire components to service classes. I followed the pattern, and now have implemented delete functionality for most of the records using service classes.

As a whole, moving the application/business logic from livewire component to service classes feels much more cleaner than before. Having business logic in a service classes has given more freedom to call these services from any controller or livewire components.

Here is the github repo.

https://github.com/oitcode/samarium

More work/code is required to move most of the application logic from livewire components to service classes, but for now I have implemented deletion of records at least.

Worked some time on this, so sharing here, also thanks to all who suggested this change.

Thanks.

https://redd.it/1kqfdha
@r_php
Frankenstein Migration: Mojavi to Symfony

I have a web application, that I currently maintain, that is a frankenstein of beast. As far as I can tell there are two php frameworks in this project, Mojavi 2.0 and Symfony 4.4, and I need to migrate it to one. It was originally built on Mojavi and then at some point someone added Symfony 4.4 but never fully migrated it.

I can't find any documentation on Mojavi. The only info I can get is from ChatGPT...and that was only helpful in understanding the structure. I want to do a phased rewrite to 6.4 or 7 but my boss is against it and thinks updating to 4.4 should be easy.

If anyone has experience with this kind of migration, can you help. With either how to refactor the code in Mojavi to Symfony 4 or convincing my boss to the rewrite.

https://redd.it/1kqhprb
@r_php
Is it safe to use emulated prepared statements in Laravel?

Hi everyone,

I’m building a DBA assistant. One challenge we’ve encountered is prepared statements in MySQL and MariaDB. They don’t leave much for analysis after they’re executed. We've sent this problem to MariaDB core developers.

Since Laravel uses PDO with prepared statements by default, it makes profiling harder. But there’s an option to enable “emulated” prepared statements in PDO. When enabled, queries are sent as raw SQL, which is easier to log and analyze.

So I’m wondering:

Would it be safe to enable emulated prepared statements in Laravel - at least in dev or staging - to get better query insights?

Curious to hear your thoughts.

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