{"id":16060497,"url":"https://github.com/geerlingguy/ping","last_synced_at":"2025-05-15T08:05:35.806Z","repository":{"id":4880945,"uuid":"6036232","full_name":"geerlingguy/Ping","owner":"geerlingguy","description":"A PHP class to ping hosts.","archived":false,"fork":false,"pushed_at":"2023-07-10T23:12:58.000Z","size":63,"stargazers_count":470,"open_issues_count":3,"forks_count":154,"subscribers_count":22,"default_branch":"1.x","last_synced_at":"2025-04-07T02:19:45.445Z","etag":null,"topics":["class","linux","mac","macos","network-tools","networking","packagist","php","ping","windows"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/geerlingguy/ping","language":"PHP","has_issues":true,"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/geerlingguy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"github":"geerlingguy","patreon":"geerlingguy"}},"created_at":"2012-10-01T20:58:47.000Z","updated_at":"2025-04-03T19:01:55.000Z","dependencies_parsed_at":"2022-09-25T04:01:06.307Z","dependency_job_id":"cca763c8-5652-420e-906e-6ba1ab31cec3","html_url":"https://github.com/geerlingguy/Ping","commit_stats":{"total_commits":59,"total_committers":15,"mean_commits":3.933333333333333,"dds":"0.35593220338983056","last_synced_commit":"0b932537042353dcdc4d07a08926f0277aa3b85d"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geerlingguy%2FPing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geerlingguy%2FPing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geerlingguy%2FPing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geerlingguy%2FPing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/geerlingguy","download_url":"https://codeload.github.com/geerlingguy/Ping/tar.gz/refs/heads/1.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248870335,"owners_count":21175019,"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":["class","linux","mac","macos","network-tools","networking","packagist","php","ping","windows"],"created_at":"2024-10-09T04:04:49.251Z","updated_at":"2025-04-14T11:25:42.280Z","avatar_url":"https://github.com/geerlingguy.png","language":"PHP","readme":"\u003cimg src=\"https://raw.githubusercontent.com/geerlingguy/Ping/1.x/Resources/Ping-Logo.png\" alt=\"Ping for PHP Logo\" /\u003e\n\n# Ping\n\n[![Build Status](https://travis-ci.org/geerlingguy/Ping.svg?branch=1.x)](https://travis-ci.org/geerlingguy/Ping)\n\nA PHP class to ping hosts.\n\nThere are a ton of different methods of pinging a server using PHP, and I've found most to be poorly documented or downright dangerous in their implementation.\n\nTherefore, I've created this simple class, which incorporates the three most popular ping methods (`exec()` with the system's `ping` utility, `fsockopen()`, and `socket_create()`). Each method has its benefits and drawbacks, and may work better or worse on a particular system.\n\n## Installation\n\n```\n$ composer require geerlingguy/ping\n```\n\n## Usage\n\nThis is a very simple class. Just create an instance, and run `ping()`.\n\n```php\n$host = 'www.example.com';\n$ping = new \\JJG\\Ping($host);\n$latency = $ping-\u003eping();\nif ($latency !== false) {\n  print 'Latency is ' . $latency . ' ms';\n}\nelse {\n  print 'Host could not be reached.';\n}\n```\n\nYou can also specify the ttl (maximum hops) and timeout when creating the instance:\n\n```php\n$ttl = 128;\n$timeout = 5;\n$ping = new \\JJG\\Ping($host, $ttl, $timeout);\n```\n\n...or using the `setTtl()` or `setTimeout()` methods:\n\n```php\n$ping = new \\JJG\\Ping($host);\n$ping-\u003esetTtl(128);\n$ping-\u003esetTimeout(5);\n```\n\nYou can change the host using the `setHost()` method:\n\n```php\n$ping = new \\JJG\\Ping($host);\n...\n$ping-\u003esetHost('www.anotherexample.com');\n```\n\n## License\n\nPing is licensed under the MIT (Expat) license. See included LICENSE.md.\n\n## Author\n\nPing is maintained by [Jeff Geerling](https://www.jeffgeerling.com), and is used to check servers for [Server Check.in](https://servercheck.in), an inexpensive website and server uptime monitoring service.\n","funding_links":["https://github.com/sponsors/geerlingguy","https://patreon.com/geerlingguy"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeerlingguy%2Fping","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeerlingguy%2Fping","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeerlingguy%2Fping/lists"}