DEDUPED Hot AI repos. Real use cases. What people build. Get the Monday 5

How to unit-test classification code without a running server with Laya PHP

Run your tests against a built-in fake so CI does not need Laya or Docker.

Short answer: Run composer require marcreichel/laya-php in your project; then open examples/05-testing-with-fake.php in the cloned repo to see how the fake is set up; run php examples/05-testing-with-fake.php to confirm it works without a server. All steps.

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

  1. Run composer require marcreichel/laya-php in your project.
  2. Open examples/05-testing-with-fake.php in the cloned repo to see how the fake is set up.
  3. Run php examples/05-testing-with-fake.php to confirm it works without a server. (inferred, check the README)
  4. Create a fake with the answers your code expects, for example Laya::fake(['department' => Department::Billing, 'urgency' => 2, 'churn' => true]) in Laravel.
  5. 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.

Use this in your AI agent

Ask your agent

Using the Deduped MCP, get the setup steps for marcreichel/laya-php and "Unit-test classification code without a running server"

Add Deduped to Claude Code once

claude mcp add --transport http deduped https://dedupedai.com/mcp

Cursor, ChatGPT, others

Share: X LinkedIn Hacker News Email Copy link

Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer