PHP Service Health Class
EN: A class to check or test web site's properties. Results will listing via true or false results of given functions.
TR: PHP ile oluşturduğunuz sitenizin özelliklerini test etmenizi kolaylaştıracak bir sınıf. Gerekli fonksiyonları tanımlayarak, fonksiyonun döndürdüğü True/False değerine göre çalışmayan özellikler rapor edilir.
require 'SmartTest.php';
$test = SmartTest::getInstance();
$test->test_function("gzip function is avaliable.", "gzcompress");
$test->test_extension("php-gd module is exist.", "gd");
$test->test_writable("tmp/cookie.txt file is writable.", "tmp/cookie.txt");
$test->test_file_exist("bootstrap-theme.css is exist.", "css/bootstrap-theme.css");
This function is only for "Mysqli". Bu özellik sadece "Mysqli" ile bağlantı kurulurken kullanılabilir.
$test->test("Veritabanı bağlantısı", function() use ($test) {
$con = new mysqli("localhost", "username", "password", "database");
if (mysqli_connect_errno()) {
$test->stop(); // Stop all test functions. Because other functions will return false.
return false;
}
return true;
});
$test->test("Kitapçı ajax", function() use ($test) {
$response = $test->get("http://www.kitabyte.com/ajax/bookstore");
return count($response->bookstore) > 0;
});
$test->test("Kullanıcı arama", function() use ($test) {
$response = $test->get("http://www.kitabyte.com/");
return count($response) > 0;
});
$test->test("Post ile erişmek", function () use ($test) {
$fields = array("field1" => "data", "field2" => 123);
$response = $test->post("http://www.kitabyte.com/test", $fields);
if ($response->success) {
return true;
} else {
return false;
}
}
return false;
});
$test->run();
<!DOCTYPE html>
<html lang="tr">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Kitabyte System Health</title>
<!-- Bootstrap -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<?php
$test->run();
?>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</body>
</html>
Bu kaynak kod MIT lisansı ile lisanslanmıştır. This source code is licensed under MIT License.