PHPackages                             joeymckenzie/artisense - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. joeymckenzie/artisense

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

joeymckenzie/artisense
======================

Laravel docs from the comfort of your own terminal.

v0.2.4(11mo ago)524[6 PRs](https://github.com/JoeyMckenzie/artisense/pulls)MITPHPPHP ^8.4CI passing

Since May 24Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/JoeyMckenzie/artisense)[ Packagist](https://packagist.org/packages/joeymckenzie/artisense)[ Docs](https://github.com/artisense/artisense)[ RSS](/packages/joeymckenzie-artisense/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (18)Versions (14)Used By (0)

 [![logo](art/logo.png)](art/logo.png) [![packgist downloads](https://camo.githubusercontent.com/2ebb202a4811d5af1d447aeb696c930f1e58597a614757fbead6b5dd3e3fa98e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a6f65796d636b656e7a69652f6172746973656e73652e737667)](https://camo.githubusercontent.com/2ebb202a4811d5af1d447aeb696c930f1e58597a614757fbead6b5dd3e3fa98e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a6f65796d636b656e7a69652f6172746973656e73652e737667) [![ci](https://camo.githubusercontent.com/56c27a36f8f3ceefc40365f0b0e64cfe0212a913686f1732b17ed5c0a1e02dd6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6a6f65796d636b656e7a69652f6172746973656e73652f72756e2d63692e796d6c3f6272616e63683d6d61696e266c6162656c3d6369)](https://camo.githubusercontent.com/56c27a36f8f3ceefc40365f0b0e64cfe0212a913686f1732b17ed5c0a1e02dd6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6a6f65796d636b656e7a69652f6172746973656e73652f72756e2d63692e796d6c3f6272616e63683d6d61696e266c6162656c3d6369) [![packgist downloads](https://camo.githubusercontent.com/1b6108ae42c82ebba1b35e60ba3b828d211397110f6a7fd3f18db886fa5d0d9d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6a6f65796d636b656e7a69652f6172746973656e73652f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65)](https://camo.githubusercontent.com/1b6108ae42c82ebba1b35e60ba3b828d211397110f6a7fd3f18db886fa5d0d9d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6a6f65796d636b656e7a69652f6172746973656e73652f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65) [![packgist downloads](https://camo.githubusercontent.com/d58def66de78da8ca13061ad854e8408a694d5f9e0795eb3f623fca6ed26e51c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a6f65796d636b656e7a69652f6172746973656e73652e737667)](https://camo.githubusercontent.com/d58def66de78da8ca13061ad854e8408a694d5f9e0795eb3f623fca6ed26e51c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a6f65796d636b656e7a69652f6172746973656e73652e737667) [![codecov coverage report](https://camo.githubusercontent.com/6842cfa3b7b3b5be251bb0932c7ce4c28e1e958f4e356a39ab9c6de30ed0f118/68747470733a2f2f636f6465636f762e696f2f67682f4a6f65794d636b656e7a69652f6172746973656e73652f67726170682f62616467652e7376673f746f6b656e3d41584d50385a544d4b44267374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/6842cfa3b7b3b5be251bb0932c7ce4c28e1e958f4e356a39ab9c6de30ed0f118/68747470733a2f2f636f6465636f762e696f2f67682f4a6f65794d636b656e7a69652f6172746973656e73652f67726170682f62616467652e7376673f746f6b656e3d41584d50385a544d4b44267374796c653d666c61742d737175617265)

Artisense 📕
===========

[](#artisense-)

Laravel docs from the comfort of your terminal.

Table of Contents
-----------------

[](#table-of-contents)

- [Motivation](#motivation)
- [How it works](#how-it-works)
- [Requirements](#requirements)
- [Getting started](#getting-started)
- [Usage](#usage)
    - [Versions](#versions)
    - [Formatting](#formatting)
- [Changelog](#changelog)
- [Credits](#credits)
- [License](#license)

Motivation
----------

[](#motivation)

Artisense is meant to be a local-first offline copy of the Laravel documentation. Artisense is a set of artisan commands that allow you to locally store and search the laravel documentation from the comfort of your terminal.

If you're anything like me and living in the terminal, those precious seconds `alt` + `tab`ing between code editor and browser to review the Laravel documentation really adds up (who has that kinda time?). Why not make docs accessible from the terminal?

How it works
------------

[](#how-it-works)

At its core, artisense is a SQLite database that lives within your `storage_path()` underneath an `artisense/` folder:

```
your-laravel-app/
  app/
  config/
  ...
  storage/
    artisense/
      artisense.sqlite // Where docs are stored
      docs-11.x/ // Documentation markdown files from 11.x
        artisan.md
        ...
      docs-12.x/ // Documentation markdown files from 12.x
        artisan.md
        ...
      docs-master.x/ // Documentation markdown files from master
        artisan.md
        ...
      zips/ // Zip archives of the documentation
        laravel-12.x.zip
        laravel-11.x.zip
        laravel-master.x.zip
        ...
```

Artisense uses SQLite to store documentation pulled from the Laravel documentation [source](https://github.com/laravel/docs). The documentation is downloaded as a zip file, extracted into a `artisense/docs-{version}.x/` folder, then processed into sections to allow full-text search using SQLite's [FTS5](https://www.sqlite.org/fts5.html) extension. Since artisense is just a SQLite file, you may connect and query it like any other SQLite database.

Requirements
------------

[](#requirements)

- Laravel 12 or greater
- PHP 8.4 or greater

Getting started
---------------

[](#getting-started)

Install artisense with composer:

```
composer require --dev joeymckenzie/artisense
```

You may also publish the configuration file with:

```
php artisan vendor:publish --tag="artisense-config"
```

This will create the following `config/artisense.php` file:

```
return [

    /*
    |--------------------------------------------------------------------------
    | Documentation version
    |--------------------------------------------------------------------------
    |
    | Specifies the version of the documentation to use, with both numbered
    | versions and master available. By default, the most recent numbered
    | is used if no version is specified while attempting to download.
    |
    */

    'versions' => DocumentationVersion::VERSION_12,

    /*
    |--------------------------------------------------------------------------
    | Output Formatter
    |--------------------------------------------------------------------------
    |
    | Specifies the optional formatter that the output should use for markdown.
    | Markdown content will be returned from artisense and can be formatted
    | Using any formatting tools installed wherever artisense is running.
    |
    */

    'formatter' => BasicMarkdownFormatter::class,

    /*
    |--------------------------------------------------------------------------
    | Search Preference
    |--------------------------------------------------------------------------
    |
    | Specifies the search preferences to use when querying for documentation.
    | Ordered searches are used by default, returning results using ordered
    | phrase matching. You may choose your preference to adjust results.
    |
    */

    'search' => [
        'preference' => SearchPreference::ORDERED,
        'proximity' => 10,
    ],

    /*
    |--------------------------------------------------------------------------
    | Retain Artifacts
    |--------------------------------------------------------------------------
    |
    | Specifies the artificat retention policy artisense should use when processing
    | Laravel documentation. If set to true, documentation markdown files along
    | zip archives will be retained within the storage folder during install.
    |
    */

    'retain_artifacts' => true,

];
```

Artisense has a few tuning knobs within its configuration:

- **Version**: specifies the version to run queries against, as multiple versions of the documentation may all be stored alongside one another
    - Accepts either a single `DocumentationVersion` or an array of `DocumentationVersions`, e.g.

```
return [
    // Accepts a singe version
    'versions' => DocumentationVersion::VERSION_12,

    // You may also specify multiple versions
    'versions' => [
        DocumentationVersion::VERSION_11,
        DocumentationVersion::VERSION_12,
        DocumentationVersion::MASTER,
    ],
];
```

- **Formatter**: specifies any custom formatting the markdown output should use when results are found
- **Search preference**: SQLite full-text search preference, either `ordered` or `unordered`
- **Search proximity**: relative distance between terms full-text search should consider when querying using an `unordered` preference

Usage
-----

[](#usage)

First, prepare artisense by running the install command:

```
php artisan artisense:install
```

You'll be prompted with a choice of versions to install:

```
🔧 Installing artisense...

 ┌ Which version of documentation would you like to install? ───┐
 │ › ◼ 12.x                                                     │
 │   ◻ 11.x                                                     │
 │   ◻ 10.x                                                     │
 │   ◻ master                                                   │
 └──────────────────────────────────────────────────────────────┘
  You can change the default version within the artisense.php config file.
```

Artisense uses [Laravel Prompts](https://laravel.com/docs/12.x/prompts), so any supported version of the documentation may be selected. Multiple versions of the documentation may be selected, where each will be processed and stored within the database allowing for querying across Laravel versions.

The install command will do a few things:

1. Download the Laravel markdown documentation files based on the configured version
2. Create a local SQLite database in your project within the storage folder under `storage/artisense`
3. Seed the database with the processed Laravel documentation

Usage
-----

[](#usage-1)

Artisense uses SQLite's full-text search extension [FTS5](https://www.sqlite.org/fts5.html) to query Laravel documentation. Once you've successfully installed a version of the documentation using artisense, you may use the `artisense:search` artisan command to search relevant sections:

```
php artisan artisense:search

 ┌ Enter a search term to find relevant information: ───────────┐
 │ Installing Reverb, handling Stripe webhooks, etc.            │
 └──────────────────────────────────────────────────────────────┘
  Use at least a few characters to get relevant results.
```

If any relevant documentation is found, matches will be displayed in the terminal:

```
 ┌ Enter a search term to find relevant information: ───────────────┐
 │ pennant                                                          │
 ├──────────────────────────────────────────────────────────────────┤
 │   2407 - 12.x - Laravel Pennant - Configuration                ┃ │
 │   2406 - 12.x - Laravel Pennant - Installation                 │ │
 │   2433 - 12.x - Laravel Pennant - Store Configuration          │ │
 └──────────────────────────────────────────────────────────────────┘
  Use at least a few characters to get relevant results.
```

and if you select an entry:

> Laravel Pennant - Defining Features Externally - 12.x
>
> ### Defining Features Externally
>
> [](#defining-features-externally)
>
> If your driver is a wrapper around a third-party feature flag platform, you will likely define features on the platform rather than using Pennant's `Feature::define` method. If that is the case, your custom driver should also implement the `Laravel\Pennant\Contracts\DefinesFeaturesExternally` interface:
>
> ```
>
