Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Commit f59feaa

Browse files
committed
Fix README.MD with info on missing checks, cleanup composer.json.
1 parent 5348559 commit f59feaa

File tree

2 files changed

+158
-16
lines changed

2 files changed

+158
-16
lines changed

README.md

+156-10
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,35 @@ ZendDiagnostics
33

44
Simple component for performing diagnostic tests in real-world PHP applications.
55

6-
It currently ships with the following Checks: [Callback](#callback), [ClassExists](#classexists),
7-
[CpuPerformance](#cpuperformance), [DirReadable](#dirreadable), [DirWritable](#dirwritable),
8-
[DiskFree](#diskfree), [ExtensionLoaded](#extensionloaded), [PhpVersion](#phpversion),
9-
[SteamWrapperExists](#streamwrapperexists).
10-
11-
## Using diagnostics with Symfony 2
12-
13-
Work in progress: https://github.com/liip/LiipMonitorBundle/pull/33
6+
It currently ships with the following Diagnostic Checks:
7+
8+
* [ApcFragmentation](#apcfragmentation) - check if APC memory fragmentation is below given threshold,
9+
* [ApcMemory](#apcmemory) - check available APC memory,
10+
* [Callback](#callback) - call a user-defined diagnostic function,
11+
* [ClassExists](#classexists) - make sure class exists in current environment,
12+
* [CpuPerformance](#cpuperformance) - check server CPU performance is above baseline,
13+
* [DirReadable](#dirreadable) - make sure given path is readable,
14+
* [DirWritable](#dirwritable) - make sure given path is writable,
15+
* [DiskFree](#diskfree) - check there's enough free space on given path,
16+
* [ExtensionLoaded](#extensionloaded) - make sure extension is loaded,
17+
* [HttpService](#httpservice) - check if given http host is responding,
18+
* [Memcache](#memcache) - check if memcache extension is loaded and given server is reachable,
19+
* [PhpVersion](#phpversion) - make sure that PHP version matches constraint,
20+
* [PhpFlag](#phpflag) - make sure that given PHP flag (feature) is turned on or off.
21+
* [ProcessRunning](#processrunning) - check if a process with given name or ID is currently running,
22+
* [SecurityAdvisory](#securityadvisory) - check installed composer dependencies against SensioLabs SA database,
23+
* [SteamWrapperExists](#streamwrapperexists) - make sure given stream wrapper is available.
1424

1525
## Using diagnostics with Zend Framework 2
1626

17-
1. Install the [ZFTool module](https://github.com/zendframework/ZFTool/pulls).
27+
1. Install the [ZFTool module](https://github.com/zendframework/ZFTool).
1828
2. Enable diagnostic tests in [your application config.php](https://github.com/zendframework/ZFTool/blob/master/docs/DIAGNOSTICS.md).
1929
3. In your console type `php public/index.php diag` to run diagnostics.
2030

31+
## Using diagnostics with Symfony 2
32+
33+
Work in progress: https://github.com/liip/LiipMonitorBundle/pull/33
34+
2135
## Using diagnostics in plain PHP
2236

2337
1. Add ZendDiagnostics component to your application
@@ -222,9 +236,33 @@ ZendDiagnostics provides several "just add water" checks you can use straight aw
222236

223237
The following built-in tests are currently available:
224238

239+
### ApcFragmentation
240+
241+
Make sure that [APC memory fragmentation level](www.php.net/apc/‎) is below given threshold:
242+
243+
````php
244+
<?php
245+
use ZendDiagnostics\Check\ApcFragmentation;
246+
247+
// Display a warning with fragmentation > 50% and failure when above 90%
248+
$fragmentation = new ApcFragmentation(50, 90);
249+
````
250+
251+
### ApcMemory
252+
253+
Check [APC memory usage percent](www.php.net/apc/‎) and make sure it's below given threshold.
254+
255+
````php
256+
<?php
257+
use ZendDiagnostics\Check\ApcMemory;
258+
259+
// Display a warning with memory usage is above 70% and a failure above 90%
260+
$checkFreeMemory = new ApcMemory(70, 90);
261+
````
262+
225263
### Callback
226264

227-
Run a function (callback) and use return value as a result
265+
Run a function (callback) and use return value as the result:
228266

229267
````php
230268
<?php
@@ -341,6 +379,46 @@ $checkCompression = new ExtensionLoaded(array(
341379
));
342380
````
343381

382+
### HttpService
383+
384+
Attempt connection to given HTTP host or IP address and try to load a web page. The check also supports
385+
checking response codes and page contents.
386+
387+
````php
388+
<?php
389+
use ZendDiagnostics\Check\HttpService;
390+
391+
// Try to connect to google.com
392+
$checkGoogle = new HttpService('www.google.com');
393+
394+
// Check port 8080 on localhost
395+
$checkLocal = new HttpService('127.0.0.1', 8080);
396+
397+
// Check that the page exists (response code must equal 200)
398+
$checkPage = new HttpService('www.example.com', 80, '/some/page.html', 200);
399+
400+
// Check page content
401+
$checkPageContent = new HttpService(
402+
'www.example.com',
403+
80,
404+
'/some/page.html',
405+
200,
406+
'<title>Hello World</title>'
407+
);
408+
````
409+
410+
### Memcache
411+
412+
Attempt to connect to given Memcache server.
413+
414+
````php
415+
<?php
416+
use ZendDiagnostics\Check\Memcache;
417+
418+
$checkLocal = new Memcache('127.0.0.1'); // default port
419+
$checkBackup = new Memcache('10.0.30.40', 11212);
420+
````
421+
344422

345423
### PhpVersion
346424

@@ -356,6 +434,74 @@ $require545orNewer = new PhpVersion('5.4.5');
356434
$rejectBetaVersions = new PhpVersion('5.5.0', '<');
357435
````
358436

437+
### PhpFlag
438+
439+
Make sure that given PHP flag(s) is enabled or disabled (i.e. as defined in php.ini). You can use this test to
440+
alert the user about unsafe or behavior-changing PHP settings.
441+
442+
````php
443+
<?php
444+
use ZendDiagnostics\Check\PhpFlag;
445+
446+
// This check will fail if use_only_cookies is not enabled
447+
$sessionOnlyUsesCookies = new PhpFlag('session.use_only_cookies', true);
448+
449+
// This check will fail if safe_mode has been enabled
450+
$noSafeMode = new PhpFlag('safe_mode', false);
451+
452+
// The following will fail if any of the flags is enabled
453+
$check = new PhpFlag(array(
454+
'expose_php',
455+
'ignore_user_abort',
456+
'html_errors'
457+
), false);
458+
````
459+
460+
### PhpVersion
461+
462+
Check if current PHP version matches the given requirement. The test accepts 2 parameters - baseline version and
463+
optional [comparison operator](http://www.php.net/manual/en/function.version-compare.php).
464+
465+
466+
````php
467+
<?php
468+
use ZendDiagnostics\Check\PhpVersion;
469+
470+
$require545orNewer = new PhpVersion('5.4.5');
471+
$rejectBetaVersions = new PhpVersion('5.5.0', '<');
472+
````
473+
474+
### ProcessRunning
475+
476+
Check if a given unix process is running. This check supports PIDs and process names.
477+
478+
````php
479+
<?php
480+
use ZendDiagnostics\Check\ProcessRunning;
481+
482+
$checkApache = new ProcessRunning('httpd');
483+
484+
$checkProcess1000 = new ProcessRunning(1000);
485+
````
486+
487+
### SecurityAdvisory
488+
489+
Run a security check of libraries locally installed by [Composer](http://getcomposer.org) against
490+
[SensioLabs Security Advisory database](https://security.sensiolabs.org/database) and warn about potential
491+
security vulnerabilities.
492+
493+
````php
494+
<?php
495+
use ZendDiagnostics\Check\SecurityAdvisory;
496+
497+
// Warn about any packages that might have security vulnerabilities and require updating
498+
$security = new SecurityAdvisory();
499+
500+
// Check another composer.lock
501+
$security = new SecurityAdvisory('/var/www/project/composer.lock');
502+
````
503+
504+
359505
### SteamWrapperExists
360506

361507
Check if a given stream wrapper (or an array of wrappers) is available. For example:

composer.json

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "zendframework/zenddiagnostics",
3-
"description": "A set of interfaces for performing diagnostic tests for PHP applications",
3+
"description": "A set of components for performing diagnostic tests in PHP applications",
44
"keywords": [
55
"php",
66
"diagnostics",
@@ -25,9 +25,5 @@
2525
"ext-bcmath" : "Required by Check\\CpuPerformance",
2626
"sensiolabs/security-checker": "Required by Check\\SecurityAdvisory"
2727
},
28-
"extra": {
29-
"branch-alias": {
30-
"dev-master": "2.0.x-dev"
31-
}
32-
}
28+
"extra": {}
3329
}

0 commit comments

Comments
 (0)