Download the PHP package wire-elements/spotlight without Composer

On this page you can find all versions of the php package wire-elements/spotlight. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package spotlight

Total Downloads Total Downloads Latest Stable Version License

About Wire Elements Spotlight

Wire Elements Spotlight is a Livewire component that provides Spotlight/Alfred-like functionality to your Laravel application. View demo video.

Installation

Laravel Spotlight Tutorial

Click the image above to read a full article on using the Wire Elements Spotlight package or follow the instructions below.

To get started, require the package via Composer:

Livewire directive

Add the Livewire directive @livewire('livewire-ui-spotlight'):

Alpine (only when using Livewire v2)

Spotlight requires Alpine. You can use the official CDN to quickly include Alpine:

Opening Spotlight

To open the Spotlight input bar you can use one of the following shortcuts:

You can customize the keybindings in the configuration file (see below). It's also possible to toggle Spotlight from any other Livewire component or via Javascript.

In any Livewire component you can use the dispatchBrowserEvent or dispatch helper.

You can also use the $dispatch helper from Alpine to trigger the same browser event from your markup.

Creating your first Spotlight command

You can create your first Spotlight command by creating a new class and have it extend LivewireUI\Spotlight\SpotlightCommand. Start by defining a $name and $description for your command. The name and description will be visible when searching through commands.

To help you get started you can use the php artisan make:spotlight <command-name> command.

The execute method is called when a command is chosen, and the command has no dependencies. Let's for example take a look at the Logout command execute method:

As you can see, you can type-hint your dependencies and have them resolved by Laravel. If you type-hint Spotlight $spotlight, you will get access to the Livewire Spotlight component. This gives you access to all the Livewire helpers, so you can redirect users, emit events, you name it.

How to define search synonyms

Sometimes you may want to include additional search terms (often called synonyms) when searching for commands. This can be useful if users refer to something by multiple names or the command may include more than one piece of functionality (for example, a settings page that has multiple types of settings on it). You can add as many synonyms as you want directly on a command by defining a $synonyms array:

When searching, users can now enter "credit card" and they'll be shown a search result for the View Billing Settings command.

How to define command dependencies

In some cases your command might require dependencies. Let's say we want to create a new user and add it to a specific team. In this case we would need to define a team dependency. To define any dependencies, add a new method to your command and name the method dependencies.

You can use the SpotlightCommandDependencies::collection() method to create a new collection of dependencies. Call the add method to register a new dependency. You can add as many of dependencies as you like. The user input prompt follows the order in which you add the commands.

For every dependency, Spotlight will check if a search{dependency-name} method exists on the command. This method provides the search query given by the user. For example, to search for our team dependency:

Spotlight expects a collection of SpotlightSearchResult objects. The SpotlightSearchResult object consists out of the result identifier, name and description.

Every dependency will have access to the already defined dependencies. So in the example below, you can see that searchFoobar has access to the Team the user has chosen. This allows for scoped dependency searching.

Register commands

You can register commands by adding these to the livewire-ui-spotlight.php config file:

It's also possible to register commands via one of your service providers:

Alternatively, you can also conditionally show or hide a command from the command itself. (Note: you will still need to register your command in your config file or in a service provider.) Add the shouldBeShown method to your command and add any logic to resolve if the command should be shown. Dependencies are resolved from the container, so you can for example verify if the currently authenticated user has the required permissions to access given command:

If you need to do logic that can't be done in a service provider (for example, any logic that needs to use the currently authenticated user) to determine if your command should be shown in the Spotlight component, you can add a shouldBeShown method on your command. You can type-hint any dependencies you need and they'll be resolved out of the container for you. (Note: you will still need to register your command in your config file or in a service provider.)

Configuration

You can customize Spotlight via the livewire-ui-spotlight.php config file. This includes some additional options like including CSS if you don't use TailwindCSS for your application. To publish the config run the vendor:publish command:

If you want to translate or change default the placeholder you will need to publish the translation file.

If you want to change the spotlight view, you can also publish the views.

Credits

License

Wire Elements is open-sourced software licensed under the MIT license.

Beautiful components crafted with Livewire


All versions of spotlight with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/contracts Version ^8.0|^9.0|^10.0|^11.0
livewire/livewire Version ^3.0
spatie/laravel-package-tools Version ^1.4.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package wire-elements/spotlight contains the following files

Loading the files please wait ....