Who it is forA PHP developer whose code calls a classifier and whose CI pipeline should not depend on a model server.
The problemTests that call a live model server are slow, flaky and need extra infrastructure to run in CI.
The outcomeTests run on any machine with PHP and Composer, and they check how your code handles each typed answer.
What you need first
- PHP 8.4+ and Composer
- A PSR-18 HTTP client such as Guzzle or Symfony HttpClient
- Docker, to run laya-serve from the repo's compose.yaml
- Laravel 13+ for the Laravel steps (service provider, artisan commands, validation rule, cast)
Steps
- Run
composer require marcreichel/laya-phpin your project. - Open
examples/05-testing-with-fake.phpin the cloned repo to see how the fake is set up. - Run
php examples/05-testing-with-fake.phpto confirm it works without a server. (inferred, check the README) - Create a fake with the answers your code expects, for example
Laya::fake(['department' => Department::Billing, 'urgency' => 2, 'churn' => true])in Laravel. - Assert the call count with
$laya->assertPredictedCount(1);in your test.
Prompt for your agent
In the marcreichel/laya-php repo, write a test for <class that calls Laya> that uses the built-in fake to return <expected answers>. Report the test result and the call count, and verify that the test passes with no laya-serve running.
Caveat. The fake only returns the answers you give it, so it checks your code's handling of results, not whether Laya would classify real text correctly.
Get 5 new use cases every morning. Free, one short email, unsubscribe anytime.
Get them freeShare: X LinkedIn Hacker News Email Copy link
Disclaimer
Deduped lists open-source repositories that belong to other people. We do not own, maintain, audit, or vouch for any of them, and a repo appearing here is not an endorsement or a safety check. The use cases, steps, and prompts are written by AI and may be incomplete, outdated, or just wrong. Where a use case is marked "Seen in the wild", we link to public posts where someone described something similar, but we have not verified those posts and the use case itself is still our AI's own write-up. Use all of this at your own risk. Only run code, commands, or agents on systems and accounts you are authorized to use, and read the code and every command before you run it, especially anything that touches credentials, files, or the network. Nothing here is professional, security, legal, or financial advice. All trademarks and project names belong to their respective owners, and their use here does not imply affiliation. Content is provided as is, without warranties of any kind. Found a mistake, a safety problem, or something you want removed? Email [email protected] and we will look at it promptly. Full disclaimer page