chitanok/line-api-laravel
Laravel package for building simple LINE Messaging API bots. Provides a service provider and basic setup to send and receive LINE messages and create a lightweight bot for notifications or customer interactions.
Pros:
chitanok/line-api-laravel) is a Laravel wrapper for the LINE Messaging API, aligning well with architectures requiring chatbot, notification, or messaging integrations (e.g., customer support, alerts, or interactive services).MessagingService) without polluting core business logic, adhering to separation of concerns.Cons:
HttpClient facade, which is replaceable if needed (e.g., for Guzzle customizations)..env). Ensure your team can secure and rotate credentials.429 Too Many Requests, 401 Invalid Token).LineMessagingService).LineClient) in config/app.php or a service provider.Line::sendMessage() directly or wrap in a custom facade for consistency.message.received) to trigger Laravel jobs or notifications.LineJob::dispatch()).php-curl or php-json are enabled (required for HTTP requests).line_messages (e.g., user_id, message_id, content, status, created_at).composer require chitanok/line-api-laravel) in a sandbox environment.Line::replyMessage()).guzzlehttp/guzzle or symfony/http-client..env:
LINE_CHANNEL_ACCESS_TOKEN=your_token_here
LINE_CHANNEL_SECRET=your_secret_here
LineService facade/class to wrap package calls.// app/Services/LineService.php
class LineService {
public function sendTextMessage(string $userId, string $message) {
return Line::sendMessage([
'to' => $userId,
'messages' => [['type' => 'text', 'text' => $message]],
]);
}
}
Route::post('/line-webhook', [LineWebhookController::class, 'handle']);
X-Line-Signature header).try {
$response = Line::sendMessage(...);
} catch (Exception $e) {
Log::error("LINE API failed", ['error' => $e->getMessage(), 'payload' => $payload]);
throw new LineApiException("Failed to send message");
}
LineService (mock Line facade).LINE_CHANNEL_ACCESS_TOKEN in .env when rotated (set a calendar reminder).How can I help you explore Laravel packages today?