Example #1
0
 /**
  * Loads the directory recursively
  * 
  * @param string $specDir
  * @param array  $ignore
  * @return array
  */
 public function load($specDir, $ignore = array())
 {
     $ignore = $this->lookForIgnoreConfig($specDir, $ignore);
     $directory = new \DirectoryIterator($specDir);
     $loaded = array();
     foreach ($directory as $file) {
         if ($file->isDot()) {
             continue;
         }
         if ($this->fileIsNotInIgnoreList($file, $ignore)) {
             if ($file->isDir()) {
                 $loaded = array_merge($loaded, $this->load($file->getRealpath(), $ignore));
             } else {
                 $example = parent::load($file->getRealpath());
                 if ($example !== false && $example !== array(false)) {
                     if (!is_array($example)) {
                         $example = array($example);
                     }
                     $loaded = array_merge($loaded, $example);
                 }
             }
         }
     }
     return $loaded;
 }
Example #2
0
 function __autoload($className)
 {
     static $stat;
     if (!$stat) {
         $stat = $_REQUEST['stat'];
     }
     $start = microtime(true);
     ClassLoader::load($className);
     $elapsed = microtime(true) - $start;
     if (empty($GLOBALS['ClassLoaderTime'])) {
         $GLOBALS['ClassLoaderTime'] = $GLOBALS['ClassLoaderCount'] = 0;
     }
     $GLOBALS['ClassLoaderTime'] += $elapsed;
     $GLOBALS['ClassLoaderCount']++;
 }
Example #3
0
 public function setUp()
 {
     parent::setUp();
     // enable route filters
     $this->app['router']->enableFilters();
     // create an artisan object for running migrations
     $artisan = $this->app->make('artisan');
     // run the migrations to create Sentry 2 tables
     $artisan->call('migrate', array('--database' => 'testbench', '--path' => '../vendor/cartalyst/sentry/src/migrations'));
     // run our migrations to update the Sentry 2 users table
     $artisan->call('migrate', array('--database' => 'testbench', '--path' => 'migrations'));
     // seed our database tables
     $artisan->call('migrate', array('--database' => 'testbench', '--path' => '../tests/seeds'));
     // Load models
     ClassLoader::addDirectories(array(realpath(__DIR__ . '/models')));
     ClassLoader::load('Foo');
     ClassLoader::load('Bar');
     ClassLoader::load('Baz');
 }
Example #4
0
<?php

/*
|--------------------------------------------------------------------------
| Register The Laravel Class Loader
|--------------------------------------------------------------------------
|
| In addition to using Composer, you may use the Laravel class loader to
| load your controllers and models. This is useful for keeping all of
| your classes in the "global" namespace without Composer updating.
|
*/
ClassLoader::addDirectories(array(app_path() . '/commands', app_path() . '/controllers', app_path() . '/models', app_path() . '/database/seeds'));
ClassLoader::load(app_path() . '/models/Subtask.php');
/*
|--------------------------------------------------------------------------
| Application Error Logger
|--------------------------------------------------------------------------
|
| Here we will configure the error logger setup for the application which
| is built on top of the wonderful Monolog library. By default we will
| build a rotating log file setup which creates a new file each day.
|
*/
$logFile = 'log-' . php_sapi_name() . '.txt';
Log::useDailyFiles(storage_path() . '/logs/' . $logFile);
/*
|--------------------------------------------------------------------------
| Application Error Handler
|--------------------------------------------------------------------------
|
Example #5
0
/**
 * Automatically load classes' files.
 *
 * @param className	the class name to be loaded.
 */
function phpUtilAutoload($className)
{
    static $classLoader = null;
    // Created just once
    if (!isset($classLoader)) {
        // File to store the directories list
        define('SUB_DIR_FILE', 'subdir.lst');
        $subDirs = array();
        if (file_exists(SUB_DIR_FILE)) {
            // Load the subdirectories from the file
            $content = file_get_contents(SUB_DIR_FILE);
            $subDirs = explode(PHP_EOL, $content);
        } else {
            // Save the subdirectories to the file
            $subDirs = DirUtil::allSubDirs('.');
            $content = implode(PHP_EOL, $subDirs);
            file_put_contents(SUB_DIR_FILE, $content, LOCK_EX);
        }
        // Here you can configure other file extensions. Example:
        // $classLoader = new ClassLoader( $subDirs,
        // 		array( '.php', '.class.php' ) );
        $classLoader = new ClassLoader($subDirs);
    }
    // Load the class
    $classLoader->load($className);
}
Example #6
0
        }
    }
});
Event::listen('APL.core.prepare', function () use($APLExtensions) {
    foreach ($APLExtensions as $Extension) {
        $full_class = "WebAPL\\" . $Extension;
        $full_class::__init();
        class_alias($full_class, $Extension);
    }
});
Event::listen('APL.modules.load', function () {
    Event::fire('APL.core.load');
    Event::fire('APL.core.prepare');
    Module::where('enabled', '1')->get()->each(function ($module) {
        ClassLoader::addDirectories(app_path() . '/modules/' . $module->extension . '/');
        ClassLoader::load($module->extension);
        Modules::addInstance($module->extension);
    });
});
$clear_cache = FALSE;
Event::listen(['eloquent.sav*', 'eloquent.upd*', 'eloquent.del*', 'eloquent.creat*'], function () use(&$clear_cache) {
    $clear_cache = TRUE;
});
App::shutdown(function () use(&$clear_cache) {
    if ($clear_cache) {
        File::deleteDirectory($_SERVER['DOCUMENT_ROOT'] . '/apps/frontend/storage/cache/');
        @unlink($_SERVER['DOCUMENT_ROOT'] . '/apps/frontend/storage/meta/services.json');
        Cache::flush();
    }
});
App::before(function () {
Example #7
0
<?php

require_once dirname(__DIR__) . '/bootstrap.php';
require_once PATH_VENDOR_ROOT . '/Slim/Slim.php';
$app = new Slim();
$app->config('templates.path', dirname(__DIR__) . '/templates');
$app->get('/', function () use($app) {
    $app->render('index.html', array());
});
$app->get('/mecab', function () use($app) {
    $sentence = $app->request()->get('s');
    $cl = new ClassLoader();
    $ret = $cl->load('Mecab');
    $mecab = new Mecab();
    /*
    $mecab_options = array(
        '-u' => PATH_RESOURCE_ROOT . '/word.dic',
    );
    */
    $ret = $mecab->parseToNode($sentence, $mecab_options);
    $app->response()->header('Content-Type', 'application/json; charset=utf-8');
    $app->response()->body(json_encode($ret));
});
$app->run();