PHPackages                             morphcms/command-palette-module - 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. morphcms/command-palette-module

ActiveLaravel-module[Utility &amp; Helpers](/categories/utility)

morphcms/command-palette-module
===============================

0.0.0(3y ago)03PHP

Since Jul 11Pushed 3y agoCompare

[ Source](https://github.com/morphcms/command-palette-module)[ Packagist](https://packagist.org/packages/morphcms/command-palette-module)[ RSS](/packages/morphcms-command-palette-module/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (3)Used By (0)

Command Palette
===============

[](#command-palette)

Installation
------------

[](#installation)

```
php artisan module:install morphcms/command-palette-module
```

via Composer

You have to paste the repository path within your `composer.json` file.

```
{
    "repositories": [
        {
            "type": "vcs",
            "url": "git@github.com:morphcms/command-palette-module.git"
        }
    ]
}
```

Then run:

```
composer require morphcms/command-palette-module
```

Usage
-----

[](#usage)

From within your module service provider or EventServiceProvider you can register your listeners to the `CommandSearch`event.

```
CommandSearch::class => [
    // Register your listeners here.
],
```

The listener must extend the `CollectionSearchListener` or the `CommandSearchListener`.

Perform a command search to the `api` route `/commands/search`.

Request Parameters:

```
'query' => ['required', 'string'],
'limit' => ['sometimes', 'numeric', 'min:1', 'max:100'],
'args' => ['array', 'nullable'],
'args.*' => [],
'options' => ['array', 'nullable'],
'options.*' => [],
```

Returns an array of `SearchResult`.

```
{
    "group": [
        {
            "type": "resource-type",
            "meta": []
        }
    ],
    "blog": [
        {
            "type": "posts",
            "title": "My first post",
            "icon": "DocumentText",
            "description": "Some post summary.",
            "group": "blog",
            "meta": []
        }
    ]
}
```

Creating a CollectionSearchListener
-----------------------------------

[](#creating-a-collectionsearchlistener)

The `CollectionSearchListener` is used when you want to hardcode a list of `SearchResult` that will be searched using the 'contains' method.

```
use Modules\CommandPalette\ActionTypes\NavigateAction;
use Modules\CommandPalette\ActionTypes\ToastAction;
use Modules\CommandPalette\DTO\SearchResult;
use Modules\CommandPalette\Enums\CommandIcon;
use Modules\CommandPalette\Listeners\CollectionSearchListener;

class GeneralCommandsSearchListener extends CollectionSearchListener
{
    public function items(): array
    {
        return [
            SearchResult::make('Greet') // The command title that will also be searched
                ->group('Admin') // Just a name to nicely group results
                ->icon(CommandIcon::LightningBolt) // Uses Hero Icons package
                ->description('Says hello back to you.') // A summary of what this command or this result does.
                ->action(ToastAction::make()->message('Hello, '.auth()->user()->name.'!')), // Action is catched on the frontend, this should send a payload
        ];
    }
}
```

Creating a CommandSearchListener
--------------------------------

[](#creating-a-commandsearchlistener)

The `CommandSearchListener` is the base listener where you have to implement the way you search and fetch the results. It must return a **collection** of `SearchResult`

```
namespace App\Listeners;

use Illuminate\Support\Collection;
use Modules\Blog\Models\Post;
use Modules\CommandPalette\ActionTypes\NavigateAction;
use Modules\CommandPalette\DTO\SearchResult;
use Modules\CommandPalette\Enums\CommandIcon;
use Modules\CommandPalette\Events\CommandSearch;
use Modules\CommandPalette\Listeners\CommandSearchListener;

class GeneralCommandsSearchListener extends CommandSearchListener
{
    protected function search(CommandSearch $event): Collection|null
    {
        return Model::search($event->query)
            ->limit($event->limit)
            ->get()
            ->map(fn (Model $model) =>
                SearchResult::make(
                    title: $model->title,
                    type: 'resource_name',
                )->group('Resource Name')
                 ->icon(CommandIcon::Sparkles)
                 ->action(NavigateAction::make(['id' => $model->id]))
            );
    }
}
```

Examples of Search Listeners
----------------------------

[](#examples-of-search-listeners)

### Blog posts example

[](#blog-posts-example)

```
namespace App\Listeners\Commands;

use Illuminate\Support\Collection;
use Modules\Blog\Models\Post;
use Modules\Shop\Enums\ProductStatus;

use Modules\CommandPalette\ActionTypes\NavigateAction;
use Modules\CommandPalette\DTO\SearchResult;
use Modules\CommandPalette\Enums\CommandIcon;
use Modules\CommandPalette\Events\CommandSearch;
use Modules\CommandPalette\Listeners\CommandSearchListener;

class BlogCommandsSearchListener extends CommandSearchListener
{
    // This implementation uses Scout for search
    protected function search(CommandSearch $event): Collection|null
    {
        return Post::search($event->query)
            ->query(fn ($q) => $q->where('status', ProductStatus::Published->value))
            ->get()
            ->map(fn (Post $post) => SearchResult::make(
                title: $post->title,
                type: 'post',
            )->group('Blog')
                ->icon(CommandIcon::DocumentText)
                ->action(NavigateAction::make(['slug' => $post->slug]))
            );
    }
}
```

### Custom commands example with authorization

[](#custom-commands-example-with-authorization)

```
namespace App\Listeners\Commands;

use Laravel\Nova\Nova;use Modules\CommandPalette\ActionTypes\NavigateAction;
use Modules\CommandPalette\ActionTypes\ToastAction;
use Modules\CommandPalette\DTO\SearchResult;
use Modules\CommandPalette\Enums\CommandIcon;
use Modules\CommandPalette\Listeners\CollectionSearchListener;

class AdminCommandsSearchListener extends CollectionSearchListener
{
    public function authorize(): bool
    {
        return auth()->check() && auth()->user()->is_admin;
    }

    public function items(): array
    {
        return [
            SearchResult::make('Create Product')
                ->group('Admin')
                ->icon(CommandIcon::LightningBolt)
                ->action(
                    NavigateAction::make([
                        'url' => Nova::url('/resources/products/new'),
                ])),
        ];
    }
}
```

Command Actions
---------------

[](#command-actions)

The `CommandAction` type is nothing more than a data transfer object with a fluent API.

The only two required attributes are `type` and `meta`.

### Creating a `CustomAction`

[](#creating-a-customaction)

```
namespace Modules\CommandPalette\ActionTypes;

use Modules\CommandPalette\DTO\CommandAction;

class MyCommandAction extends CommandAction
{
    public function __construct(array $meta = [])
    {
        parent::__construct('my-type', $meta);
    }
}
```

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1408d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f68765a77418f8056ef39ed2491f2b2b544a58166a462bf3d5f1332d539241d4?d=identicon)[codrin-axinte](/maintainers/codrin-axinte)

---

Top Contributors

[![codrin-axinte](https://avatars.githubusercontent.com/u/6564791?v=4)](https://github.com/codrin-axinte "codrin-axinte (1 commits)")

### Embed Badge

![Health badge](/badges/morphcms-command-palette-module/health.svg)

```
[![Health](https://phpackages.com/badges/morphcms-command-palette-module/health.svg)](https://phpackages.com/packages/morphcms-command-palette-module)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
