Skip to content

Instantly share code, notes, and snippets.

@adamdilek
Forked from lab2023/KebabChecker.php
Created October 13, 2011 13:39
Show Gist options
  • Save adamdilek/1284240 to your computer and use it in GitHub Desktop.
Save adamdilek/1284240 to your computer and use it in GitHub Desktop.
KebabChecker
<?php
/**
* Created by JetBrains PhpStorm.
* User: Muhammet
* Date: 19.10.2011
* Time: 05:47
* To change this template use File | Settings | File Templates.
*/
// Version.php
require_once __DIR__. '\library\Kebab\Version.php';
/**
*
*/
class checker {
function __construct()
{
$this->control();
}
/**
* @return void
*/
function control()
{
//Zend Control
if(file_exists(__DIR__. '\library\Zend\version.php')) {
require_once __DIR__. '\library\Zend\version.php';
$this->check(Zend_Version::VERSION==Kebab_Version::ZEND, 'Zend Framework version :' .zend_version::VERSION.
'but Kebab Framework requires ' .Kebab_Version::ZEND,TRUE);
} else {
$this->check(FALSE,'Zend Framework is not installed !',TRUE);
}
//Doctrine Control
if(file_exists(__DIR__.'\library\Doctrine')) {
require_once __DIR__.'\library\Doctrine\Core.php';
$this->check(Doctrine_Core::VERSION == Kebab_Version::DOCTRINE,
'Doctrine version :'.Doctrine_Core::VERSION.
'but Kebab Framework requires' .Kebab_Version::DOCTRINE,TRUE);
} else{
$this->check(FALSE,'Doctrine is not installed !',TRUE);
}
//Ext Js Control
if(file_exists(__DIR__. '\web\assets\vendors\ext-3.4.0')){
$extjs=true;
$this->check($extjs,'Ext JS version :'.Kebab_Version::EXT_JS.
'but Kebab Framework requires'.Kebab_Version::EXT_JS,TRUE);
} else{
$this->check($extjs,'Doctrine is not installed');
}
//SQLite Control
$file_patch= __DIR__. '\application\configs\database.ini';
$info= parse_ini_file($file_patch);
$text= substr($info['database.doctrine.connections.master.dsn'],0,6);
if($text=='sqlite'){
if((file_exists(__DIR__.'\application\variables\databases\kebab_production.db')==FALSE)
&& (file_exists(__DIR__.'\application\variables\databases\kebab_staging.db')==FALSE)
&& (file_exists(__DIR__.'\application\variables\databases\kebab_testing.db')==FALSE)
&& (file_exists(__DIR__.'\application\variables\databases\kebab_development.db')==FALSE)
) {
$this->check(FALSE,'SqLlite DB not found',TRUE);
}
}
//Php Control
$this->check(version_compare(PHP_VERSION,'5.2.4') >= 0,'Your server is running PHP Version:' .PHP_VERSION.
'but Kebab Framework requires at least 5.2.4.',TRUE);
//Apc control
$this->check(extension_loaded('apc'),'APC is not installed.',FALSE);
}
/**
* @param bool $bool
* @param string $error
* @param bool $is_mandatory
* @return void
*/
function check($bool, $error, $is_mandatory=FALSE)
{
if(!$bool) {
echo $is_mandatory ? 'ERROR : ':'WARNING : ';
echo $error . '<br>';
if($is_mandatory) {
exit('You must fix this problem before resuming the check.');
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment