Polyscope - The agent-first dev environment for Laravel

The Neuron AI Framework for PHP and Laravel

Published on by

The Neuron AI Framework for PHP and Laravel image

Neuron AI is a PHP Agentic framework to build production-ready AI-driven applications. Along with the core neuron-ai framework, the neuron-laravel package provides Laravel-specific integration points without limiting access to the core framework components.

This package aims to make it easier for Laravel developers to get started with AI agent development using the Neuron AI framework. Neuron doesn't need invasive abstractions, it already has a very simple syntax, 100% typed code, and clear interfaces you can rely on to develop your agentic system or create custom plugins and extensions.

Using the Laravel package's Artisan commands, you can quickly generate files such as a Neuron agent, a tool, a workflow, and more. Using Neuron, you can extend the Agent class to create agents quickly, providing you with rich features like chat history, tools, etc, and a clean interface:

<?php
 
namespace App\Neuron;
 
use NeuronAI\Agent;
use NeuronAI\SystemPrompt;
use NeuronAI\Providers\AIProviderInterface;
use NeuronAI\Providers\Anthropic\Anthropic;
 
class YouTubeAgent extends Agent
{
protected function provider(): AIProviderInterface
{
// return an AI provider instance (Anthropic, OpenAI, Ollama, Gemini, etc.)
return new Anthropic(
key: 'ANTHROPIC_API_KEY',
model: 'ANTHROPIC_MODEL',
);
}
 
public function instructions(): string
{
return (string) new SystemPrompt(
background: ["You are an AI Agent specialized in writing YouTube video summaries."],
steps: [
"Get the url of a YouTube video, or ask the user to provide one.",
"Use the tools you have available to retrieve the transcription of the video.",
"Write the summary.",
],
output: [
"Write a summary in a paragraph without using lists. Use just fluent text.",
"After the summary add a list of three sentences as the three most important takeaways from the video.",
]
);
}
}

As I learned about Neuron, the Chat History feature really stood out to me, providing LLM context out of the box while truncating the conversation to avoid exceeding the LLM content window. Chat history can be stored in-memory, in a file, a database, or any storage you want by implementing the AbstractChatHistory class.

Laravel Neuron Main Features

  • A ready-to-use configuration file for AI providers, embeddings providers credentials
  • A few artisan commands to create the most used components and reduce boilerplate code
  • Facades to automatically instantiate providers and vector stores
  • Ready-to-run migrations if you want to use the EloquentChatHistory component
  • AI coding assistant guidelines integrated with Laravel Boost to help AI write better code

Learn More

While we cannot cover every feature Neuron provides, I recommend starting with the official documentation. It includes details about every part of Neuron as well as videos. Lastly, check out the example app demonstrating a multi-agent workflow in Laravel.

👨‍💻 The source code is available on GitHub: neuron-core/neuron-laravel

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.

image
Laravel Code Review

Get expert guidance in a few days with a Laravel code review

Visit Laravel Code Review
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
Get expert guidance in a few days with a Laravel code review logo

Get expert guidance in a few days with a Laravel code review

Expert code review! Get clear, practical feedback from two Laravel devs with 10+ years of experience helping teams build better apps.

Get expert guidance in a few days with a Laravel code review
PhpStorm logo

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm
Laravel Cloud logo

Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Cloud
Acquaint Softtech logo

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit

The latest

View all →
Browse and Execute Artisan Commands from an Interactive TUI image

Browse and Execute Artisan Commands from an Interactive TUI

Read article
Laravel Pint Now Replaces Fully Qualified Class Names with Imports image

Laravel Pint Now Replaces Fully Qualified Class Names with Imports

Read article
Inertia v3 Upgrade Prompt and JSON Log Support in Laravel Boost v2.3.0 image

Inertia v3 Upgrade Prompt and JSON Log Support in Laravel Boost v2.3.0

Read article
Laracon AU Returns to Brisbane - Call for Speakers Now Open image

Laracon AU Returns to Brisbane - Call for Speakers Now Open

Read article
Detecting and Fixing Race Conditions in Laravel Applications image

Detecting and Fixing Race Conditions in Laravel Applications

Read article
LaraCopilot: Generate Laravel MVPs From a Single Prompt With AI image

LaraCopilot: Generate Laravel MVPs From a Single Prompt With AI

Read article