PHP Classes

File: system/dependencies/kahlan/kahlan/bin/kahlan

Recommend this page to a friend!
  Classes of Dimitri Sitchet   dFramework   system/dependencies/kahlan/kahlan/bin/kahlan   Download  
File: system/dependencies/kahlan/kahlan/bin/kahlan
Role: Example script
Content type: text/plain
Description: Example script
Class: dFramework
Framework to build PHP applications
Author: By
Last change:
Date: 2 years ago
Size: 2,115 bytes
 

Contents

Class file image Download
#!/usr/bin/env php
<?php
if (!defined('DS')) {
   
define('DS', DIRECTORY_SEPARATOR);
}

error_reporting(E_ALL);

$pwd = realpath(getcwd());
$vendorName = 'vendor';

if (
file_exists($composerPath = "{$pwd}/composer.json")) {
   
$composerJson = json_decode(file_get_contents($composerPath), true);
   
$vendorName = isset($composerJson['config']['vendor-dir']) ? $composerJson['config']['vendor-dir'] : $vendorName;
}

$autoload = require __DIR__ . '/../autoload.php';
$autoloader = $autoload("{$pwd}/{$vendorName}");

use
Kahlan\Box\Box;
use
Kahlan\Suite;
use
Kahlan\Cli\Kahlan;
use
Kahlan\Jit\ClassLoader;

require
__DIR__ . '/../src/functions.php';
$GLOBALS['__composer_autoload_files']['337663d83d8353cc8c7847676b3b0937'] = true;

$box = \Kahlan\box('kahlan', new Box());

$box->service('suite.global', function() {
    return new
Suite();
});

$specs = new Kahlan([
   
'autoloader' => $autoloader,
   
'suite' => $box->get('suite.global')
]);
$specs->loadConfig($argv);
initKahlanGlobalFunctions();

if (
$autoloader instanceof ClassLoader) {
   
$commandLine = $specs->commandLine();
   
$autoloader->patch([
       
'include' => $commandLine->get('include'),
       
'exclude' => array_merge($commandLine->get('exclude'), ['Kahlan\\']),
       
'persistent' => $commandLine->get('persistent'),
       
'cachePath' => rtrim(realpath(sys_get_temp_dir()), DS) . DS . 'kahlan',
       
'clearCache' => $commandLine->get('cc')
    ]);

   
$specs->initPatchers();

    foreach (
$autoloader->files() as $fileIdentifier => $file) {
        if (!empty(
$GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
            continue;
        }
       
$autoloader->loadFile($file);
       
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
    }
}

if (!
file_exists("{$pwd}/{$vendorName}/autoload.php")) {
    echo
"\033[1;31mYou need to set up the project dependencies using the following commands: \033[0m" . PHP_EOL;
    echo
'curl -s http://getcomposer.org/installer | php' . PHP_EOL;
    echo
'php composer.phar install' . PHP_EOL;
    exit(
1);
}

$specs->run();
exit(
$specs->status());