{"id":18026460,"url":"https://github.com/timoschwarzer/php-tail","last_synced_at":"2025-04-04T19:47:13.957Z","repository":{"id":90393990,"uuid":"80374328","full_name":"timoschwarzer/php-tail","owner":"timoschwarzer","description":"A smart way to tail files depending of the environment","archived":false,"fork":false,"pushed_at":"2017-01-29T21:46:21.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-10T04:41:27.621Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/timoschwarzer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-29T21:36:36.000Z","updated_at":"2018-06-07T06:05:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"6471e78f-ff61-4b77-8fe3-347eab89e4c1","html_url":"https://github.com/timoschwarzer/php-tail","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timoschwarzer%2Fphp-tail","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timoschwarzer%2Fphp-tail/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timoschwarzer%2Fphp-tail/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timoschwarzer%2Fphp-tail/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timoschwarzer","download_url":"https://codeload.github.com/timoschwarzer/php-tail/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247240144,"owners_count":20906772,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-30T08:06:50.741Z","updated_at":"2025-04-04T19:47:13.938Z","avatar_url":"https://github.com/timoschwarzer.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# php-tail\nA smart way to tail files depending of the environment\n\n## Installation\n\nThe installation of this library is made via composer.\nDownload `composer.phar` from [their website](https://getcomposer.org/download/).\nThen add to your composer.json :\n\n```json\n\t\"require\": {\n\t\t...\n\t\t\"php-extended/php-tail\": \"^2.0\",\n\t\t...\n\t}\n```\n\nThen run `php composer.phar update` to install this library.\nThe autoloading of all classes of this library is made through composer's autoloader.\n\n## Usage\n\nThe basic usage of this library is as follows :\n\n```php\nuse PhpExtended\\Tail\\Tail;\nuse PhpExtended\\Tail\\TailException;\n\n$filename = \"/../path/to/my/file.ext\";\n$tail = new Tail($filename);\n\ntry\n{\n\t// 10 is the number of lines you want\n\t// 200 is the average number of chars on each line (optional)\n\t// false is to force throwing exceptions (optional, use true if you want silent mode)\n\t$lines = $tail-\u003esmart(10, 200, false);\n}\ncatch(TailException $e)\n{\n\t// do something is case it fails\n}\n\n```\n\nThis library proposes 6 methods to tail a file, which can be more or less \nperformant depending on the context. They each follow the same signature \n(see sample code above).\n\nThose methods are :\n- `naive` : Loads the whole file into php, then retains only the last lines\n- `cheat` : Uses underlying unix `tail -n` function\n- `single` : Uses a signle byte buffer to read backwards the file\n- `simple` : Uses a fixed size buffer to read backwards the file\n- `dynamic` : Uses a dynamically sized buffer to read backwards the file\n- `smart` : Tries to choose the best among those five to be the fastest (recommanded)\n\nThis library is inspired from this [specific stackoverflow topic](http://stackoverflow.com/questions/15025875/what-is-the-best-way-in-php-to-read-last-lines-from-a-file/15025877).\n\n\n## License\nMIT (See [license file](LICENSE)).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimoschwarzer%2Fphp-tail","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimoschwarzer%2Fphp-tail","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimoschwarzer%2Fphp-tail/lists"}