joeymckenzie / artisense
Laravel docs from the comfort of your own terminal.
Requires
- php: ^8.4
- ext-zip: *
- illuminate/contracts: ^12.0
- league/commonmark: ^2.7
Requires (Dev)
- ext-pdo: *
- larastan/larastan: ^v3.4.0
- laravel/pint: ^v1.22.1
- nunomaduro/collision: v8.8.0
- orchestra/testbench: ^v10.3.0
- peckphp/peck: ^0.1.3
- pestphp/pest: ^v3.8.2
- pestphp/pest-plugin-arch: ^v3.1.1
- pestphp/pest-plugin-laravel: ^v3.2.0
- pestphp/pest-plugin-type-coverage: ^3.5
- pestphp/pest-plugin-watch: ^3.0
- phpstan/extension-installer: ^1.4.3
- phpstan/phpstan-deprecation-rules: ^2.0.3
- phpstan/phpstan-phpunit: ^2.0.6
- rector/rector: ^2.0
README

Artisense 📕
Laravel docs from the comfort of your terminal.
Table of Contents
Getting started
You can install artisense with composer:
composer require joeymckenzie/artisense
You can also publish the config file with:
php artisan vendor:publish --tag="artisense-config"
This will create the following config/artisense.php
file:
return [ /* |-------------------------------------------------------------------------- | Artisense Status |-------------------------------------------------------------------------- | | This option controls whether Artisense is enabled for your application. | When enabled, Artisense features are available throughout your app. | Set this value as false disable Artisense functionality entirely. | */ 'enabled' => true, /* |-------------------------------------------------------------------------- | 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. | */ 'version' => 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' => null, ];
Usage
First, prepare artisense by running the install command:
php artisan artisense:install
The install command will do a few things:
- Download the Laravel markdown documentation files based on the configured version
- Create a local SQLite database in your project within the storage folder under
storage/artisense
- Seed the database with the parsed Laravel documentation
Artisense allows for multiple versions of documentation to coincide with one another. For instance, running the above
command with the default settings will seed documentation within the database for the latest stable version. However,
you may also re-run installation with an updated version value within the artisense.php
:
return [ // Other configuration... 'version' => DocumentationVersion::MASTER, ];
You may also install versions by explicitly passing a --version
flag to the install command:
php artisan artisense:install --version "12.x" // (10.x, 11.x, master, etc.)
Usage
Artisense uses SQLite's full-text search extension FTS5 to store Laravel
documentation.
Once you've successfully installed a version of the documentation using artisense, you may use the docs
artisense
artisan
command to search relevant sections:
php artisan artisense:docs
┌ What are you looking for? ───────────────────────────────────┐
│ enum validation │
└──────────────────────────────────────────────────────────────┘
If any relevant documentation is found, artisense will display it within your terminal:
🔍 Found relevant information:
Validation - enum
enum
The
Enum
rule is a class based rule that validates whether the field under validation contains a valid enum value. TheEnum
rule accepts the name of the enum as its only constructor argument. When validating primitive values, a backed Enum should be provided to theEnum
rule:use App\Enums\ServerStatus; use Illuminate\Validation\Rule; $request->validate([ 'status' => [Rule::enum(ServerStatus::class)], ]); The `Enum` rule's `only` and `except` methods may be used to limit which enum cases should be considered valid: ```php Rule::enum(ServerStatus::class) ->only([ServerStatus::Pending, ServerStatus::Active]); Rule::enum(ServerStatus::class) ->except([ServerStatus::Pending, ServerStatus::Active]);The
when
method may be used to conditionally modify theEnum
rule:use Illuminate\Support\Facades\Auth; use Illuminate\Validation\Rule; Rule::enum(ServerStatus::class) ->when( Auth::user()->isAdmin(), fn ($rule) => $rule->only(...), fn ($rule) => $rule->only(...), );Learn more: https://laravel.com/docs/12.x/validation#enum
By default, artisense returns the raw markdown it that was used to find the relevant section. A link to the section within the documentation is also included.
Artisense uses Laravel Prompts, though you may also pass a --search
flag to
the docs
command:
php artisan artisense:docs --search "enum validation"
Using full-text search, artisense will attempt to find relevant sections, returning three entries by default. You
may configure this with the --limit
flag for the docs
command:
php artisan artisense:docs --search "enum validation" --limit 5
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.