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
{% 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
The right way to achieve confirmation before committing to database?

Hi All,

Basically I would like to have a confirmation from user once he has enter data and press submit button. The use case is as below:
1. User enters all the necessary data.
2. User press submit button.
3. User is presented with data he inputted and asked to confirm if he is sure about the data and if he want to confirm submission.
4.User confirms and then data is committed to db.

I am thinking about having two methods inside controller. Controller method 1 prepare and render form in step 1 and 2. Then it reroute the user to controller method 2.
CController method 2 will then process the step 3 and 4.

Is this right way to do?



https://redd.it/1j5paac
@r_php
Assert that response has element works locally, fails on GitHub Actions

All my tests work locally, but most fail on GitHub Actions:

F..FEEEEFEEEEEE...FEEEEEEEEEFFFE.EE....FF....FFEEE..EEEF.FFFFFF  63 / 125 ( 50%)
FFF.FFFFFFFFF.FF.............................................. 125 / 125 (100%)


These are all the functional tests that actually request a page.

Example:

App\Tests\SignUpControllerTest::test_page_is_only_accessible_to_guests
Failed asserting that the Response status code is 200.
HTTP/1.1 500 Internal Server Error


 public function test_page_is_only_accessible_to_guests(): void
{
exec('php bin/console doctrine:fixtures:load ' . UserFixtures::class . ' --env=test --no-interaction');

if (!self::$booted)
{
self::bootKernel();
}

/** @var KernelBrowser $browser */
$browser = self::getContainer()->get('test.client');
$browser->setServerParameters([
'HTTP_HOST' => 'localhost:8000',
'HTTPS' => false,
]);

/** @var KernelBrowser $browser */
$browser = self::getClient($browser);

$browser->request(Request::METHOD_GET, $route);

$this->assertResponseStatusCodeSame(Response::HTTP_OK);
}


Could 'HTTP_HOST' => 'localhost:8000' be the culprit? How to make this compatible with GitHub CI/CD?

https://redd.it/1j5ugri
@r_php
Feedback for my framework - Forge modular explicit framework

Hello people i want share this project that i've been working on it, its an explicit php framework without magic this is still in very heavy development but i would love to hear your feedback, the name is Forge, because i see it more like a toolkit that you can choose what you need, any type of feedback is welcome, Thanks.

\- Here is the Repo: https://github.com/forge-engine/forge

\- Documentation: https://forge-engine.github.io/

https://redd.it/1j61ec5
@r_php
Executable path

I want to start learning php but when I make a .php, it makes me edit the php.validate.executablepath, how do I edit this?

https://redd.it/1j60l18
@r_php
Is Laravel Broadcasting suitable for real-time online game?

I struggle to understand how multiplayer online games work with WebSockets. I've always thought that they keep one connection open for both sides of the communication - sending and receiving, so the latency is as minimal as possible.

However, Laravel seems to suggest sending messages via WebSockets through axios or fetch API, which is where I'm confused. Isn't creating new HTTP requests considered slow? There is a lot going on to dispatch a request, bootstrap the app etc. Doesn't it kill all the purpose of WebSocket connection, which is supposed to be almost real-time?

Is PHP a suboptimal choice for real-time multiplayer games in general? Do some other languages or technologies keep the app open in memory, so HTTP requests are not necessary? It's really confusing to me, because I haven't seen any tutorials using Broadcasting without axios or fetch.

How do I implement a game that, for example, stores my action in a database and sends it immediately to other players?

https://redd.it/1j64tak
@r_php
DAE get frustrated when searching for a Composer package for "foo" and only find "laravel-foo"?

I get that many people use Laravel, but like myself, many don't. I'd much rather use independent packages that are not wired in to illuminate or whatever. Why not make an independent package for the functionality, and then add a bridge/wrapper for Laravel? That way you can support many frameworks if you so choose.

https://redd.it/1j67jov
@r_php
Whats your approach for realtime applications on shared hosts

When it comes to realtime web applications, its always things like ReactPHP, or nodejs based websocket, or similar tools that are not really an option on shared hosts.
The next obvious thing would be SSE, but because of the usual low php process limit, this isnt an option as well if youre not the only person using the application...

So I'm curious what do others use? Is a 3rd party tool like pusher the only option?

https://redd.it/1j6eqae
@r_php
LarAgent v0.2.0 Released

Hello, Laravel devs! Just released a new version with updates:

* Support for Laravel 12
* Dynamic model setting
* New command for batch cleaning of chat histories `php artisan agent:chat:clear AgentName`

Check the release notes here:

[https://github.com/MaestroError/LarAgent/releases/tag/0.2.0](https://github.com/MaestroError/LarAgent/releases/tag/0.2.0)



https://redd.it/1j6jbmc
@r_php
🚀 Laravel 12 – The Future of Laravel? Controversy, Starter Kits & Laravel Cloud!
https://youtu.be/yDNqi2EZ2Uo

https://redd.it/1j6mxvd
@r_php
Regexp class in SPL

Anyone else ever lament that PHP doesn't have a Regexp class in its std lib (e.g. Ruby, JS) to represent a regular expression and associated flags?

Instead, we always have to deal with patterns as strings, which can be annoying:

It would be especially helpful in configuration, where there can often be something like MyConfig::$match: string that can be handled as an exact match or regex pattern. With them both as strings, we often have to resort to additional configuration, e.g. MyConfig::$exactMatch: bool. And even with that, it doesn't provide anywhere to configure regex flags.

Woudln't it be great if there were a SPL Regexp object, so we could just have MyConfig::$pattern: string|\Regexp?

Curiously, `RegexIterator` exists, but not something simpler for a single expression.

https://redd.it/1j6n2wc
@r_php
Laravel Package Directory

Ever found a useful package and wished more people knew about it? Now you can submit it to Indxs.dev, where developers explore and discover great tools.

Right now, we have three indexes:
PHP
Laravel
Filament

If you know a package that deserves a spot, go ahead and add it. Let's make it easier for devs to find the right tools!
https://indxs.dev


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