PHP Reddit – Telegram
PHP Reddit
34 subscribers
292 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
Symfony API docs

I've noticed that there is an API documentation for laravel https://api.laravel.com/docs/12.x/index.html

does symfony have the same documentation? it seems really helpful.



https://redd.it/1jlq9pl
@r_php
Good exception patterns to follow?

I recently saw that a colleague had defined a method in his new exception class called asHttpResponse() that sends back an instance of Psr\\Http\\Message\\ResponseInterface.

That got me thinking: Are there other patterns related to exceptions that are simple, easy to follow and helpful? I know woefully little about this topic.

Full disclosure: If I really like what you have to say, I'm likely to steal it for a lightning talk :-)

https://redd.it/1jlpdtu
@r_php
“Why Haven’t We Seen Another Web Language Like PHP in 30 Years?”

PHP is unique among web programming languages because it was designed from the start to be embedded directly into HTML, making it feel more like a natural extension of the web rather than a separate backend system. Unlike modern frameworks and languages that enforce strict separation between logic and presentation, PHP allows developers to mix HTML and server-side code seamlessly, making it incredibly accessible for beginners and efficient for quick development.

Even after 30 years, no other mainstream language has replicated this approach successfully. Most alternatives either rely on templating engines, APIs, or complex frameworks that separate backend logic from HTML. Why do you think PHP remains the only language to work this way? Is it a relic of the past, or does it still hold a special place in web development?

https://redd.it/1jllvip
@r_php
The end is near: Packagist is returning 500 responses randomly

Packagist web interface seems to throw Internal server errors without any reason. Reloading somtimes helps. Or it helps after 5 tries.

No call for help. Just wanted to announce armageddon.

https://redd.it/1jmngaq
@r_php
Vanilla PHP

I’m building a small web for a hobby. I might scale it a bit and offer some paid use, but it’s not my primary objective.

I’m confident I can build the app & logic and authentication just using vanilla php & MySQL, however every advice points me towards a framework regardless.

Is a framework e.g Laravel essential in 2025?

https://redd.it/1jlr3tc
@r_php
Split services.yaml into smaller parts

Hello.

My services.yaml file has over 1000 lines.

Does anyone know how I can split it into smaller parts? I tried creating smaller files and importing them in the "imports" section of the services.yaml file, but it gives me many errors.

Does anyone know the solution? Thanks.

https://redd.it/1jmtv74
@r_php
Symfony - tutorials or courses

Hi guys,

I recently started working with symfony, coming from a Laravel background.

Is there anything like Laracasts (online videos/tutorials) but for symfony? Or any learning materials you can suggest?

Thanks

https://redd.it/1jmv3s5
@r_php
🚀 Try My New VS Code Extension for Filament!

Hey everyone! 👋

I just released a VS Code extension for FilamentPHP that makes development smoother and more efficient. If you're working with Filament, give it a try and let me know what you think!

🔗 https://marketplace.visualstudio.com/items?itemName=doonfrs.vscode-filament

If you find it useful, I’d appreciate a 5-star rating on the marketplace! Your feedback helps improve the extension and reach more developers.

Let me know your thoughts or any feature suggestions! 🚀

Filament UI for VSCode Demo

https://redd.it/1jmcbw4
@r_php
Routing libraries that are updated to PHP8.4

Heya,

I've been using Phroute for a few years now and I've honestly added a lot of patches over the years to my own fork of it because development on it is basically stalled. It's getting to the point where I keep finding more and more bugs in the library that I need to make fixes for. And at this point it would be easier to rewrite the whole thing. But that feels like a waste of time.

I want to migrate over to a super simple and lightweight stand-alone routing library. The requirement I have is that it is actively maintained and as barebone as possible. All I need is Variable Routing (optional url segments) and Filters (functions that run pre/post request). That's it. I dont need anything super fancy with 700 layers of abstractions. Which library would you guys recommend?


Thanks in advance!

https://redd.it/1jlj82u
@r_php
Creating a new entity within preFlush

TLDR: Entity listener preFlush event not triggering when the entity is being created within another entities preFlush event listener.

I've got an entity called Remittance and another called Transaction. There's some other stuff going on but that doesn't really matter. I've got an entity listener on both of these which checks to see if a reference has been set and if not then it generates and sets one - these are named RemittanceListener and TransactionListener.

This works perfectly. The problem is that I'm trying to implement a feature whereby when a Remittance is created/edited, if a certain condition is met (specifically the remittance total being a negative number) then it'll create a new instance of the Transaction entity.

This actually works just fine however when doing it in the preFlush event on my RemittanceListener the TransactionListener never runs and therefore the newly created Transaction entity doesn't get a new reference. I've searched around but I can't seem to find a way around this.

Let me show you some code... my RemittanceListener and TransactionListener.

