-
-
Notifications
You must be signed in to change notification settings - Fork 1
Installation Guide
Rumen Damyanov edited this page Jul 31, 2025
·
1 revision
This page provides detailed installation instructions for php-chatbot in various environments.
- PHP: 8.3 or higher
- Composer: Latest version recommended
-
Extensions:
curl,json,mbstring - Memory: Minimum 128MB (256MB+ recommended)
- Laravel: 8.0+ (for Laravel integration)
- Symfony: 5.4+ (for Symfony integration)
- Node.js: 16+ (for frontend component development)
composer require rumenx/php-chatbot- Download the latest release from GitHub
- Extract to your project directory
- Include the autoloader:
require_once 'path/to/php-chatbot/vendor/autoload.php';For contributing or development:
git clone https://github.com/RumenDamyanov/php-chatbot.git
cd php-chatbot
composer installThe service provider is automatically discovered. No manual registration needed!
Add to config/app.php:
'providers' => [
// Other providers...
Rumenx\PhpChatbot\Adapters\Laravel\PhpChatbotServiceProvider::class,
],php artisan vendor:publish --provider="Rumenx\PhpChatbot\Adapters\Laravel\PhpChatbotServiceProvider"This creates:
-
config/phpchatbot.php- Main configuration file -
resources/views/vendor/phpchatbot/- View templates
php artisan vendor:publish --provider="Rumenx\PhpChatbot\Adapters\Laravel\PhpChatbotServiceProvider" --tag=assetsAdd to config/bundles.php:
return [
// Other bundles...
Rumenx\PhpChatbot\Adapters\Symfony\PhpChatbotBundle::class => ['all' => true],
];php bin/console chatbot:publish-configCreate config/packages/phpchatbot.yaml:
phpchatbot:
model: 'openai'
api_key: '%env(OPENAI_API_KEY)%'
prompt: 'You are a helpful assistant.'<?php
require_once 'vendor/autoload.php';
use Rumenx\PhpChatbot\PhpChatbot;
use Rumenx\PhpChatbot\Models\ModelFactory;
// Load configuration
$config = require 'path/to/config/phpchatbot.php';
// Create model and chatbot
$model = ModelFactory::make($config);
$chatbot = new PhpChatbot($model, $config);// Use environment variable for config path
$configPath = getenv('PHPCHATBOT_CONFIG_PATH') ?: __DIR__ . '/config/phpchatbot.php';
$config = require $configPath;Copy the example environment file:
cp .env.example .envAdd your AI provider API keys to .env:
# OpenAI
OPENAI_API_KEY=sk-your-openai-key-here
# Anthropic
ANTHROPIC_API_KEY=your-anthropic-key-here
# Google Gemini
GEMINI_API_KEY=your-gemini-key-here
# xAI
XAI_API_KEY=your-xai-key-here
# Meta
META_API_KEY=your-meta-key-here
# DeepSeek
DEEPSEEK_API_KEY=your-deepseek-key-here| Variable | Description | Default |
|---|---|---|
PHPCHATBOT_MODEL |
Default AI model | openai |
PHPCHATBOT_TIMEOUT |
API timeout (seconds) | 30 |
PHPCHATBOT_MAX_TOKENS |
Maximum tokens per response | 1000 |
PHPCHATBOT_TEMPERATURE |
Response creativity (0.0-1.0) | 0.7 |
# Rate limiting
PHPCHATBOT_RATE_LIMIT=10
PHPCHATBOT_RATE_WINDOW=60
# Content filtering
PHPCHATBOT_ENABLE_FILTERING=true
PHPCHATBOT_PROFANITY_FILTER=trueCreate a test script (test-installation.php):
<?php
require_once 'vendor/autoload.php';
use Rumenx\PhpChatbot\PhpChatbot;
use Rumenx\PhpChatbot\Models\DefaultAiModel;
try {
// Test with default model (no API key needed)
$model = new DefaultAiModel();
$chatbot = new PhpChatbot($model);
$response = $chatbot->ask('Hello, world!');
echo "✅ Installation successful!\n";
echo "Response: " . $response . "\n";
} catch (Exception $e) {
echo "❌ Installation failed: " . $e->getMessage() . "\n";
}Run the test:
php test-installation.php<?php
require_once 'vendor/autoload.php';
use Rumenx\PhpChatbot\PhpChatbot;
use Rumenx\PhpChatbot\Models\ModelFactory;
try {
$config = [
'model' => 'openai',
'api_key' => 'your-api-key-here',
'prompt' => 'You are a helpful assistant.',
];
$model = ModelFactory::make($config);
$chatbot = new PhpChatbot($model, $config);
$response = $chatbot->ask('What is PHP?');
echo "✅ AI integration successful!\n";
echo "Response: " . $response . "\n";
} catch (Exception $e) {
echo "❌ AI integration failed: " . $e->getMessage() . "\n";
}# Test Artisan command
php artisan route:list | grep chatbot
# Test in tinker
php artisan tinker
>>> app('phpchatbot')->ask('Hello!')# Check services
php bin/console debug:container | grep chatbot
# Test command
php bin/console chatbot:test# Clear Composer cache
composer clear-cache
# Update autoloader
composer dump-autoload# Fix directory permissions
chmod -R 755 vendor/
chmod -R 644 config/# Check required extensions
php -m | grep -E "(curl|json|mbstring)"
# Install missing extensions (Ubuntu/Debian)
sudo apt-get install php-curl php-json php-mbstringNext: Quick Start Guide