PHP Reddit – Telegram
PHP Reddit
34 subscribers
289 photos
37 videos
24.8K links
Channel to sync with /r/PHP /r/Laravel /r/Symfony. Powered by awesome @r_channels and @reddit2telegram
Download Telegram
Variable "locale" does not exist

Hi! I’m pretty new to Symfony and, although I’m in love with this language, it’s been driving me crazy for several days because of a variable that “doesn’t exist” even though I clearly defined it in my controllers. The weird part is that it doesn’t happen in all my files, and despite using AI on the side to try to figure it out, I just can’t find the issue — I’m begging you, please save me!

Here’s the situation: I have two controllers, a HomeController and a HomeAdminController. The first one works perfectly, since I can switch from English to French without any problem. BUT when I’m on the admin side — disaster! The variable suddenly “doesn’t exist” anymore, even though it’s written in plain black and white. And I just can’t switch from English to French there. That’s what really drives me crazy, because only 3 files have this issue! Not the others!!

https://redd.it/1mv8cug
@r_php
What is the best way to learn Symfony from 0 today?

Hello! I hope you are well, I have a little experience in programming but with node, some REST API, the typical... But soon they may offer me a job for newcomers who use Symfony, I like to go to places prepared so as not to have surprises. I would be very grateful if the community could give me their opinion on the best way to see this technology from scratch. I have seen good opinions about Symfonycasts but I have only found references to that page from four years ago, I don't know if it is still as recommendable today.

Thank you all very much 😊

https://redd.it/1mv9406
@r_php
Silent anonymous registration - is it possible?

Hello! I want to start a service where new web site visitors are being assigned new user id in the system silently. This way the registration form won't stop them from accessing payments and paid functionality. User may add and verify phone/email any time, if the phone/email is already registered then all the user's activity will be switched to the existing user in the database after the verification.

Switched user will be deleted from the system. Anonymous/unconfirmed users will be deleted after a month (or three) of inactivity.

Does Sympfony support this functionality?

edit: apparently it was available until 5.1 version

https://symfony.com/doc/4.4/images/anonymouswdt.png

https://github.com/symfony/symfony/discussions/48650

https://redd.it/1mvb49k
@r_php
Visual Studio Code handling of collection objects containing specific types of objects

I'm working with laravel's collections iterable objects of Illuminate\\Database\\Eloquent\\Collection which contain models. I have a function that returns a set of particular models of a particular type only, and I thought that I could use php docblocks to have vscode correctly understand what is stored in the collection, but I seem to not be getting quite what is advertised. This is the type of method definition I'm referring to:


/**
* @return \Illuminate\Database\Eloquent\Collection<App\Models\Order>
*/
function getOrders(): Collection
{
return Order::get();
}


Then elsewhere in my code, I might do:

$orders = getOrders();
foreach ($orders as $order) {
// At this line, my IDE should recognize that $order is an object of the App\Models\Order class
}


Instead of the IDE recognizing order as an Order object at the line noted, it sees it merely as an object of \Illuminate\Database\Eloquent\Model.

On the other hand, if I change my docblock to be thus:

/**
* @return \App\Models\Order[]
*/


Then things work as expected. The IDE recognizes that $order is not just a model but is an Order model specifically.

Anyone run into this and know how I can tweak my docblock so that the IDE is better aware of the collection contents at calling locations? I'm using the usual extensions in VSCode including PHP Intelephense (licensed).


https://redd.it/1mvw2o2
@r_php
How do you find Laravel Cloud performance so far?

So I've been building my new app, and I shipped it on Cloud.

Since I wanted to avoid JS framework, it's using Blade and Alpine Ajax. Most pages are under < 20kb and the biggest one is 120kb.

Nightwatch tells me that the duration of the requests are between 1.71ms and 1.71s.

While I have those metrics, switching from one page to another feels really slow - Chrome tells me that a page loads between 1 - 2s. I think I've optimized the s**t ouf of the queries, added cache almost everywhere, and the biggest page has 9 queries which run in less than 30ms. Perhaps I could do something else, but I wouldn't know what - this is not the topic of this post though.

I would like to know if others in the community who doesn't rely on Vue or React have this perceived notion of slowness as well. Thanks community!

https://redd.it/1mvxbvg
@r_php
deploy a php solution on customer's server

hi,

one customer, want to host the developed php solution on their server - they have use-only license.

how can i protect the source code on that server?

what i am looking for is a way to prevent them to change the code and for us to be able to prevent them for further usage if for example the payments stop.


thanks.

https://redd.it/1mw4gn1
@r_php
"Lambo PHP devs" what are you using?

Hi all,

I heard often phrases like "node js devs are unemployed and php devs drive lambos".
What are these lambo php devs using most of the time? Vanilla php? Wordpress? Drupal? Laravel? Symfony?

