PHP Reddit – Telegram
PHP Reddit
34 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
PHPoker: Library and Hand Evaluator

If anybody is interested, I posted about it awhile ago, finally got around to finishing it.

♦️♥️♣️♠️ PHPoker
https://github.com/PHPoker/Poker

A PHP library for working with playing cards, specifically poker (based on Nuno's Skeleton-PHP, great package).

It started off as a port of Kevin "CactusKev" Suffecool's Poker Hand Evaluator (both 5/7 card), written in C, and then I added some additional stuff to round it out and improve the developer experience a bit.

I am sure the direct C implementation Kevin will be more performant, but this is actually a very faithful port of his algorithm, including the "perfect hash" improvements contributed by Paul Senzee. Since PHP is written in C under the hood, it may not actually be as far behind as one would expect. I will do some real performance benchmarks soon and add to the ReadMe.

My version is also nicer to use from a development perspective, if I do say so myself.

Check it out, let me know what you think, or feel free to submit an issue, PR, or idea via GitHub. 🙏

Also - shoutout to CactusKev, not only for sharing his code with the detailed explanations, but he actually responded to an e-mail I sent. There was a typo on his example code which caused me some headaches before I figured it out and let him know. He was super humble and supportive that people were still using his code, and seemed like a cool and smart guy. 🌵🧊

https://redd.it/1j4p6xf
@r_php
Unicode: A Type-Safe Unicode Character Package

Hey, everyone!

Lately, I’ve been working a lot with Unicode characters, both actual symbols in UTF-8 and their escape sequences in other encodings. Managing the different variants and remembering escape sequences alongside the actual symbols (e.g., \u2190 => →) became a bit cumbersome. I also wanted a type-safe way to handle them, so inspired by spatie/emoji I built this package!

Example usage:

// Output a right arrow
echo Unicode::RIGHTARROW; // Outputs →

// Convert to escaped Unicode sequence
echo Unicode::escape(Unicode::RIGHT
ARROW); // Outputs \u2190


Would love to hear your thoughts and suggestions! It doesn’t cover every case yet, so if you think something useful is missing, feel free to reach out—or even better, send a PR!

https://github.com/rayblair06/unicode

https://redd.it/1j4vrih
@r_php
logic that decide how data is displayed, in twig or controller??

What s the right way?

Let s say I hav data to be displayed in table format. Data row that meets certain threshold will be displayed in certain color.

Do I put if else statement in twig? Or is there more elegant way?

https://redd.it/1j4xgxu
@r_php
Introducing Neuron AI – Create full featured AI Agents in PHP

Hi to all PHP engineers, I'm Valerio, CTO of Inspector
I'm very exited to share the release of Neuron AI, an open source framework for integrating AI agents into your existing PHP applications.

https://inspector.dev/introduction-to-neuron-ai-create-full-featured-ai-agents-in-php/

In the last year, I struggled a lot mainly because the PHP ecosystem to develop this kind of “Agentic” features into existing applications it’s not as advanced and rich as it is in other technologies.

In this article I jot down why I decided to release this internal tool as an open source project and what is the market opportunity for me and the PHP community.

I hope it could be the right tool for PHP developers to build AI agents into their products with stronger foundations.

Feel free to write your feedback, share this tool with other PHP friends, or contact me for further information.

https://redd.it/1j4x8ja
@r_php
Has anyone tried this (curious)

So I'm curious about something that I haven't tried myself yet, time permitting I will soon. Has anyone ever attempted sending the browser's DOM to their PHP server, manipulating the DOM with PHP and then sent it back to the browser replacing the original DOM to render stuff. I don't mind if it's a bad idea I'm just brain farting. Please tell me your experience.

https://redd.it/1j4zehs
@r_php
Laravel and Massive Historical Data: Scaling Strategies

Hey guys

I'm developing a project involving real-time monitoring of offshore oil wells. Downhole sensors generate pressure and temperature data every 30 seconds, resulting in \~100k daily records. So far, with SQLite and 2M records, charts load smoothly, but when simulating larger scales (e.g., 50M), slowness becomes noticeable, even for short time ranges.

Reservoir engineers rely on historical data, sometimes spanning years, to compare with current trends and make decisions. My goal is to optimize performance without locking away older data. My initial idea is to archive older records into secondary tables, but I'm curious how you guys deal with old data that might be required alongside current data?

I've used SQLite for testing, but production will use PostgreSQL.

(PS: No magic bullets needed—let's brainstorm how Laravel can thrive in exponential data growth)

https://preview.redd.it/uzgs39fll4ne1.png?width=1349&format=png&auto=webp&s=7e565cdfb826656959b0ff7a50a7cbeb846f0243




https://preview.redd.it/1xbd238hk4ne1.png?width=580&format=png&auto=webp&s=2d6c9dedefe6190813b28f75f7970a5556514734



https://redd.it/1j54qum
@r_php
What folders/files do you typically hide in VS Code when working with Laravel projects?

I’ve been working on Laravel projects in VS Code, and I’ve noticed that there are a lot of folders and files that aren’t directly relevant to my day-to-day coding (e.g., vendornode_modules, etc.). To keep my workspace clean, I’ve started hiding some of these in VS Code.
I’m curious, what folders or files do you typically hide in your Laravel projects?
Are there any best practices or recommendations for managing the VS Code workspace to improve productivity?

https://redd.it/1j59t0q
@r_php
Understanding Official Starter Kit options as a Laravel newbie

I'm a newbie to laravel and I come from the javanoscript world. Am I understanding the starter kit's Livewire flavour correctly that it uses Flux UI which is a paid option?

Not complaining about it, but wanted to know if I should stick with my familiar Vue Inertia combo (shadcn-vue is free & open-source) or go the Livewire path (learning curve here for me). Just want to clarify this before I go too far with either and then discovering these kinda facts. Thanks!

https://preview.redd.it/e28lwp8qn7ne1.png?width=1168&format=png&auto=webp&s=9e8664046d2c4fde2b17945c48535f44f8faf22b



https://redd.it/1j5h7i1
@r_php
Recreating React style components in Twig

I have recently been learning React and really like the how I can build a page using reusable React components. I have also been using TailwindCSS for sometime and the combination of the 2, to me, really makes sense.

I was looking at trying to recreate a similar approach in Twig. I have come up with the following as a first attempt. I was just wondering if anyone else has been down this rabbit hole and how you solved it?

{% extends 'application.html.twig' %}

{% block main %}
{% embed '@VendorBundle/PageContainer.html.twig' %}
{% block children %}
{% embed '@VendorBundle/PageHeader.html.twig' %}
{% block noscript %}Users{% endblock %}
{% block children %}
{% embed '@VendorBundle/Button/Primary.html.twig' %}
{% block href %}{{ path('name_of_path') }}{% endblock %}
{% block children %}
{{ ux_icon('bi:plus', {class: 'w-3 h-3'}) }}
Add New
{% endblock %}
{% endembed %}
{% endblock %}
{% endembed %}
{% embed '@VendorBundle/Table/TableContainer.html.twig' %}
{% block children %}
{% embed '@VendorBundle/Table/Table.html.twig' %}
{% block children %}
{% embed '@VendorBundle/Table/TableHead.html.twig' %}
{% block children %}
{% embed '@VendorBundle/Table/TableHeadRow.html.twig' %}
{% block children %}
{% embed '@VendorBundle/Table/TableHeader.html.twig' %}
{% block children %}Name{% endblock %}
{% endembed %}
{% embed '@VendorBundle/Table/TableHeader.html.twig' %}
{% block children %}Email{% endblock %}
{% endembed %}
{% embed '@VendorBundle/Table/TableHeader.html.twig' %}
{% block children %}<span class="sr-only">Actions</span>{% endblock %}
{% endembed %}
{% endblock %}
{% endembed %}
{% endblock %}
{% endembed %}
{% embed '@VendorBundle/Table/TableBody.html.twig' %}
{% block children %}
{% for user in users %}
{% embed '@VendorBundle/Table/TableBodyRow.html.twig' %}
{% block children %}
{% embed '@VendorBundle/Table/TableData.html.twig' %}
{% block children %}
{{ user.firstName }} {{ user.lastName }}
{% endblock %}
{% endembed %}
{% embed '@VendorBundle/Table/TableData.html.twig' %}
{% block children %}
<a href="mailto:{{ user.emailAddress }}" class="underline hover:no-underline">{{ user.emailAddress }}</a>
{% endblock %}
{% endembed %}
{% embed '@VendorBundle/Table/TableData.html.twig' with {'classes': 'flex items-center justify-end'} %}
{% block children %}
<button id="actions-{{ loop.index }}-dropdown-button" data-dropdown-toggle="actions-{{ loop.index }}-dropdown" class="inline-flex items-center p-0.5 text-sm font-medium text-center text-gray-500 hover:text-gray-800 rounded-lg focus:outline-none dark:text-gray-400 dark:hover:text-gray-100" type="button">
{{ ux_icon('bi:three-dots', {class: 'w-5 h-5'}) }}
</button>
<div id="actions-{{ loop.index }}-dropdown" class="hidden z-10 w-44 bg-white rounded divide-y divide-gray-100 shadow dark:bg-gray-700 dark:divide-gray-600">
<ul class="py-1 text-sm text-gray-700 dark:text-gray-200" aria-labelledby="actions-{{ loop.index }}-dropdown-button">
<li>
<a href="{{ path('name_of_path', { id: user.accountId }) }}" class="block py-2 px-4 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">Edit</a>
</li>
</ul>
<div class="py-1">
<a href="{{ path('name_of_path', { id: user.accountId }) }}" class="block py-2 px-4 text-sm text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-200 dark:hover:text-white">Delete</a>
</div>
</div>
{% endblock %}
{% endembed %}
{% endblock %}
{% endembed %}
{% endfor %}
{% endblock %}
{% endembed %}
{% endblock %}
{% endembed %}
{% embed '@VendorBundle/Table/TablePagination.html.twig' with {'pagination': users} only %}{% endembed %}
{% endblock %}
{% endembed %}
{% endblock %}
{% endembed %}
{% endblock %}

// VendorBundle/PageHeader.html.twig

<div class="flex items-center justify-between space-x-3 w-full md:w-auto pb-4">
<h1 class="text-4xl font-bold text-gray-900 dark:text-white">{% block noscript %}{% endblock %}</h1>
{% block children %}{% endblock %}
</div>

https://redd.it/1j5l6zm
@r_php
Laravel Cloud blocking iframes

I was evaluating Laravel Cloud as an alternative to Heroku recently and found that it's not suitable for our BigCommerce & Shopify apps as they add an "X-Frame-Options: Deny" header.

This essentially blocks our apps from loading as both platforms use iframes. I've spoken to support and it doesn't sound like it's an option that Laravel are going to provide in the short term.

Has anyone come up with a workaround? Perhaps Cloudflare could remove the header?

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