PHP

· Lars Nielsen

API Platform Returned an IRI Instead of the Object, and Saving the Form Cleared the Owner

In CaRMen, my CRM, every deal has an owner and every activity has an assignee: a user. For a while the deal list showed "-" in the Owner column for every deal, which looked like a display bug. It was worse than that. Opening a deal and saving it, without touching the owner field, removed the owner from the deal. The same happened to an activity's assignee.

Read article API Platform Returned an IRI Instead of the Object, and Saving the Form Cleared the Owner
· Lars Nielsen

API Platform 4 Dropped the hydra: Prefix, and Every List in My CRM Went Empty

I run a small CRM for myself called CaRMen — a Symfony 7 API Platform backend with a React frontend. In August I had to bump api-platform/core from ^3.3 to ^4.0, not because I wanted the new major version, but because composer's own security-advisory audit flagged every 3.3.x and 3.4.x release in a row. There was no patched 3.x left to stay on.

Read article API Platform 4 Dropped the hydra: Prefix, and Every List in My CRM Went Empty
· Lars Nielsen

Symfony Login Throttling Behind a Reverse Proxy: Without trusted_proxies, Everyone Shares One IP

CaRMen, the CRM I built for myself, now runs as two public sites: the real instance and a demo. Public means bots find the login endpoint within hours, so in October I added rate limiting to logins and to password-reset emails. The limits themselves took a few lines of Symfony configuration.

Read article Symfony Login Throttling Behind a Reverse Proxy: Without trusted_proxies, Everyone Shares One IP
· Lars Nielsen

Doctrine proxies are going away: PHP 8.4 lazy objects explained

If you have ever wondered why Doctrine entities cannot be final, this is the article that answers it. And the answer stops being true in PHP 8.4.

This is the largest change in the Symfony 8 and Doctrine 4 move, and it is not really a framework change at all. It is a PHP language feature removing the need for a fifteen-year-old workaround.

Read article Doctrine proxies are going away: PHP 8.4 lazy objects explained
· Lars Nielsen

Dependency inversion in Symfony: what autowiring made easy, and what it made optional

Autowiring is one of the better things to happen to PHP. Typehint a class in a constructor, and Symfony finds it, builds it, and hands it over. No configuration, no factory, no container gymnastics. A generation of PHP developers now writes dependency injection without ever thinking about it, which is exactly what good tooling should achieve.

Read article Dependency inversion in Symfony: what autowiring made easy, and what it made optional
· Lars Nielsen

Provisioning a PHP web server with Ansible: MySQL, PHP-FPM, nginx and Let's Encrypt

Four packages, one playbook. This should be a boring afternoon, and it mostly is — except for one ordering problem that breaks almost every tutorial on the subject, in a way that only shows up on a genuinely fresh server.

So let me start there, because if you understand it the rest is just YAML.

Read article Provisioning a PHP web server with Ansible: MySQL, PHP-FPM, nginx and Let's Encrypt
Subscribe to PHP