Installation and setup | laravel-site-search | Spatie

 SPATIE

  Laravel Site Search
======================

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-site-search](https://spatie.be/docs/laravel-site-search/v2)  Installation and setup

 Version   v3   v2   v1

 Other versions for crawler [v3](https://spatie.be/docs/laravel-site-search/v3) [v2](https://spatie.be/docs/laravel-site-search/v2) [v1](https://spatie.be/docs/laravel-site-search/v1)

- [ Introduction ](https://spatie.be/docs/laravel-site-search/v2/introduction)
- [ Support us ](https://spatie.be/docs/laravel-site-search/v2/support-us)
- [ Installation and setup ](https://spatie.be/docs/laravel-site-search/v2/installation-setup)
- [ About us ](https://spatie.be/docs/laravel-site-search/v2/about-us)
- [ Questions and issues ](https://spatie.be/docs/laravel-site-search/v2/questions-issues)
- [ Requirements ](https://spatie.be/docs/laravel-site-search/v2/requirements)
- [ Changelog ](https://spatie.be/docs/laravel-site-search/v2/changelog)

Basic usage
-----------

- [ High level overview ](https://spatie.be/docs/laravel-site-search/v2/basic-usage/high-level-overview)
- [ Indexing your first site ](https://spatie.be/docs/laravel-site-search/v2/basic-usage/indexing-your-first-site)
- [ Retrieving results ](https://spatie.be/docs/laravel-site-search/v2/basic-usage/retrieving-results)
- [ Preventing content from being indexed ](https://spatie.be/docs/laravel-site-search/v2/basic-usage/preventing-content-from-being-indexed)
- [ Using a search profile ](https://spatie.be/docs/laravel-site-search/v2/basic-usage/using-a-search-profile)
- [ Authenticating requests ](https://spatie.be/docs/laravel-site-search/v2/basic-usage/authenticating-requests)
- [ Listing indexes ](https://spatie.be/docs/laravel-site-search/v2/basic-usage/listing-indexes)
- [ Troubleshooting ](https://spatie.be/docs/laravel-site-search/v2/basic-usage/troubleshooting)

Advanced usage
--------------

- [ Creating multiple search indexes ](https://spatie.be/docs/laravel-site-search/v2/advanced-usage/creating-multiple-search-indexes)
- [ Using a custom indexer ](https://spatie.be/docs/laravel-site-search/v2/advanced-usage/using-a-custom-indexer)
- [ Indexing extra properties ](https://spatie.be/docs/laravel-site-search/v2/advanced-usage/indexing-extra-properties)
- [ Customizing Meilisearch settings ](https://spatie.be/docs/laravel-site-search/v2/advanced-usage/customizing-meilisearch-settings)
- [ Available events ](https://spatie.be/docs/laravel-site-search/v2/advanced-usage/available-events)

      You are viewing the documentation for **an older version** of this package. You can check the version you are using with the following command:

 `                                    composer show spatie/laravel-site-search                                                                                                                                                                                                                                    `

Installation and setup
======================

###  On this page

1. [ Require via composer ](#content-require-via-composer)
2. [ Publish migrations ](#content-publish-migrations)
3. [ Schedule the crawl command ](#content-schedule-the-crawl-command)
4. [ Publish the config file ](#content-publish-the-config-file)
5. [ Install the Meilisearch client ](#content-install-the-meilisearch-client)
6. [ Install Meilisearch ](#content-install-meilisearch)
7. [ Authenticating requests to Meilisearch ](#content-authenticating-requests-to-meilisearch)

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.

```
// in app/Console/Kernel.php
use Spatie\SiteSearch\Commands\CrawlCommand;

protected function schedule(Schedule $schedule)
{
    // other commands
    // ...

    $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:

```
