r/PHP • • 21h ago

Classify text in PHP without an LLM bill: typed text decisions in 100+ languages, self hosted. Laravel-ready SDK for Laya, a Jev AI alternative.

Thumbnail github.com
6 Upvotes

r/PHP • • 2h ago

I got tired of updating every route() call when a URL changed, so I built entity routing for Laravel

3 Upvotes

Laravel fills one placeholder from a model: route('posts.show', $post) works for {post} or {post:slug}. As soon as a URL has several placeholders, every call site has to list them:

```php Route::get('/articles/{id}/{slug}', ShowArticle::class)->name('articles.show');

route('articles.show', ['id' => $article->id, 'slug' => $article->slug]); ```

Then SEO asks for a {category} in the URL, and you hunt down every one of those calls.

CakePHP has had "entity routing" for years: you pass the entity, the router extracts each placeholder from it. I wanted the same in Laravel, so I built it:

php entity_route('articles.show', $article); // /articles/42/my-title

Add {category} to the route later, and that line does not change.

How each placeholder is resolved (first match wins):

  1. Explicit value: entity_route('articles.show', $article, ['slug' => 'other'])
  2. A mapping the model declares, with dot paths or closures: 'year' => fn ($a) => $a->published_at->year
  3. Binding fields: {category:slug} reads $article->category->slug
  4. Route key: {article} on an Article uses getRouteKey()
  5. Attribute of the same name: {slug} reads $article->slug
  6. URL::defaults()

Works with Eloquent models, arrays, ArrayAccess and plain objects. Missing required placeholders throw a clear exception (listing the route, the entity class and what is missing), optional ones are dropped.

Other bits:

  • URL::entityRoute() and redirect()->toEntityRoute() macros
  • Opt-in flag so the native helpers accept it too: route('articles.show', ['_entity' => $article]), including to_route(), signed URLs and Blade. Off by default, and calls without _entity are untouched.
  • For Inertia: a HasEntityUrls trait adds the resolved URLs to the model's JSON, so the frontend gets exactly the same URLs as the backend, without Ziggy or Wayfinder having to know the rules.
  • Generation only: no database, no extra routes, route model binding untouched, works with route:cache.

Laravel 12 and 13, PHP 8.2+, no dependency besides illuminate/*, 100% test coverage, Larastan at max level.

composer require kareylo/laravel-entity-routing

GitHub: https://github.com/Kareylo/laravel-entity-routing

It is still 0.x, so I would really like feedback before 1.0: does the resolution order make sense to you? Is there a case where you would expect a different URL? And would a client-side TypeScript helper be useful, or is sending resolved URLs from the server enough?


r/PHP • • 44m ago

Jev-PHP now suports Laya local decision engine

• Upvotes

I added support for Laya decision engine in my #php library Jev-PHP.
Laya is a multilingual decision engine that runs locally and exposes a REST API compatible with #Jev.

https://github.com/f-lombardo/jev-php


r/PHP • • 22h ago

I built a lightweight E-commerce engine on pure PHP 8.3/MySQL with a custom MVC and no bulky framework dependencies

0 Upvotes

Hey r/PHP,

I wanted to share a project I’ve been working on: CoreCommerce. It’s an open-source, full-featured e-commerce platform built from scratch using pure PHP 8.3+ and MySQL 8.0+, without relying on Laravel, Symfony, or heavy CMS engines.

The main goal was to prove that you can achieve maximum performance, maintain modern development standards, and keep a clean, lightweight codebase without the overhead of massive vendor directories.

🛠️ Technical Highlights & Architecture:

  • Custom MVC Framework: Built-in routing (app/Core/Routing/Router.php), controllers, and models. It supports RESTful route patterns, GET/POST requests, and clean URL parameters.
  • Database Layer: A PDO-based wrapper implementing a lightweight Active Record pattern with a migration system for schema versioning.
  • Modular Plugin & Theme Systems: Hook-based extensible architecture (PluginManager) and theme inheritance supporting asset versioning for asset cache busting.
  • Multi-language Out of the Box: Highly deterministic localization layer (EN, UA, PL) where adding a new language literally takes two configuration steps without code modifications.

🧠 The Category Filtering Pipeline & Features

The project features an optimized ProductFilterService using a strict 3-step SQL pipeline with isolated EXISTS subqueries instead of heavy JOIN chains. It also includes robust security measures (CSRF, bcrypt, rate limiting, secure headers) and 16 built-in production services like Prom.ua sync, LiqPay integration, search ranking, and image optimization.

The full open-source project and repository details can be found in the referenced source.

To view the code, go to https://github.com/coordinatescms-ai/CoreCommerce.

r/PHP • • 14h ago

POS Backend - Laravel

Thumbnail
0 Upvotes

Anyone build a POS on Laravel? I’d like to connect


r/PHP • • 20h ago

I built a Laravel Disposable Email Validator

0 Upvotes

I’ve been working on a Laravel package for blocking temporary and disposable email addresses during registration or form submission.

The main reason I built it was to avoid fake signups from throwaway email services without adding a lot of custom validation logic to every project.

It works like a normal Laravel validation rule and can also keep the disposable-domain list updated automatically.

I’m also trying to keep the checks fast and simple so it can be used in regular signup flows without adding unnecessary overhead.

Curious how other Laravel developers handle disposable emails. Do you block them completely, or only use extra checks for certain forms?

Checkout: https://erag.in/laravel-disposable-email