r/PHP 21h ago

Long-term university system in PHP, microservices or modular monolith, given high staff turnover?

17 Upvotes

Hi everyone,

I work for a Brazilian federal university, and we're starting to plan a new integrated system that will serve the whole university community (from teaching-related services to internal administration). Expected usage is high (many requests across several domains), and the system needs to last many years.

One challenge specific to our context: being public sector, we have high staff turnover on the dev team, so whoever joins later needs to ramp up quickly.

We were initially leaning toward microservices, mostly to keep things scalable and modular over the long run, but after reading some older threads here I'm second-guessing that. Given a small-ish team, high turnover, a long lifespan, and multiple domains, would you recommend starting with a well-structured modular monolith instead of going straight to microservices?

And if microservices do make sense for a project like this, which PHP frameworks/tools would you suggest for building the actual APIs: Laravel, Symfony, Slim, Lumen, something else?

Genuinely trying to learn from people who've been through this. Any experience, even 'don't do it', is welcome!


r/PHP 15h ago

How I used AI to migrate a 10k-line PHP 5.6 monolith to Laravel in 14 days.

Thumbnail
0 Upvotes

r/PHP 8h ago

Laravel 12 + Breeze + Spatie Permissions — Complete Role & Permission Setup

0 Upvotes

If you're working with Laravel 12 and want to implement proper roles and permissions, I put together a complete tutorial using Laravel Breeze + Spatie Laravel Permission.

In the video, I cover:

Laravel 12 + Breeze authentication setup Installing and configuring Spatie Permissions Creating Roles & Permissions Assigning permissions to users Checking roles and permissions Protecting routes with middleware Role-based access control Practical examples with Admin / Manager / Employee roles

🎥 Full tutorial: https://youtu.be/vX46YQprMho Language:Hindi

Hope this helps anyone currently implementing RBAC in Laravel.


r/PHP 7h ago

GitHub - eznix86/laravel-analytics: Data Build Tool the eloquent way

Thumbnail github.com
0 Upvotes

At work, I kept writing the same thing: a few analytics tables, a cron job to rebuild them, and the same SQL copy-pasted into three models. Change one definition, forget to update one copy, and suddenly two dashboards quietly disagree.

There’s `dbt`, which solves this problem for data teams, but it means bringing Python and a second toolchain into a Laravel project. So I tried the same idea in PHP.

An analytics model is an Eloquent model with one query on it:

```php
class Revenue extends Model implements AnalyticsModel
{
use Analytics;

public function computes(): Query
{
return $this->from(Order::class)
->where('status', '<>', 'cancelled')
->per('customer_id')
->measure('total', 'sum(amount)');
}
}
```

Then `php artisan analytics:sync` works out what depends on what and builds everything in the right order.

After that, it’s just Eloquent:

```php
Revenue::query()->where('total', '>', 1000)->get();
```

A few things it does:

* The `GROUP BY` comes from the dimensions you declare, so you never have to write them twice.
* it has Incremental, microbatch, and snapshot buildsthe, same ideas as dbt.
* Runs on PostgreSQL, MySQL, and SQLite with the same commands.

### What it does not do

Every model in a dependency chain has to use the same connection.

That means you can’t, for example, import a SQLite query directly into a PostgreSQL query. This could be solved with an import mechanism, and I am still thinking about a better way to make that work in an Eloquent-like way.

### Why not just use a query class with dependency injection?

A query class, like the action pattern in `App\Queries`, that you inject wherever you need it is perfectly fine.

If the aggregate is fast, you need live numbers, and you only have one or two of them, write the class and skip this package.

The issue is that it computes on every read and you have zero indexes.

Cache the query? Now you’re stuck dealing with stale data.

There’s another problem: each layer (CTEs, subqueries, etc.) gets re-run instead of being reused.

You can use query classes can be composable by calling each other, but a shared subquery is still recomputed inside every caller. This package composes by reference.

For example, you can have a `StgOrder` model representing a transformed version of the `Order` table. It gets built once, and the models that depend on it simply select from the finished table.

This package can append the rows that arrived since the last run, rebuild one day at a time, or keep one row per version with `valid_from` and `valid_to`.

This package will make a built table that can carry the indexes your read patterns need.

A helper like `Revenue::isStale()` can tell you when the data has passed its freshness window.

### Why not just write a job that rebuilds the table?

That’s essentially what the package does.

The difference is that the queries are reusable, and dependencies are propagated through the entire chain of downstream aggregates.

TLDR; You write reusable queries as a data person but in PHP.

Repo: https://github.com/eznix86/laravel-analytics

Read more about DBT: https://en.wikipedia.org/wiki/Data_build_tool

the real dbt guys: https://github.com/dbt-labs/dbt-core (for the curious folks)


r/PHP 4h ago

Article No more issues

Thumbnail stitcher.io
24 Upvotes

r/PHP 1h ago

Laravel Middleware in Hindi: Create, Alias & Apply to Routes

Upvotes

I’ve made a Hindi tutorial on Laravel 12 Middleware covering the complete flow from creating Middleware to applying it on routes.

In this video: • Create custom Middleware • Understand the handle() method • Register Middleware • Create Middleware aliases • Apply aliases to routes • Practical route examples

🎥 Tutorial: https://youtu.be/USOjYgaKUDk

For those learning Laravel 12, hope this helps clear up how Middleware actually works.


r/PHP 1h ago

flatbb: a free, open-source PHP forum designed to be extended by AI assistants (no framework, SQLite/MySQL, plugin marketplace)

Upvotes

Source: https://github.com/nwnuyhs/flatbb (MIT; added after the comments below asked for it)

I've just released Flatbb 0.1.5, a flat, lightweight forum written in plain PHP 8.1. MIT licensed, free.

  • No framework, no Composer, no build step. Upload, open the installer, done in 2 minutes. Runs on the cheapest shared hosting or a 1 GB VPS.
  • SQLite or MySQL 5.7+. Start on SQLite, move to MySQL later with one command.
  • Built for AI-assisted development. The repo ships CLAUDE.md / AGENTS.md and docs written for AI tools. Open the folder in Claude Code or Cursor, say "add a badge plugin", and it knows the hooks, the rules and how to publish.
  • Plugin marketplace with one-click install from the admin panel; publish your own plugin with php flatbb plugin:publish.
  • Discourse-style three-column layout, dark mode, Markdown editor with image upload, full-text search, 7 interface languages.

The interesting part is the developer story: every hook, region and API function is documented in generated Markdown, plugins are plain prefixed functions with a manifest, and the repo includes instruction files for Claude Code / Cursor / Copilot. In practice you describe a plugin in one sentence and the AI writes it, checks it (php flatbb plugin:check) and publishes it to the marketplace.

Source: https://github.com/nwnuyhs/flatbb - Download: https://www.flatbb.com/download - Plugins: https://www.flatbb.com/market

It's early (0.1.x) and I'd love feedback, bug reports and plugin ideas.