Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

demiurgich's avatar

I have problems with Scout and Algolia. Need help.

Hello. I am developing Intranet system on Laravel 5.6. I have installed Scout and Algolia as described in official documentation. Registered account on Algolia and put both Application ID and Admin API Key to scout.php. Scout engine is set to Algolia. But Algolia does not work. Even Batch Import (php artisan scout:import “App\MyModel”) tells that data is imported, but no changes on server affected. While trying to find the reason I discovered, that Scout is using NullEngine. Trying to backup settings I got 'exception: algoliasearch requires an applicationid'. What should I do to fix the problem? Thank you.

0 likes
16 replies
rin4ik's avatar

did you install this?

composer require algolia/algoliasearch-client-php
demiurgich's avatar

Yes, I did. Now I'm watching this video.

1 like
demiurgich's avatar

I didn't find any help in video. Maybe I need to enable some php extension? While trying to backup settings I got exception that I need curl. I enabled it. After that I receive exception about algoliasearch requires an applicationid. When trying to import data no error is displayed. Everything is OK, he tells. But no data is sync.

rin4ik's avatar

yes try

PHP 7.2: sudo apt-get install php7.2-curl
PHP 7.1: sudo apt-get install php7.1-curl
PHP 7.0: sudo apt-get install php7.0-curl
PHP 5.6: sudo apt-get install php5.6-curl
1 like
demiurgich's avatar

@rin4ik Curl is installed. Here is phpinfo() section about curl


curl
cURL support    enabled
cURL Information    7.56.0
Age     3
Features
AsynchDNS   Yes
CharConv    No
Debug   No
GSS-Negotiate   No
IDN     Yes
IPv6    Yes
krb4    No
Largefile   Yes
libz    Yes
NTLM    Yes
NTLMWB  No
SPNEGO  Yes
SSL     Yes
SSPI    Yes
TLS-SRP     No
HTTP2   Yes
GSSAPI  No
KERBEROS5   Yes
UNIX_SOCKETS    No
PSL     No
Protocols   dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, pop3, pop3s, rtsp, scp, sftp, smtp, smtps, telnet, tftp
Host    x86_64-pc-win32
SSL Version     OpenSSL/1.1.0g
ZLib Version    1.2.11
libSSH Version  libssh2/1.8.0 
-------------------------------------------------------------

@Cronix Yes I have account on Algolia. Every time I try to sync my data I check it in browser. And I put both Application ID and Admin API Key in config/scout.php. I also tried to put Keys in .env file, and in vendor\laravel\scout\config\scout.php. And even directly to __construct function of vendor\algolia\algoliasearch-client-php\src\AlgoliaSearch\Client.php. Still the same result.

When I go step-by-step in scout process I found that NullEngine is involved. If I comment update() function of AlgoliaEngine nothing happens, not the single error.

demiurgich's avatar

My \vendor\algolia\algoliasearch-client-php\src\AlgoliaSearch\Client.php file does not receive ApplicationId as far as all variables needed to __constract().

Where can be the reason?

demiurgich's avatar

In Laravel 5.6 Api Keys are stored in config\scout.php. Am I right? They are there. When I try to var_damp (config('scout.algolia.id')) it returns NULL. Or should I re-view the video you proposed me? It is old enought, for some older version.

rin4ik's avatar

yes @demiurgich config('scout.algolia.id') it shouldn't return null

'algolia' => [
        'id' => env('ALGOLIA_APP_ID', ''),
        'secret' => env('ALGOLIA_SECRET', ''),
    ],

.env file

ALGOLIA_APP_ID=MGXIQSZE70
ALGOLIA_SECRET=c372f98f94323428b8234ffde38d53624
1 like
demiurgich's avatar

Here is my config\scout.php:

'algolia' => [
        'id' => env('ALGOLIA_APP_ID', '-----------'),
        'secret' => env('ALGOLIA_SECRET', '----------------------------lkjhh'),
    ],

And here is .env

SCOUT_ENGINE=algolia,
ALGOLIA_APP_ID=---------kjbjhbj,
ALGOLIA_SECRET=--------------kjnbiubuyg,

Looks like they are normal.

Cronix's avatar

To keep it simple, remove that.

then create /config/algolia.php

return [
    'id' => env('ALGOLIA_APP_ID'),
    'secret' => env('ALGOLIA_SECRET'),
];

Then to use:

config('algolia.id');
config('algolia.secret');

PS - in your .env, remove the trailing commas. There should be no commas at the end of the lines unless it's actually a part of the value that you are setting the key for.

key=value
key=value

NOT

key=value,
key=value,

PSS - You should remove the actual app key and id from your last few posts, otherwise anyone who is reading this can use them and charge to your account!

1 like
demiurgich's avatar
demiurgich
OP
Best Answer
Level 1

Those Keys are modificated.

My hugs to you, guys. You are awesome. I am stupid. My problem was in cache. I needed to clear it. All changes I did were helpless because settings saved in cache were unchanged.

Please or to participate in this conversation.