The SDK provides several Artisan commands for managing SAP B1 connections and sessions.
| Command | Description |
|---|---|
sap-b1:status |
Show connection status and configuration |
sap-b1:session |
Manage sessions (login, logout, refresh, clear) |
sap-b1:health |
Check connection health |
sap-b1:pool |
Manage session pool (status, warmup, drain, cleanup) |
Display connection status, configuration, and session information.
# Show status for default connection
php artisan sap-b1:status
# Show status for specific connection
php artisan sap-b1:status --connection=production
# Include connection test
php artisan sap-b1:status --testSAP B1 Connection Status: default
Configuration
Base URL ...................................... https://server:50000
Company DB .................................... SBODEMOUS
Username ...................................... manager
Language ...................................... 23
Session Configuration
Driver ........................................ file
TTL ........................................... 1680 seconds
Refresh Threshold ............................. 300 seconds
HTTP Configuration
Timeout ....................................... 30 seconds
SSL Verify .................................... Yes
Retry Times ................................... 3
Session Status
Status ........................................ Active
Session ID .................................... abc123-def456
Company ....................................... SBODEMOUS
Expires At .................................... 2026-01-11 15:30:00
Created At .................................... 2026-01-11 15:02:00
Remaining ..................................... 28 minutes
php artisan sap-b1:status --test Connection Test
Result ........................................ Connected successfully
Response Time ................................. 234ms
Company Name .................................. Demo US Company
Manage SAP B1 sessions.
Create a new session:
php artisan sap-b1:session login
# Specific connection
php artisan sap-b1:session login --connection=productionEnd the current session:
php artisan sap-b1:session logout
# Skip confirmation
php artisan sap-b1:session logout --force
# Specific connection
php artisan sap-b1:session logout --connection=productionRefresh the current session:
php artisan sap-b1:session refresh
php artisan sap-b1:session refresh --connection=productionClear local session data without SAP logout:
php artisan sap-b1:session clear
php artisan sap-b1:session clear --forceClear all stored sessions:
php artisan sap-b1:session clear-all
php artisan sap-b1:session clear-all --forceCheck SAP B1 connection health.
# Check default connection
php artisan sap-b1:health
# Check specific connection
php artisan sap-b1:health --connection=production
# Check all connections
php artisan sap-b1:health --all
# JSON output for monitoring tools
php artisan sap-b1:health --jsonChecking SAP B1 connection health...
SAP B1 connection is healthy
Status ........................................ Healthy
Connection .................................... default
Company DB .................................... SBODEMOUS
Response Time ................................. 156.42ms
Session ID .................................... abc123...
php artisan sap-b1:health --json{
"healthy": true,
"message": "SAP B1 connection is healthy",
"connection": "default",
"company_db": "SBODEMOUS",
"response_time": 156.42,
"session_id": "abc123..."
}php artisan sap-b1:health --allChecking all SAP B1 connections...
default ....................................... Healthy
Company ..................................... SBODEMOUS
Response .................................... 156.42ms
production .................................... Healthy
Company ..................................... SBOPROD
Response .................................... 89.21ms
warehouse ..................................... Unhealthy
Error ....................................... Connection failed: timeout
Some connections are unhealthy.
Manage the session pool (requires SAP_B1_POOL_ENABLED=true).
View pool statistics:
php artisan sap-b1:pool status
php artisan sap-b1:pool status --connection=productionSession Pool Status [default]
Total Sessions ................................ 5
Active (In Use) ............................... 2
Idle (Available) .............................. 3
Expired ....................................... 0
Min Size ...................................... 2
Max Size ...................................... 10
Algorithm ..................................... round_robin
Pool Health ................................... Healthy
Utilization ................................... 40.0%
Pre-create sessions in the pool:
# Warmup to minimum size
php artisan sap-b1:pool warmup
# Warmup specific count
php artisan sap-b1:pool warmup --count=5
# Specific connection
php artisan sap-b1:pool warmup --connection=production --count=10Remove all sessions from the pool:
php artisan sap-b1:pool drain
# Skip confirmation
php artisan sap-b1:pool drain --force
# Specific connection
php artisan sap-b1:pool drain --connection=productionRemove expired sessions:
php artisan sap-b1:pool cleanup
php artisan sap-b1:pool cleanup --connection=productionView session summary:
php artisan sap-b1:pool sessionsSessions in Pool [default]
+---------+-------+
| Status | Count |
+---------+-------+
| idle | 3 |
| active | 2 |
| expired | 0 |
+---------+-------+
Total ......................................... 5
All commands return appropriate exit codes:
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Failure |
Use exit codes in scripts:
php artisan sap-b1:health --connection=production
if [ $? -eq 0 ]; then
echo "SAP B1 is healthy"
else
echo "SAP B1 is down!"
# Send alert
fiSchedule health checks in routes/console.php (Laravel 11+):
use Illuminate\Support\Facades\Schedule;
Schedule::command('sap-b1:health --all --json')
->everyFiveMinutes()
->appendOutputTo(storage_path('logs/sap-b1-health.log'));
Schedule::command('sap-b1:pool cleanup')
->everyMinute()
->withoutOverlapping();Or in app/Console/Kernel.php (Laravel 10):
protected function schedule(Schedule $schedule)
{
$schedule->command('sap-b1:health --all')
->everyFiveMinutes()
->emailOutputOnFailure('admin@example.com');
$schedule->command('sap-b1:pool cleanup')
->everyMinute()
->withoutOverlapping();
}# .github/workflows/deploy.yml
- name: Check SAP B1 Connection
run: php artisan sap-b1:health --json
continue-on-error: false#!/bin/bash
# deploy.sh
echo "Checking SAP B1 connections..."
php artisan sap-b1:health --all
if [ $? -ne 0 ]; then
echo "SAP B1 health check failed. Aborting deployment."
exit 1
fi
echo "All connections healthy. Proceeding with deployment..."- Health Checks - Programmatic health checks
- Session Pool - Configure session pooling
- Configuration - All configuration options