PHPackages                             agentsib/binary-search - 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. agentsib/binary-search

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

agentsib/binary-search
======================

Binary Search Library for php

1.1.0(2y ago)0591GPL-3.0PHPPHP ^7.4|^8.0

Since Mar 6Pushed 2y ago1 watchersCompare

[ Source](https://github.com/agentsib/binary-search)[ Packagist](https://packagist.org/packages/agentsib/binary-search)[ RSS](/packages/agentsib-binary-search/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (2)Versions (3)Used By (0)

binary-search
=============

[](#binary-search)

This is a fork of [keepper/binary-search](https://github.com/keepper/binary-search), the original maintainer does not continue maintenance.

---

Binary Search Library for php

Реализация алгоритма бинарного поиска на PHP

Умеет работать с большими файлами без чтения файла целиком в память.

---

Пример использования
====================

[](#пример-использования)

1. Получаем файл при помощи
---------------------------

[](#1-получаем-файл-при-помощи)

> wget [http://www.fms.gov.ru/upload/expired-passports/list\_of\_expired\_passports.csv.bz2](http://www.fms.gov.ru/upload/expired-passports/list_of_expired_passports.csv.bz2)

2. Распаковываем
----------------

[](#2-распаковываем)

> bzip2 -d list\_of\_expired\_passports.csv.bz2

3. Сортируем
------------

[](#3-сортируем)

> sort list\_of\_expired\_passports.csv &gt; source.csv

4. Консольная утилита для поиска просроченного файла в БД недействительных паспортов ФМС
----------------------------------------------------------------------------------------

[](#4-консольная-утилита-для-поиска-просроченного-файла-в-бд-недействительных-паспортов-фмс)

> touch fms.php

Редактируем файл fms.php пишем простой код

```
include_once 'vendor/autoload.php';

if (count($argv) < 3) {
    // Вывод справки
    print "Используйте php5 test.php файл искомая строка\n";
    exit;
} else {
    // Берем атрибуты переданные с коммандной строки
    $filepath = $argv[1];
    $pattern = $argv[2];
}

// Создаем объект источник данных для поиска
$dataSource = new \BinarySearch\DataSource\FileData($filepath);

// Инициализируем класс бинарного поиска
$searcher = new \BinarySearch\BinarySearch($dataSource);

// Для отладки можем инжектировать объект логгер
//$searcher->injectLogger(new \BinarySearch\ConsoleLog());

// Производим поиск позиции в источники данных, в которой находится искомое значение
$position = $searcher->search($pattern);

if ( is_null($position) ) {
    print 'Не найдено'."\n";
    exit;
}

print 'Найдено на позиции: '.$position."\n";

// Идем на указаную позицию и читаем найденое
$dataSource->moveTo($position);
print 'Значение: ['.$dataSource->getData().']'."\n";
```

5. Пробуем (размер файла source 1,2 Гб)
---------------------------------------

[](#5-пробуем-размер-файла-source-12-гб)

### 5.1. На отсутствующем значении:

[](#51-на-отсутствующем-значении)

> time php5 ./test.php ./source.csv 5005,000435

```
Не найдено

real    0m0.095s
user    0m0.018s
sys     0m0.009s

```

### 5.2. На присутствующем значении:

[](#52-на-присутствующем-значении)

> time php5 ./test.php ./source.csv 0000,000435

```
Найдено на позиции: 434
Значение: [0000,000435]

real    0m0.104s
user    0m0.009s
sys     0m0.018s

```

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Every ~2116 days

Total

2

Last Release

922d ago

PHP version history (2 changes)1.0.0PHP ^5.5.9|^7.0

1.1.0PHP ^7.4|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/1bb08551e2cca1a2ce3f792c36ba88dd12ca69d296283d98d2a7f8d1173be205?d=identicon)[AgentSIB](/maintainers/AgentSIB)

---

Top Contributors

[![keepper](https://avatars.githubusercontent.com/u/1147352?v=4)](https://github.com/keepper "keepper (8 commits)")[![agentsib](https://avatars.githubusercontent.com/u/1577055?v=4)](https://github.com/agentsib "agentsib (7 commits)")[![thereisnobugs](https://avatars.githubusercontent.com/u/7262810?v=4)](https://github.com/thereisnobugs "thereisnobugs (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/agentsib-binary-search/health.svg)

```
[![Health](https://phpackages.com/badges/agentsib-binary-search/health.svg)](https://phpackages.com/packages/agentsib-binary-search)
```

###  Alternatives

[symfony/lock

Creates and manages locks, a mechanism to provide exclusive access to a shared resource

514139.2M660](/packages/symfony-lock)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[ecotone/ecotone

Enterprise architecture layer for Laravel and Symfony — CQRS, Event Sourcing, Durable Workflows (Sagas, Orchestrators), Projections, and Outbox messaging via PHP attributes.

564576.7k48](/packages/ecotone-ecotone)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k39](/packages/civicrm-civicrm-core)[illuminate/broadcasting

The Illuminate Broadcasting package.

7127.2M208](/packages/illuminate-broadcasting)[logiscape/mcp-sdk-php

Model Context Protocol SDK for PHP

368116.8k12](/packages/logiscape-mcp-sdk-php)

PHPackages © 2026

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