neuron-core/neuron-laravel
Laravel integration for Neuron AI that lets you build AI agents, tools, and retrieval-augmented workflows in Laravel using familiar configuration, facades, and Artisan generators for PHP-native AI orchestration.
This release (2.0.0) is a compatibility release: the Laravel bridge now targets Neuron 4. The public surface of the Laravel package is largely unchanged, but the underlying agent framework had a major bump, so treat this as an upgrade task rather than a drop-in patch.
Minimal path:
composer require neuron-ai/neuron:^4.0 alongside the bridge package. Do not allow ^3 to remain in the lockfile — a mixed constraint will resolve to incompatible contracts and fail at runtime, not at install time.php artisan vendor:publish, pick the neuron/bridge entry) and review the provider, model, and API-key settings. Prefer env() only inside the config file..env, then smoke-test with php artisan tinker: resolve the package's base agent from the container and run a trivial prompt. If that works, the wiring (service provider, HTTP client, config) is correct.Look first at: the package's service provider (what it binds and publishes), the published config file, and the upstream Neuron 4 upgrade notes — the bridge is thin, so most breaking changes will come from the framework underneath.
Agents as container-resolved classes. Define agents as classes with instructions and a tools() declaration, and resolve them via app()/injection rather than new. That lets tools receive their own dependencies (repositories, HTTP clients) and makes agents swappable in tests.
Keep tools thin. A tool should validate input, call a service or Eloquent query, and return a compact string/array. Business logic belongs in services; tool descriptions are prompt surface, so word them precisely — vague descriptions are the single biggest cause of wrong tool selection.
Queue long runs. Anything beyond a few seconds belongs in a job. Dispatch with a dedicated queue and a worker --timeout comfortably above your slowest provider call; the default 60s is frequently too low for tool-using agents.
Config-driven model selection. Read model/provider from config so tests and local dev can point at a cheap model or a fake. Bind provider clients in a service provider so swapping providers per environment is a config change, not a code change.
Observability. Hook the package/framework events (or a logging middleware) to record prompt, tool calls, token usage, and latency. Cost visibility is the thing teams most regret skipping.
Testing. Use the upstream test helpers to fake agent responses where available; otherwise Http::fake() the provider endpoint. Assert on tool invocations (spy the tool class) rather than on model prose, which is non-deterministic.
Orchestration. For multi-step work, prefer composing several small agents through a Laravel job/pipeline over one giant agent with ten tools. Persist conversation and intermediate state in the database; do not hold it in memory across queue hops.
php artisan config:clear (and optimize:clear on deploy). A cached config referencing an old provider class produces confusing "class not found" errors at boot.php artisan queue:restart as part of the deploy.config/app.php, remove it — package discovery plus a manual entry yields double bindings and odd singleton behaviour.max_execution_time, the queue worker --timeout, the queue retry_after, and the HTTP client timeout all apply. Order them: HTTP < worker < retry_after, or jobs get retried while still running and you pay twice.env() outside config breaks under config:cache. A classic source of "works locally, null in production" API-key bugs.RateLimiter, and add a hard iteration ceiling for tool loops — an agent that keeps calling a failing tool will happily spend money in a loop.tinker — queue serialisation masks the real exception more often than not.How can I help you explore Laravel packages today?