By default, it uses the ripgrep (https://github.com/BurntSushi/ripgrep) to search for files matching your criteria.
You are free to create your own search driver
To get the result on the frontend as quickly as possible, I recommend using websockets
You can use for example soketi (https://github.com/soketi/soketi), or third-party services like pusher on the server side, and Laravel echo (https://github.com/laravel/echo) on the frontend
When the match is found, it triggers Link000\Finder\Events\SearchResultFoundEvent
event
You can implement your own listener and handle the event by yourself
In that case, I recommend turning off the broadcasting functionality provided by the package, by setting the broadcasting.method
config to empty value
- find
- ripgrep
php artisan vendor:publish --provider="Link000\Finder\FinderServiceProvider" --tag="config"
and adjust settings in the config/finder.php
file
config('finder.search_base_path')
config('finder.search_base_path', '/my/custom/path')
Config name | Default value | Description |
---|---|---|
route_prefix | finder |
Prefix for default routes provided by package (located in routes/finder.php) |
route_middlewares | ['web'] |
Middlewares for default routes provided by package (located in routes/finder.php) |
Config name | Default value | Description |
---|---|---|
broadcasting.broadcast_name | Link000\Finder\Events\SearchResultFoundBroadcastEvent |
Event name you will listen to on the frontend |
broadcasting.channel_name | finder.results |
If you use private channel, user id will be automatically appended, so the final channel will be in the format finder.results.{user_id} |
broadcasting.channel_type | private |
[public/private] User must be authenticated, otherwise public will be used |
broadcasting.method | websockets |
Broadcast every search result using websockets. If you change or leave it blank, you will disable the broadcasting provided by the package |
Config name | Default value | Description |
---|---|---|
search_base_path | base_path() |
Where to search |
driver | env('FINDER_DRIVER', 'rg') |
Active search driver |
drivers | ['rg' => Link000\Finder\Drivers\RipGrepSearchDriver::class] |
Registered search drivers (you can change during runtime) |
broadcast_method broadcasting.broadcast_name broadcasting.channel_type (public/private, if user is not authenticated, it will fallback to the public channel) broadcasting.channel_name
You can add custom search driver by implementing the Link000\Finder\Interfaces\FinderInterface
- Create your custom driver and implement
Link000\Finder\Interfaces\FinderInterface
- Add your driver including the full namespace into the finder.drivers config
// ... other configs
'drivers' => [
'my_custom_driver' => App\Drivers\MyCustomSearchDriver::class,
],
- activate your driver
- by changing
ENV
variable
FINDER_DRIVER='my_custom_driver'
- by changing
finder.driver
config
// ... other configs 'driver' => 'my_custom_driver',
- or setting the driver at the runtime
use Link000\Finder\Interfaces\FinderInterface class YourController { protected FinderInterface $finderService; public function __construct(FinderInterface $finderService) { $this->finderService = $finderService; } public function search() { // use your driver dynamically $this->finderService->setDriver(app(MyCustomSearchDriver::class)); } }
- by changing
This installs pre-defined stack with routes, controllers, services, styles etc.
I recommend to have a clean git working tree, so you can see newly created files
You should customize or remove unnecessary to fit your current application
vue
(vue + inertia, tailwind)blade
(blade, tailwind)api
(routes only)
php artisan finder:install
add to your application composer.json:
"repositories": [
{
"type": "path",
"url": "/packages/*",
"options": {
"symlink": true
}
}
]
This instructs composer to look for packages in the /packages and creates a symlink to the installed package
symlink:false
will copy the package into the vendor directory, instead of creating a symlink (default behavior)
composer update