Question Details

How to Create Bot Client Instance by Using PHP Namespaces?

I've tried the method on the official document.

$httpClient = new \LINE\LINEBot\HTTPClient\CurlHTTPClient($channelAccessToken);
error_log('bot instance');
$bot = new \LINE\LINEBot($httpClient, ['channelSecret' => $channelSecret]);

The 'Japanese Yen' symbol is a backslash.

I put an error_log in between to check if the HTTPClient is created successfully. Unfortunately, the error_log doesn't show and the $httpClient is not created so it must means that there's something wrong with the previous line of code. I have main.php and the folder 'LINE' in the same root folder. I think the path might be wrong but I can't find any way to fix it since my directory path is the same as it is in the code namespace. By the way, I'm using a server that doesn't show any error about the code, unless print out error_log manually, but it doesn't tell if the path is correct.

Does anyone know what it might be to cause the issue?

Edited: 3 months ago
Profile picture


Profile picture
森 駿介(Mori Shunsuke)
Posted: 2 months ago
Edited: 2 months ago

How do you install the sdk? Tell me with detail.

We recommended you to install sdk with Composer.(Please see

$ composer require linecorp/line-bot-sdk

This is not possible if you use composer.

I have main.php and the folder 'LINE' in the same root folder.

Are you sure? question.vm