You can install this package inside a Laravel app of which the content needs to be indexed. You could also install this package inside a standalone Laravel app that is dedicated to crawling multiple other sites.
Here are the steps that you need to perform to install the package.
##Require via composer
laravel-site-search can be installed via Composer:
composer require "spatie/laravel-site-search:^1.0.0"
##Publish migrations
Next, you should publish the migrations and run them:
php artisan vendor:publish --tag="site-search-migrations"
php artisan migrate
##Schedule the crawl command
This package contains a command that will crawl your site(s), and update the indexes.
In most cases, it's best to schedule that command, so you don't need to run it manually.
In the example below, we schedule to run the command every three hours, but you can decide which frequency is best for you.
use Spatie\SiteSearch\Commands\CrawlCommand;
protected function schedule(Schedule $schedule)
{
$schedule->command(CrawlCommand::class)->everyThreeHours();
}
##Publish the config file
Optionally, you can publish the config file with this command.
php artisan vendor:publish --tag="site-search-config"
This is the content of the config file:
<?php
return [
'ignore_content_on_urls' => [
],
'ignore_content_by_css_selector' => [
'[data-no-index]',
'nav',
],
'do_not_index_content_headers' => [
'site-search-do-not-index',
],
'do_not_crawl_urls' => [
],
'default_profile' => Spatie\SiteSearch\Profiles\DefaultSearchProfile::class,
'default_indexer' => Spatie\SiteSearch\Indexers\DefaultIndexer::class,
'default_driver' => Spatie\SiteSearch\Drivers\MeiliSearchDriver::class,
];
##Install the Meilisearch client
Next, you should require the Meilisearch PHP client:
composer require meilisearch/meilisearch-php
##Install Meilisearch
This package uses Meilisearch under the hood to provide blazing fast search results.
Head over to the Meilisearch docs to learn how to install it on your system.
Here are the steps for installing it on a Forge provisioned server. You must first download the stable release:
curl -L https://install.meilisearch.com | sh
Next, you must change the ownership and modify permission:
chmod 755 meilisearch
chown root:root meilisearch
After that, move the binary to a system-wide available path:
sudo mv meilisearch /usr/bin/
Finally, you can run the binary and make sure it keeps running. In the Forge Dashboard, click on "Daemons" under "Server Details". Fill out the following for a new daemon:
- Command:
meilisearch --master-key=SOME_MASTER_KEY --env=production --http-addr 0.0.0.0:7700 --db-path ./home/forge/meilifiles
- User:
forge
- Directory: leave blank
- Processes:
1
These instructions were take from this gist by Jose Soto.
##Authenticating requests to Meilisearch
To avoid unauthorized persons making request to Meilisearch, either block Meilisearch's default port (7700) in your firewall, or make sure all requests use authentication.