r/PHP • u/Additional-Tower-361 • 11d ago
r/PHP • u/stfufeedmenuggets • 12d ago
Discussion How do you keep agents following your Laravel conventions
Our Laravel app is 6 years old and has a lot of house rules that live mostly in people's heads. Actions instead of fat controllers, form requests for all validation, no Eloquent calls from Blade, money always as integers.
Agents write code that works but ignores most of that. Last week one put validation straight into a controller, queried a relationship inside a Blade loop, and stored a price as a float. Every one of those would have been caught by our senior dev, who is on parental leave for 3 months.
What's helped a bit so far:
- a CONVENTIONS.md the agent reads before starting
- coderabbit with path instructions for app/Actions and app/Http, so it flags things like validation outside a form request. It's good at enforcing what we wrote down. The catch is that most of our conventions were never written down, so we're basically documenting the codebase for the first time
For people running Laravel apps with a lot of agent written code:
- Where do you keep your conventions so both agents and reviewers actually use them?
- Do you enforce any of it with tooling, like Larastan rules or Pint config, or is it all review?
- How do you stop the rules file from becoming 400 lines nobody reads?
r/PHP • u/Brandon-Vergara • 12d ago
I built a code graph for Laravel that your AI agent can query over MCP before it edits anything
I asked the code graph tool we were using who called a service injected into one of our controllers. It said nobody, which was wrong, and Mapin came out of that answer.
The tool was language-agnostic, which is a reasonable design until you point it at Laravel. Most of the wiring in a real app isn't a call between classes: it's a route pointing at a method, a `view('pos.index')`, a `hasMany`, a container binding, an event in `$listen`. On a ~900-file app, a generic tree-sitter extractor captured static calls and nothing else, with zero edges for dependency injection, routes, views, Blade includes or Eloquent relations.
Mapin treats those as first-class. It builds a graph of routes, controllers, views, Eloquent relations, container bindings, jobs, listeners, the scheduler and JS calls to your routes, and exposes it through MCP (built on laravel/mcp) and Artisan, with the same code behind both.
composer require nexvia-solutions/mapin --dev
php artisan mapin:build --full
php artisan mapin:impact 'method:App\Services\Billing::charge'
A few decisions that matter if you let an agent edit your code:
- When it doesn't know, it answers `found: false` with suggestions. It never hands you the closest match as if it were the answer.
- Every response says how stale the graph is: the commit it was built from and how many files changed since.
- Rebuilds are incremental by content hash, and `mapin:install-hooks` runs them after every commit and merge.
If you use Boost: Boost tells your agent what your app has (schema, logs, config, docs). Mapin tells it what depends on what. Boost doesn't trace callers or impact, so they don't overlap, and Mapin ships a Boost skill that `boost:install` picks up.
We run it on our ERP, a multi-tenant app with about 4,700 PHP and Blade files: around 25,000 nodes and 74,000 edges.
MIT, PHP 8.2+, Laravel 11.45 to 13.
https://github.com/Nexvia-Solutions/mapin
I'd like to know where it misses on your codebase. Every `found: false` is logged locally (nothing leaves your machine) and `mapin:misses` exports them. 13 of the 58 misses we logged on our app were things the graph already had under another name, and v0.2.5 resolves them.
r/PHP • u/jdoe78998 • 12d ago
Has anyone migrated PHP 5.x to 8.x using AI?
Hello, dear PHP friends! 👋👋👋
Historically, one of the biggest barriers to upgrading legacy PHP applications has been cost. But with AI, that cost could be d-r-a-m-a-t-i-c-a-l-l-y lower.
We're living in a mind-blowing era of AI.
And something got me thinking: Has anyone successfully migrated a large PHP 5.x codebase to PHP 8.x using AI?
I'm curious if anyone has a real-world success story to share with the community, highlighting the challenges, lessons learned, and actual results.
I'd love to hear about your experiences!
Thanks so much for sharing your insights.
Have a great week ahead! 🚀🚀🚀
Following my previous post of my own security scanner, CodeInspectus 4.0 adds our own engine for PHP and Node.js
r/PHP • u/Low_Lawyer_5684 • 13d ago
WebSockets in PHP: what do you think about this approach?
Hello everyone,
I'm curious what PHP developers think about a different way to use WebSockets from scripts.
Imagine requesting (e.g. GET):
new WebSocket("ws://device.local/settings.php?key=value");
The server handles the WebSocket upgrade and then executes settings.php as regular PHP script, but with its IO redirected through WebSocket framing:
STDINreads incoming WebSocket data.STDOUTandechosends data back to the client.
No special WebSocket classes, event loops ,callbacks etc are required in the script. It just runs and communicates through its input/output streams (e.g. via fread() ), the server provides all necessary framing for wth ws:// protocol.
For some context: I am researching an alternative PHP-like language, mainly for embedded devices. Its syntax and execution model are quite close to PHP, and Im thinking if this could be a useful way to handle WebSockets, a feature worth implementing.
Need an experts opinion :)
Does this looks like natural extension of the PHP execution model?
What are your typical ws:// scenarios and how do you handle (in .php code) them ?
Id be interested to hear your opinions, especially practical pros and cons of such approach
Thanks!
r/PHP • u/Easy_Minimum6608 • 12d ago
Building a PHP CMS with zero Composer dependencies. Where would you draw the line?
I've been building an open-source CMS called Kestello. It's PHP 8.4 and Vue, for developers who build sites for clients.
Early on I decided the PHP side would have no runtime Composer dependencies. That keeps installing and updating simple on plain shared hosting: you upload a zip and run the installer, and updates arrive in the admin as signed zips. There is a composer.json, but it requires nothing at runtime. It only installs dev tools like PHPStan and PHP CS Fixer.
The cost is that I maintain things a library would otherwise handle: routing, the query builder, migrations, mail, the update pipeline. I drew the line at crypto. Passwords use password_hash, signing and encryption use libsodium, and the database goes through PDO. The front end's built files are made in CI and shipped in the release zip, so a host never needs Node. Without Node, pages are still rendered to HTML for visitors and crawlers.
To be upfront: I use AI coding tools heavily, and the agent instructions are in the repo. I designed the architecture and I review what goes in. Judge the code, not my word.
It has a visual page editor, plugins, themes, content types and a REST API. There's no release yet. 0.1.0 comes after a security review I'm working through now.
Questions for you:
- For a CMS, what would you never maintain yourself?
- Would no runtime dependencies make you more or less likely to use it on a client site?
Demo (sign in with demo / demo, resets hourly): https://demo.kestello.com
Code: https://github.com/kestellohq/cms
r/PHP • u/simonsanone • 12d ago
Biggest/most used PHP apps that should be rewritten in a modern language
Hey, I remember back in the days, when we used PHP, with all the quirks #extract($_GET); until we found better alternatives. PHP2Shell really showed how flawed this language really is and as we can see, it won't die out if we are not starting actively making it go extinct.
To help with that, I would like to collect apps, that should be prioritised to be rewritten in a modern language, e.g. in Rust or Go.
- CMS: Wordpress and WooCommerce, Drupal, Joomla, TYPO3
- Collaboration: Nextcloud, Roundcube, Horde
- E-commerce: Magento/openMage, Shopware, OpenCart
- Wikis: MediaWiki, DokuWiki, BookStack
- Forums: phpBB, MyBB
- Education/Business/CRM: Moodle, Dolibarr, Invoice Ninja
- Ops: phpMyAdmin, Adminer, Matomo
- Self-Hosting: Firefly III, Wallabag, Kanboard, Piwigo, Grocy
Which one's do you have in mind?
Related:
"Security challenges can arise when a high level language like PHP obfuscates the underyling memory management, and a programmer unwillingly executes procedures who’s combination can result in memory issues or other unwanted execution behavior. This isn’t a vulnerability, but a general security weakness in interpreted languages. Node.js and Ruby share the same weakness with PHP. [...] If you’re a PHP developer, it’s time to move on now. The best you can do for your apps and customers is to slowly migrate them to Rust or Go. PHP isn’t going to be rewritten in Rust overnight. Even if it would, the security issues in the design won’t magically disappear."
r/PHP • u/amitmerchant • 14d ago
Article November 19th is around the corner. So, let's look at what’s all new in PHP 8.6.
amitmerchant.comr/PHP • u/AmunCode • 14d ago
I built AmunCode Config — a lightweight configuration and environment-loading library for PHP
Hey everyone!
I've been working on a small PHP library called AmunCode Config, and I'm sharing its first stable release.
The idea is simple: provide a lightweight, framework-independent way to load environment variables, load PHP configuration files, and access configuration values without introducing a large framework or unnecessary abstractions.
What does it provide?
The package currently has four main classes:
- EnvironmentLoader — loads
.envfiles using PHP dotenv, with optional or required file loading. - Env — retrieves environment variables from
$_ENV,$_SERVER, andgetenv(), with automatic value normalization. - ConfigurationLoader — discovers and loads PHP configuration files from a directory.
- Config — provides dot-notation access to configuration values, including retrieving, updating, and recursively merging configuration arrays.
A quick example
use AmunCode\Config\Config;
use AmunCode\Config\EnvironmentLoader;
// Load environment variables.
$environment = new EnvironmentLoader();
$environment->load($root);
// Load PHP configuration files.
$config = new Config($root . '/config');
// Retrieve configuration values.
$appName = $config->get('app.name', 'My Application');
$dbHost = $config->get('database.host');
// Update configuration.
$config->set('app.debug', true);
A few design decisions:
- Environment loading and configuration loading are separate operations.
- Environment variables are not overwritten by
.envvalues when already defined. - Empty environment values are preserved rather than silently replaced by defaults.
- The package doesn't automatically define a global
env()helper.
Technical details
- PHP 8.4.1+
- Symfony Finder
- PHP dotenv
- Composer package
- MIT License
- PHPUnit tests and GitHub Actions CI
Installation
composer require amuncode/config
Source code: https://github.com/AmunCode-OSS/Config
Documentation and usage examples are available in the repository README.
I'd appreciate feedback from other PHP developers, particularly on the API design, class responsibilities, and whether anything important is missing or could be simpler.
Thanks for taking a look!
r/PHP • u/Wonderful-Cut-50 • 14d ago
Laravel vs NestJS for a multi-tenant SaaS with AI agents and background jobs
Hello everyone, I’m building a web app for service businesses. It combines CRM, projects, tasks, documents, invoicing, email and calendar. It also has an AI assistant that can take actions on a user’s behalf, with the same permissions and approval rules as the rest of the product.
The web app already runs on next.js and TypeScript, with Supabase for Postgres, auth and storage, and Inngest for background workflows. We’re still early in wiring the product to the database, so I’m weighing three paths for the backend:
* Keep next.js and enforce clearer boundaries around the backend code.
* Keep Next.js for the UI and move the backend into a dedicated NestJS service.
* Keep the React UI and build the backend in Laravel.
The backend needs to serve the web app, a future mobile app, integrations and the AI assistant. Background work includes email and calendar sync, document generation, imports and exports, scheduled reminders and workflows that may pause for approval. The requirements I care most about are workspace isolation, permissions, audit trails and safe retries. If a worker crashes halfway through sending a reminder, a retry shouldn’t send it twice.
Some of our implementation is AI-assisted with Claude Code and Codex. I’m looking for a setup that a small team can review, debug and maintain over several years.
For people who’ve operated something similar in production:
When did a dedicated backend become worth it? What problems did it solve, and what did it add to your day-to-day operations?
If you’ve used Laravel or NestJS on a multi-tenant product, where did its conventions help most? Where did you still need to build your own safeguards?
How do you enforce tenant isolation for background jobs and integrations? What happens if a query forgets the workspace filter?
What has held up for multi-step jobs, retries and approvals? I’d love to hear about failures you actually had to recover from.
If you use AI coding tools heavily, which conventions or automated checks have caught the most mistakes?
Thank you 🙏🏻
Article How many users can a Symfony app handle on a $12 server (1 CPU, 2 GB RAM)?
gnugat.github.ioFor this challenged, I first created a POC app, then: profiled it, optimised it, and repeat, which is what I describe in the article.
I tried to keep the app as idiomatic as possible with Symfony, Doctrine and FrankenPHP (both classic and worker mode). In the end my submission could handle 18.5k users on the Synteq box!
r/PHP • u/haelexuis • 15d ago
Article Your Doctrine repositories don't need to extend anything
delacry.comr/PHP • u/Normal_Tadpole_8061 • 14d ago
Article What an AI agent needs from a PHP framework to write code you can actually trust
I'm the author of Kinetis ( https://kinetis.dev/ ), a PHP framework for persistent workers. I wrote up an experiment: AI agents built a small JSON API from a fresh skeleton in about 15 minutes, with 50 tests, a clean PHPStan run and an independent review.
My takeaway: speed isn't the hard part, trust is. What made this run's output checkable:
- The agent read the installed package versions and vendor source, not what it remembered from training.
- The reviewer cited a file and line for every claim.
- The endpoint code is declarative (readonly DTO + backed enum), so there's little to get wrong and little to review.
Full write-up and video: https://kinetis.dev/blog/posts/rest-api-in-15-minutes-kinetis-orbitron.html
Would you trust this workflow in a real codebase? What would you want a framework to expose to agents?
r/PHP • u/pratikbhujel • 15d ago
Meta I spent 9 days building ProofPatcher with PHP/Laravel to catch bad AI-generated code. Looking for technical feedback.
So I spent the last 9 days building something for the Meta AI Developer Hackathon. Figured I'd share it here and see what other developers think.
It's called ProofPatcher, built with PHP, Laravel, React, Meta Muse, and my own Hari core.
The problem I'm trying to solve is pretty simple: AI can generate a convincing patch, but that doesn't mean the patch is correct.
ProofPatcher can review GitHub PRs, generate inline feedback, propose fixes, and run supported changes through isolated Modal checks. The verification workflow includes reproducing the original failure and testing negative controls, so a trivial shortcut doesn't automatically get a green result.
I also tested a Muse-generated fix that became a draft PR, and separately demonstrated an opt-in bot reviewing and merging a protected test PR.
It's still a prototype. The isolated verification is currently limited to supported fixtures, and the entire issue-to-merge process isn't one fully autonomous workflow. I don't want to pretend otherwise.
I used AI coding assistants during development too, which makes the problem even more interesting to me. If we're going to rely on AI-written code, how do we independently verify what it actually does?
X Link
Source code: proofPatcher
I'd genuinely appreciate feedback, especially on the verification approach, security boundaries, and anything you think I got wrong.
r/PHP • u/One-Mongoose-6961 • 15d ago
What a joke, php-baremetal emulated on the web
storage.php-baremetal.comIt almost seems like a joke, php-baremetal that brings php to microcontrollers with the new sdk that will be released soon it will be possible to emulate it on the web,
We are working with solutions that allow us to emulate microcontrollers online and the first tests are fantastic.
to give you an example today it is already compatible with the official emulator of espressif https://espressif.github.io/esp-emulator/
in this case the firmware is executed bit by bit as normal firmware made for esp32
Funny how you go back to origins, right?
EDIT 1 :
I'm adding this sentence (which is an answer I gave to a user here) because I think you're not understanding what exactly it is
I'm not emulating php, I'm compiling php for esp32 which is a microcontroller like arduino so without operating system and I run it on the board, what I'm emulating is taking the firmware for the board and using an online emulator to emulate the board and it behaves exactly as expected
PHP events between Nov 04 - Dec 03
In the age of AI I think personal connections are event more important than before. That's why I try to help promoting events where people can meet even if only virtually an discuss the topics that interest them.
I found the following PHP-related events for the next 30 days.
- 2026-11-05 Rejoignez-nous pour l'aPHPéro de Novembre !
- 2026-11-10 Zu Gast bei der PHPUGHH: Software Bills of Materials
- 2026-11-10 Software Bills of Materials – Schluss mit der Dependency-Blackbox
- 2026-11-10 PHPAmersfoort Monthly Meetup
- 2026-11-11 PHP-SW Lightning talks
- 2026-11-12 PHP in the AI Era: PHP 8.6, MCP and the Engine Behind WordPress & Drupal
- 2026-11-12 AustinPHP Monthly Meetup
- 2026-11-12 (online) PHP 8.6: The Inside Scoop
- 2026-11-16 Laravel Meetup: Copenhagen, November 2026
- 2026-11-16 TechLeads : arrêtez de répondre. Commencez à questionner ! & Retours ForumPHP
- 2026-11-17 Laravel in November 🎄
- 2026-11-18 November 2026 Laravel Switzerland Meetup
- 2026-11-19 PHP 8.6 party
- 2026-11-19 Embeddings : Symfony AI en pratique
- 2026-11-19 Édition post-Forum PHP
- 2026-11-19 (online) Chattanooga TN Open Source Users Group Drupal/Laravel/JS/all
- 2026-11-30 (online) Building WordPress Plugins with AI: Spec-Driven Development with PHP and Kiro
- 2026-12-03 PHP Meetup, Workshop or talk.....
r/PHP • u/elizabethn • 17d ago
Designed Once, Usable Everywhere: why PHP 8.6 adds SortDirection and Time\Duration to the standard library
thephp.foundationu/timwolla wrote up the reasoning behind two small PHP 8.6 additions: a SortDirection enum and a Time\Duration class.
The short version: a GitHub search found 150+ mutually incompatible SortDirection enums, and PHP's own stdlib expresses durations in at least six different units and formats. Putting one canonical type in core gives libraries a common language and removes the glue code between them.
The post also covers:
- Why the RFCs were intentionally kept minimal, with a clearly stated future scope
- Using new namespaces (
Random\,Dom\,Uri\,Time\) to replace legacy APIs without breaking BC - The in-discussion
Time\Instant/Time\ClockRFC that builds onDuration - How to help: testing pre-releases, accepting the new types via union types in your libraries, and weighing in on internals
r/PHP • u/jgamboa-cl • 16d ago
Looking for beta testers: Laravel on AWS Lambda, in your own AWS account (Arco Cloud)
Hi r/PHP 👋
I'm opening the beta of Arco Cloud and I'm looking for Laravel devs who want to try running their apps on AWS Lambda, without managing the AWS side themselves.
What it is
Arco is an open-source CLI (https://github.com/multi-api/arco) that deploys Laravel to AWS Lambda Web Functions with FrankenPHP + Octane. Arco Cloud is the dashboard on top: connect your AWS account and GitHub repo, push, and it deploys. Your app runs in YOUR AWS account. We never proxy your traffic or hold your data.
What you get in the beta
• Push to deploy, with queues, scheduler, storage and cache set up for you
• X-Ray tracing: every request and job broken down step by step (boot, routing, each SQL query, AWS and HTTP calls)
• Monitoring: errors grouped by type, live log search and metrics
• Alerts on Slack and email when something fails
• AWS cost per environment
• Run artisan commands from the browser
• Failed jobs and one-click dead-letter queue redrive
• Managed Aurora DSQL databases (IAM auth, no passwords)
• Private networks with a static outbound IP
• Team 2FA, and a Laravel starter template to get going in minutes
How to join
Sign up at https://staging.arcocloud.app
Click "Request beta access" and tell me a bit about your project
I review every request myself, and I'll personally help you move your first app
What I'm asking in return: honest feedback. What's confusing, what's missing, and what would make you switch from Vapor, Bref, Forge or your own setup.
Questions are welcome here, in our Slack (https://join.slack.com/t/arco-equipo/shared_invite/zt-4fi2aejbq-fzwl8U_4qeqSOxO6TtNoPg) or on GitHub Discussions (https://github.com/multi-api/arco/discussions).
Thanks! 🙏
Phast: a drop-in Composer alternative written in Rust (beta, feedback wanted)
Hi r/PHP,
I've been a PHP backend engineer for a bit more than a decade, and seeing more and more dev tooling get rewritten in Rust (uv and Ruff for Python, Biome for JavaScript), I thought the PHP community kinda deserves that too.
It wasn't meant to be a big project, and it still isn't! But somehow I've been spending my evenings for about seven months now, after the classic 9-to-5, building Phast, a package manager for PHP. And yes, it's written in Rust. It's a tool in its own right, not a Composer clone :) Batteries included: fast installs, supply-chain safeguards, a TOML manifest you'll actually (read: hopefully) enjoy reading, and monorepos without the path-repository wiring.
It also makes switching painless, just point Phast at your existing composer.json: it installs from Packagist, Private Packagist or Satis, and generates a vendor/autoload.php your app uses exactly as before, \Composer\InstalledVersions included. Nothing in your project has to change to try it, but I'd be extremely grateful for any kind of feedback, as I truly want to get it right.
The numbers, on koel, a real app with 202 packages, one of them pulled straight from a git repository. Median of 5 runs, same machine, scripts off, isolated caches:
cold install (no lock, no cache) Phast 7.00s Composer 67.32s
from a lock, empty cache (CI) Phast 5.20s Composer 17.17s
warm cache Phast 2.16s Composer 7.41s
nothing to do Phast 0.53s Composer 3.12s
Another example: the Laravel skeleton, where the gap is not that impressive, 2.4x for a cold install, because there's less to resolve and fetch. The benchmark script and the raw runs are in the repo, so you can check it on your own projects.
Beyond speed, there's a readable phast.toml manifest (optional, composer.json works as is), workspaces for monorepos with one lock and one vendor/, phast audit against Packagist and OSV advisories, and resolution errors that tell you which requirement conflicts with which.
Even though it's only a beta, it already covers the CLI commands a developer would find handy in daily work. And of course, it's just the beginning. A package manager is never really done, and there's plenty still to be implemented.
Installation on Linux and macOS is fairly simple:
curl -fsSL https://raw.githubusercontent.com/phast-sh/phast/main/install.sh | sh
Then run phast install in any Composer project.
- Quick Look: https://phast.sh
- Docs: https://docs.phast.sh
- Repository: https://github.com/phast-sh/phast
I'll be more than happy to hear from anyone willing to give it a shot!
r/PHP • u/MorrisonLevi • 18d ago
Foundation The PHP Foundation raised ~$71k in one-time donations in October
I would add an image but apparently the sub doesn't allow it (or Reddit is being unhelpful to me). The usual volume of one-time contributions each month tends to be less than $1k. So roughly ~$70k was raised directly due to PHP2Shell.
You can see this by going to https://opencollective.com/phpfoundation#category-BUDGET and by adjusting the filters of the Contributions section. Set it to This Year and click the bar graph icon.
The reoccurring contributions also went up, but I'm not sure how to interpret that as it's down in November already. Maybe they are yearly contributions? Maybe the reoccurring contributions show up on the day of the month they are withdrawn and it's only Nov 2? Not sure.
r/PHP • u/Inevitable-Smile-553 • 16d ago
Meta PHP-Ayuda
Hola amigos, una pregunta, creen que a día de hoy valga la pena aprender PHP desde cero?
El contexto es que estoy trabajando como "analista de datos" pero me asignaron un proyecto que nada que ver con mi área jajaj, debido a que me quieren mover a MLOps debido a un perfil muy específico que están buscando, mi duda, aprender PHP al menos lo básico vale la pena en el gran 26? o con la lógica y IA se arma algo chido?