takuya/php-plocate-wrapper

plocate search wrapper

0.3.3 2025-03-04 15:28 UTC

This package is auto-updated.

Last update: 2025-03-04 15:28:40 UTC


README

php wrapper for plocate and plocate-build command for search files

find files by plocate db

search files using locate.db(plocate database)

<?php
$locate = new LocateWrap();
$ret = $locate->search('composer.json');
foreach ($ret as $item) {
  var_dump($item);
}

find files from sub-directory ( not from / )

We can find files from only sub-directory by shell.

## build file database only ~/Documents
subdir=/home/takuya/Documemts
cd $subdir 
find . -type f -printf '%P\n' > find-results.txt
plocate-build -p find-results.txt my-document.db
## find from using custom database
plocate -d my-document.db .docx

This project is aimed to build that database. sample code is below.

<?php
$builder = new LocateDbBuilder('~/.Document.db','~/Document');
$builder->build();

$locate = new LocateWrap('~/.Document.db');
$found = $locate->search('.docx');

Installing

from GitHub.

name='php-plocate-wrapper'
composer config repositories.$name \
vcs https://github.com/takuya/$name  
composer require takuya/$name:master
composer install

from packagist

composer require takuya/php-plocate-wrapper