neuron-core / neuron-laravel
Utility Package for using Neuron AI in Laravel applications.
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/neuron-core/neuron-laravel
Requires
- php: ^8.2
- illuminate/console: ^10.0|^11.0|^12.0
- illuminate/contracts: ^10.0|^11.0|^12.0
- illuminate/support: ^10.0|^11.0|^12.0
- neuron-core/neuron-ai: ^2.10
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.75
- larastan/larastan: ^3.0
- livewire/livewire: ^3.7
- orchestra/testbench: ^10.0
- rector/rector: ^2.2
- tomasvotruba/type-coverage: ^2.0
Suggests
- inspector-apm/inspector-laravel: ^4.18.2
README
Important
Get early access to new features, exclusive tutorials, and expert tips for building AI agents in PHP. Join a community of PHP developers pioneering the future of AI development. Subscribe to the newsletter
This package aims to make it easier for Laravel developers to get started with AI agent development using Neuron AI framework. The package is built to help developers during the initial setup and configuration of their projects, it's not meant to completely wrap the Neuron AI architecture. Neuron doesn't need such invasive abstractions, it already has a very simple syntax, 100% typed code, and clear interfaces you can rely on to integrate or create custom plugins and extensions.
In this package we provide you with a development kit specifically designed for Laravel integration points without limiting the access to the Neuron native API.
You can find a ready-to-use configuration file, a few artisan commands to reduce boilerplate code, a service class to get an instance of the AI provider with the classic Laravel configuration-driven approach. You can also find ready-to-run migration if you want to use the Eloquent Chat History component, and other useful helpers.
What is Neuron?
Neuron is the leading PHP framework for creating and orchestrating AI Agents. It allows you to integrate AI entities in your PHP applications with a powerful and flexible architecture. We provide tools for the entire agentic application development lifecycle, from LLM interfaces, data loading, to multi-agent orchestration, monitoring and debugging. In addition, we provide tutorials and other educational content to help you get started using AI Agents in your projects.
Requirements
- PHP >= 8.2
- Laravel >= 10.x
Install
Install the latest version by:
composer require neuron-core/neuron-laravel
Configuration file
If you want to customize the configuration file beyond the environment variables, you can copy the package configuration file
in your project config/neuron.php folder:
php artisan vendor:publish --tag=neuron-config
Create an Agent
To create a new AI agent, run the following command:
php artisan neuron:agent MyAgent
This will create a new agent class in your app/Neuron/Agents folder with the name MyAgent.php and a couple of
basic methods inside.
AI Providers
To get an instance of AI provider to be used in your agents, you can use the NeuronAI\Laravel\AIProvider service class.
It allows you to get an instance of the provider based on the configuration file.
use NeuronAI\Laravel\AIProvider; // Get the default provider $provider = AIProvider::driver(); // Get a specific provider instance $provider = AIProvider::driver('anthropic');
The configuration file allows you to configure the default AI provider you want to use in your agents, and the connection parameters (API key, model, etc.) for all the providers you want to use.
Neuron allows you to implement AI agents using many different providers, like Anthropic, Gemini, OpenAI, Ollama, Mistral, and many more. Learn more about supported providers in the Neuron AI documentation: https://docs.neuron-ai.dev/the-basics/ai-provider
You can configure the appropriate API key in your environment file:
# Support for: anthropic, gemini, openai, openai-responses, mistral, ollama, huggingface, deepseek NEURON_PROVIDER=anthropic ANTHROPIC_KEY= GEMINI_KEY= OPENAI_KEY= MISTRAL_KEY= OLLAMA_URL= # And many others
Artisan Commands
The package ships with a few artisan commands to reduce boilerplate code and make the setup process easier for the most common Neuron AI components.
# Create an agent
php artisan neuron:agent MyAgent
# Create a RAG
php artisan neuron:rag MyRAG
# Create a tool
php artisan neuron:tool MyTool
# Create a workflow
php artisan neuron:workflow MyWorkflow
# Create a node
php artisan neuron:node CustomNode
# Create a middleware
php artisan neuron:middleware CustomMiddleware
EloquentChatHistory
Neuron provides you with a built-in system to manage the memory of a chat session you perform with the agent. In many Q&A applications you can have a back-and-forth conversation with the LLM, meaning the application needs some sort of "memory" of past questions and answers, and some logic for incorporating those into its current thinking.
Here is the documentation: https://docs.neuron-ai.dev/the-basics/chat-history-and-memory
The package ships with a ready-to-use migration for the ElquentChatHistory component. Here is the command to copy the migration
in your project database/migrations/neuron folder:
php artisan vendor:publish --tag=neuron-migrations
And then run the migrations:
php artisan migrate --path=/database/migrations/neuron
Read more about Eloquent Chat History in the Neuron AI documentation: https://docs.neuron-ai.dev/the-basics/chat-history-and-memory#eloquentchathisotry