class RemittanceListener
{
    public function preFlush(Remittance $remittance, PreFlushEventArgs $args): void
    {
        // Get em
        $em = $args->getObjectManager();
        $uow = $em->getUnitOfWork();

        // Not got a reference
        if (!$remittance->getReference())
        {
            // Set it
            $remittance->setReference($this->utilHelper->generateNextReference("remittance"));
        }

        // Totals
        $total = 0;

        // Loop the lines
        foreach ($remittance->getLines() as $someLine)
        {
            // Add to totals
            $total += $someLine->getTotal();
        }

        // Has the remittance gone negative
        if ($total < 0)
        {
            // Work out the difference
            $difference = abs($total);

            // Create a new transaction
            $transaction = new Transaction(
                'amount' => $difference,
                'denoscription' => "Shortfall on " . $remittance->getReference(),
                'remittance' => $remittance
            );

            // Persist the transaction
            $em->persist($transaction);

            // Compute changeset for the new entity so that it gets persisted
            $metaData = $em->getClassMetadata(Transaction::class);
            $uow->computeChangeSet($metaData, $transaction);

            // Update the totals to 0
            $total = 0;
        }

        // Set totals
        $remittance->setTotal($total);
    }
}

class TransactionListener
{
    public function preFlush(Transaction $transaction, PreFlushEventArgs $args): void
    {
        // Get em
        $em = $args->getObjectManager();
        $uow = $em->getUnitOfWork();

        // Not got a reference
        if (!$transaction->getReference())
        {
            // Set it
            $transaction->setReference($this->utilHelper->generateNextReference("transaction"));
        }
    }
}

That preFlush method on the TransactionListener never runs and therefore it isn't given a reference :(

Any help would be greatly appreciated!

https://redd.it/1jn9jts
@r_php
Filament Sketchpad - Releasing v.1.1.0

Filament Sketchpad is a simple package that provides you with a sketchpad field in Filament (as the name indeed indicates). Useful for signatures (and doodles?)

I've added a few features over the last few days:

* A minimal mode (icons only, with tooltips)
* Fully configurable buttons
* An Infolist component
* A reset button

And corrected some bugs:

* Unreliable download feature
* Recording of empty strokes
* Dirty state when rendering multiple components.

More information [here](https://github.com/valentin-morice/filament-sketchpad). Feel free to reach out on GitHub or here if you'd like to request a new feature or contribute!

https://redd.it/1jndo6s
@r_php
UmbrellaAdminBundle Take a look at my AdminBundle :)

Hi,

I have created a post about this bundle some years ago but i have greatly improved the bundle since then and simplified the installation.

https://preview.redd.it/m5saf1sgxure1.png?width=1920&format=png&auto=webp&s=d84ac11a1e9be604dc8760336b31b19e8a94279a

This is the bundle => https://github.com/acantepie/umbrella-admin-bundle
There is also an online demo => https://umbrella-corp.dev/

Enjoy, this is a 100% open-source projet and don't forget to give me your feedbacks !

https://redd.it/1jnguv6
@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/1jngz14
@r_php
Decent DX with Slim/Twig/Alpinejs

I've been testing out Alpinejs quite a while. Was working on a side project in golang with sqlite and Alpinejs, but had a priority shift, as something came up over this weekend.

A 2nd degree friend of mine got in touch with me, requesting some internal tooling to manage his WhatsApp logistics. After carefully analyzing his conversation, and saw that this was mainly his side hustle, and had no intentions in scaling up due it's nature, I've decided to help him out, ofc $$$ is involved.

The tech stack was simple:
PHP 8.4
Slim
Twig
raw dogging PDO + sqlite
JS libs: Alpine, Tiptap, Hammer and Chart (all CDN btw)
Bulma, wasn't even bothered to waste time with styling. Just mainly focused for mobile styling.

Feels actually fresh to write PHP again, ofc I forgot to mention that I did include additional libraries for sanitization. Have 3 layouts (auth, dashboard and homepage) to properly load the necessary noscripts on each page.

I've managed to work on a 80% crud operations, with chartjs + half ass working PDF within a single day.

And consider i haven't touch for nearly 2 years. If I was to write the same thing in Laravel or Symphony, would have taken me 4 to 5 days just a MVP.

Oh, I was also a bad boy. Wrote +20 route with the logic in a single file. There are only 2 middlewares: throttle and csrf. The entire logic is around 1.8k lines of code.

tldr; know your foundation and everything else is easy.

https://redd.it/1jntxmp
@r_php
Easily create product webpages in your website Video preview

https://reddit.com/link/1jnvpvt/video/ybt1qgffjyre1/player

Sharing a video preview of creating a product from admin panel and displaying in the website. Using Laravel and Livewire.

Project:

https://github.com/oitcode/samarium

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