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
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
Accessing $this when calling a static method on a instance

In PHP, you can call a static method of a class on an instance, as if it was non-static:

class Say
{
public static function hello()
{
return 'Hello';
}
}

echo Say::hello();
// Output: Hello

$say = new Say();
echo $say->hello();
// Output: Hello

If you try to access $this from the static method, you get the following error:

>Fatal error: Uncaught Error: Using $this when not in object context

I was thinking that using isset($this) I could detect if the call was made on an instance or statically, and have a distinct behavior.

class Say
{
public string $name;

public static function hello()
{
if (isset($this)) {
return 'Hello ' . $this->name;
}

return 'Hello';
}
}

echo Say::hello();
// Output: Hello

$say = new Say();
$say->name = 'Jérôme';
echo $say->hello();
// Output: Hello

This doesn't work!

The only way to have a method name with a distinct behavior for both static and instance call is to define the magic __call and __callStatic methods.

class Say
{
public string $name;

public function call(string $method, array $args)
{
if ($method === 'hello') {
return 'Hello ' . $this->name;
}

throw new \LogicException('Method does not exist');
}

public static function callStatic(string $method, array $args)
{
if ($method === 'hello') {
return 'Hello';
}

throw new \LogicException('Method does not exist');
}
}

echo Say::hello();
// Output: Hello

$say = new Say();
$say->name = 'Jérôme';
echo $say->hello();
// Output: Hello Jérôme

Now that you know that, I hope you will NOT use it.

https://redd.it/1kr9kh3
@r_php
Meract: A PHP MVC Framework with Built-in Frontend Integration (Morph) – Looking for Feedback

I’ve been working on Meract, an MVC framework for PHP that bridges backend and frontend seamlessly. It’s designed for developers who want an all-in-one solution with minimal setup. Here’s why it might interest you:

1. Morph: Integrated Frontend Framework
2. Laravel-like Syntax
1. Familiar routing, models, and migrations: Route::get('/post/{id}', [PostController::class, 'show']);  
3. CLI Powerhouse (mrst)
4. Auth & Storage Out of the Box
5. Why Another Framework?
1.    Unifies backend and frontend (Morph eliminates the JS build step for simple apps).
2.    Is lightweight but extensible (e.g., swap Storage drivers for Redis).
3.    Keeps PHP’s simplicity (no Webpack/config hell).
6. Is It Production-Ready?
1. Current state: Beta (The entire framework needs testing, and Morph, in particular, requires architectural improvements).
2. Github: https://github.com/meract/meract

https://redd.it/1krbhhh
@r_php
Introducing ConvergePHP (Beta)

After almost 5 months of development, my friends are going to announce the beta release of ConvergePHP, a clean, modern, and open-source framework built specifically for Laravel developers to build and manage documentation websites, with plans to support blogs in future releases

Key features available in this early release include:
- Laravel-first architecture.
- Helps build beautiful, structured documentation out of the box
- Seamless integration of Blade components within Markdown files.
- A fast, built-in search engine.
- Highly customizable themes enabling distinct presentation.
- and much more


Try it out here:
Website: https://convergephp.com
Source code: https://github.com/convergephp/converge

https://redd.it/1krddib
@r_php
How I can make doctrine:migrations:diff generate only sql files instead of migrations?

Usually `doctrine:migrations:diff` generate a migration noscript but instead of running them as is we only ghet the diff for the db and manually execute the queries one-by-one what I want is to modify this logic in order to generate sql files instwad of migrations noscript only for the `up` .

In other words I want to generate only raw sql for the diff instead of generating migration noscripts. How can do this?

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