Laravel Local File Finder Package is a simple laravel package that allow finding a file by CONTENT (currently only for .txt file).
- List default storage directories and files.
- Search files and directories By Name.
- Search files by Content.
- [Swagger UI] (http://host:port/file-finder/api/docs)
- Create Laravel Project
$ composer create-project --prefer-dist laravel/laravel laravel_file_finder_5.6_test "5.6.*"
- Add FileFinder Package
$ cd laravel_file_finder_5.6_test
$ composer require muharihar/file-finder
- Publish Assets and Default Data Samples
$ php artisan vendor:publish --tag=public --force
- Add FileFinder Service Provider to laravel application config (config/app.php)
/*
* Package Service Providers...
*/
Muharihar\FileFinder\ServiceProviders\FileFinderServiceProvider::class,
- Running Application
$ php artisan serve
- Open Swagger UI for testing the features: http://127.0.0.1:8000/file-finder/api/docs
Command:
$ curl -v -X GET "http://localhost:8000/file-finder/api/v1.0/default/list-dir-and-files" -H "accept: application/json"
Sample Result: sampleResponse
Command:
$ curl -X GET "http://localhost:8000/file-finder/api/v1.0/search/by-name?s=b" -H "accept: application/json"
Sample Result:
{
"searchKey": "b",
"results": [
{
"idx": 2,
"isDir": true,
"shortPath": "public/file-finder/folder_animals/folder_birds",
"extension": "",
"fileSize": 0,
"parentPath": "public/file-finder/folder_animals"
},
{
"idx": 12,
"isDir": true,
"shortPath": "public/file-finder/folder_fruits/folder_berries",
"extension": "",
"fileSize": 0,
"parentPath": "public/file-finder/folder_fruits"
},
{
"idx": 13,
"isDir": false,
"shortPath": "public/file-finder/folder_fruits/folder_berries/file_berries_list.txt",
"extension": "txt",
"fileSize": 44,
"parentPath": "public/file-finder/folder_fruits/folder_berries"
},
{
"idx": 26,
"isDir": false,
"shortPath": "public/file-finder/folder_geolocations/folder_cities/file_bg.txt",
"extension": "txt",
"fileSize": 633,
"parentPath": "public/file-finder/folder_geolocations/folder_cities"
}
],
"resultCount": 4
}
Command:
$ curl -X GET "http://localhost:8000/file-finder/api/v1.0/search/by-content?s=Obama" -H "accept: application/json"
Sample Result:
{
"searchKey": "Obama",
"results": [
{
"idx": 41,
"isDir": false,
"shortPath": "public/file-finder/folder_peoples/folder_presidents/file_us.txt",
"extension": "txt",
"fileSize": 6713,
"parentPath": "public/file-finder/folder_peoples/folder_presidents",
"info": {
"firstPos": 6580,
"firstStr": "...Obama,http://en.wikipedia.org/wiki/Barack_Obama,20"
}
}
],
"resultCount": 1
}