https://redd.it/1mw6zxx
@r_php
Has anyone integrated Dodo Payments with Laravel?

I’m trying to integrate Dodo Payments into my Laravel 12 project.

I installed their PHP SDK but I’m running into a syntax error (@ related) when I try to use it. I couldn’t find any Laravel-specific tutorial or video for Dodo Payments integration—only general PHP or Node.js examples.

👉 Has anyone here successfully integrated Dodo Payments with Laravel?

Did you use their PHP SDK directly or a Laravel package?

Any example code, blog, or tutorial you can point me to?

How did you handle subnoscriptions and webhooks in Laravel?


Any help (or even just pointing me to the right resources) would be super appreciated.


https://redd.it/1mwe8k2
@r_php
Keycloak + Symfony (KnpU OAuth2Client) users getting logged out after ~30–60 minutes despite long session settings

I'm integrating Keycloak with a Symfony app using knpuniversity/oauth2-client-bundle and a custom authenticator. The flow works fine, but my users (and myself) are getting logged out after about 30–60 minutes, even though I've configured long session lifetimes in Keycloak and Symfony.

---

### Environment

Symfony 7
KnpU OAuth2ClientBundle
Keycloak (latest, running in Docker)

---

### Symfony `security.yaml` (relevant parts)

```yaml
firewalls:
main:
lazy: true
provider: app_user_provider
custom_authenticator:
- App\Security\AdminFormAuthenticator
- App\Security\KeycloakAuthenticator
entry_point: App\Security\AdminFormAuthenticator
logout:
path: app_logout
target: app_home
remember_me:
secret: '%kernel.secret%'
lifetime: 2592000 # 30 days
path: /
always_remember_me: true
```

I also store the refresh token in session and use it to refresh the access token when needed:

```php
if (!$request->query->has('code') && $session->has('refresh_token')) {
$accessToken = $this->refreshAccessToken($client, $session->get('refresh_token'));
} else {
$accessToken = $this->fetchAccessToken($client);
}
```

---

### Keycloak session/token settings

SSO Session Idle: 30 days
SSO Session Max: 10 days
Client Session Idle: 30 days
Client Session Max: 10 minutes (?? maybe suspicious?)
Offline Session Idle: 30 days
Access Token Lifespan: 15 days
Refresh Token lifespan: refresh disabled (default)
Login timeout: 30 minutes

Screenshots from KC settings:
- [Image 1](
https://i.sstatic.net/fzTV9bz6.png)
- [Image 2](
https://i.sstatic.net/la6nYY9F.png)
- [Image 3](
https://i.sstatic.net/9QQTJbCK.png)

---

### The problem

Despite these "long" settings, sessions actually expire and users get logged out after about 30–60 minutes. Reports from users match what I've also experienced.

It looks like either:

Keycloak is expiring client sessions early (e.g. because of the 10 min Client Session Max?), or
Symfony is not persisting/refreshing tokens properly, or
My remember_me config doesn’t interact correctly with OAuth2.

---

### My question

What is the likely cause of users being logged out after 30–60 minutes?

Is this due to Keycloak's Client Session Max = 10 minutes overriding the longer SSO Session Idle/Max?
Do I need to explicitly enable refresh tokens in Keycloak and adjust their lifespan?
Is my Symfony `remember_me` irrelevant here because OAuth2 tokens control session duration?
What's the recommended setup so Keycloak + Symfony sessions last ~days or weeks, not 30 minutes?

Any insight into how these Keycloak session settings interact with Symfony's session + refresh token logic would be appreciated.

https://redd.it/1mx0u6r
@r_php
With PHP8.5 we'll get Error Backtraces V2 on Fatal Errors
https://wiki.php.net/rfc/error_backtraces_v2

https://redd.it/1mx1q54
@r_php
Facade Maker

Speed up facade creation in Laravel with Facade Maker.
Generate facades and services instantly, keeping your app structure clean and consistent.

Try it here: https://laravel-hub.com/package/facade-maker

https://redd.it/1mxcke4
@r_php
VSCode setup recommended extensions

Hi everyone,
I'm currently working/learning PHP in my work place and I'm looking at the setup or VSCode extension for PHP. What are the essential extension for PHP in VSCode? Also, I'm beginner in PHP in general so I appreciate any suggestion. The project is in PHP Laravel though I think it doesn't matter. Thank you in advance .

https://redd.it/1mxi09q
@r_php
$SESSION array does not work from a subdomain.

Hi, everybody!

I have the following situation. A web page is in a subdirectory of my domain:

[`
https://myowndomain.com/app`](https://myowndomain.com/app)

And it works fine.

Now, a subdomain was made in another domain that points to the previously mentioned web page:

`
https://app.farawaydom.com -> https://myowndomain.com/app`

Works fine except that the $\
SESSION array is null when accessed from app.farawaydom.com .

Is there any solution to this issue?

Thank you in advance.

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