本文整理汇总了PHP中Application::init方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::init方法的具体用法?PHP Application::init怎么用?PHP Application::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Application
的用法示例。
在下文中一共展示了Application::init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
static function run()
{
if (!self::$init) {
self::$init = true;
self::init();
}
$route = Router::dispatch();
if (!empty($route)) {
if (is_callable($route['callback'])) {
call_user_func_array($route['callback'], $route['params']);
} else {
if (strpos($route['callback'], '@') !== false) {
$pieces = explode('@', $route['callback']);
$route['action'] = $pieces[1];
$route['controller'] = $pieces[0];
} else {
$route['action'] = 'index';
$route['controller'] = $route['callback'];
}
self::loadRoute($route);
}
} else {
call_user_func(self::$error404);
}
}
示例2: __construct
/**
* 构造函数
*
* @access public
* @param String $ini
* @return void
*/
private function __construct($ini)
{
require_once __DIR__ . '/application.php';
Application::init($ini);
$this->config = \Myfox\Lib\Config::instance('default');
$this->prefix = rtrim($this->config->get('url.prefix', ''), '/');
$logurl = $this->config->get('log/default');
if (empty($logurl)) {
$this->log = new \Myfox\Lib\BlackHole();
} else {
$this->log = new \Myfox\Lib\Log($logurl);
}
}
示例3: __construct
/**
* 构造函数
*
* @access private
* @return void
*/
private function __construct($ini, $class, $option = null)
{
require_once __DIR__ . '/application.php';
Application::init($ini);
$worker = sprintf(__NAMESPACE__ . '\\worker\\%s', ucfirst(strtolower($class)));
$this->worker = new $worker((array) $option);
if (!$this->worker instanceof \Myfox\App\Worker) {
printf("Class \"%s\" is not a subclass extended from \"Worker\".\n", $worker);
exit;
}
$config = new \Myfox\Lib\Config($ini);
self::$runmode = strtolower(trim($config->get('run.mode', 'online')));
self::$identy = sprintf('%d@%s', getmypid(), strtolower(trim(php_uname('n'))));
$_clone =& $this;
$this->sigaction(SIGTERM, function ($signal) use($_clone) {
printf("[%s]\tGot signal (%d)", date('Y-m-d H:i:s'), $signal);
if (SIGTERM == $signal) {
echo ", about to terminal ...\n";
$_clone->freelock();
exit(0);
}
});
}
示例4: activate
static function activate(Application $application)
{
$application->init();
self::$runningApplication = $application;
}
示例5: array
define('APPLICATION_ENTRY_POINT', true);
// http://php.net/manual/en/security.magicquotes.disabling.php
if (get_magic_quotes_gpc()) {
$process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
while (list($key, $val) = each($process)) {
foreach ($val as $k => $v) {
unset($process[$key][$k]);
if (is_array($v)) {
$process[$key][stripslashes($k)] = $v;
$process[] =& $process[$key][stripslashes($k)];
} else {
$process[$key][stripslashes($k)] = stripslashes($v);
}
}
}
unset($process);
}
if (!isset($action)) {
if (!isset($_REQUEST['action'])) {
$action = 'index';
} else {
$action = $_REQUEST['action'];
}
}
require_once dirname(__FILE__) . '/config.php';
require_once dirname(__FILE__) . '/core/Application.php';
$application = new Application();
$application->init($applicationConfig, $action, $_REQUEST);
$application->run();
$application->send();
exit;
示例6: define
<?php
/**
* Spiral Framework, SpiralScout LLC.
*
* @package spiralFramework
* @author Anton Titov (Wolfy-J)
* @copyright ©2009-2011
*/
define('SPIRAL_INITIAL_TIME', microtime(true));
//No comments
mb_internal_encoding('UTF-8');
//Error reporting
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', false);
//Root directory
$root = dirname(__DIR__) . '/';
//Composer
require $root . 'vendor/autoload.php';
//Forcing work directory
chdir($root);
//Let's start!
Application::init(['root' => $root, 'libraries' => $root . '/vendor/', 'application' => $root . '/application/'], true)->start();
示例7:
<?php
require_once __DIR__ . '/../app/bootstrap.php';
Application::init();
示例8: array
<?php
class Application extends Gongo_App
{
public $uses = array('root' => 'Skelton_Controller_Root');
}
$app = new Application(dirname(__FILE__));
$app->init()->run();
示例9: __construct
/**
* 构造函数
*
* @access private
* @return void
*/
private function __construct($ini, $class, $option = null)
{
require_once __DIR__ . '/application.php';
Application::init($ini);
$worker = sprintf(__NAMESPACE__ . '\\worker\\%s', ucfirst(strtolower($class)));
$this->worker = new $worker((array) $option);
if (!$this->worker instanceof \Myfox\App\Worker) {
printf("Class \"%s\" is not a subclass extended from \"Worker\".\n", $worker);
exit;
}
}
示例10: init
</div>
</div>
<div class="row">
<div class="col-md-12">
<h3>Zadanie 2</h3>
<p>Mamy plik xml zawierający listę seansów filmowych (tutaj).
Napisz program, który cyklicznie będzie zaczytywał dane z
plików z podanego źródła i zapisywał do bazy danych
(zaproponuj odpowiednią strukturę bazy). Informacje na
temat seansów w plikach mogą z biegiem czasu ulegać zmianie
i odpowiadające im dane powinny być aktualizowane w bazie.
Program powinien być w pełni przetestowany.</p>
<?php
$app = new Application();
$app->init('http://nowetwarze.goingapp.pl/kina.xml');
$app->run();
class Application
{
var $xml_file;
public function init($xml_location)
{
$this->xml_file = file_get_contents(dirname(__FILE__) . '/kina.xml', FILE_USE_INCLUDE_PATH);
//$xml_file = file_get_contents('http://nowetwarze.goingapp.pl/kina.xml', FALSE, stream_context_create( array( 'http' => array( 'user_agent' => 'php' ))));
$db_connect = new Database();
$db_connect->connect();
}
public function run()
{
$movies = simplexml_load_string($this->xml_file);
if ($movies != '') {
示例11: define
<?php
define('__ROOT__', dirname(__DIR__));
require_once __ROOT__ . '/vendor/autoload.php';
require_once __ROOT__ . '/app/config/bootstrap.php';
Application::init()->run();
示例12: exists
public $reason;
public $contributions;
public $dateline;
public $avatar;
/**
* @param null $userid
* @return static
*/
public static function exists($userid = null)
{
if ($userid === null) {
if (!TwitterAuth::isLogged()) {
return null;
} else {
$userid = TwitterAuth::getUserId();
}
}
return Application::findOne('userid = ?', [$userid]);
}
public function getVotes()
{
return ApplicationVote::find('applicationid = ?', [$this->applicationid]);
}
public function getScore()
{
$votes = $this->getVotes();
return array_sum(Model::pluck($votes, 'vote'));
}
}
Application::init('applications', 'applicationid');
示例13: header
<?php
/**
* Index
* User: R2
* Date: 05.09.12
* Time: 23:49
* To change this template use File | Settings | File Templates.
*/
header("Content-Type: charset=utf-8");
require_once "ComponentManager.php";
require_once "Application.php";
require_once "db.php";
require_once "models/Fetcher.php";
require_once "models/VoteFetcher.php";
require_once "models/AnswerFetcher.php";
require_once "models/QuestionsFetcher.php";
require_once "models/PollFetcher.php";
require_once "controller/Controller.php";
require_once "controller/PollController.php";
require_once "controller/AnswerController.php";
require_once "controller/VoteController.php";
require_once "controller/ErrorController.php";
require_once "controller/AdminPollController.php";
require_once "controller/AdminAnswerController.php";
Application::init(array('components' => array('fetchers' => array('class' => 'ComponentManager', '__construct' => array(array('components' => array('answers' => array('class' => 'AnswerFetcher'), 'poll' => array('class' => 'PollFetcher'), 'questions' => array('class' => 'QuestionsFetcher'), 'vote' => array('class' => 'VoteFetcher'))))), 'db' => array('class' => 'db', '__construct' => array('localhost', 'root', '', 'poll')))));
Application::getInstance()->run();
示例14: Application
* and save a reference for it (for convenience)
* @var Config_Simple $appConfig
*/
$appConfig = Config::factory(Config::Simple, 'main');
$appConfig->setData($config);
Registry::set('main', $appConfig, 'config');
/**
* Convert the data of main_config file
* in to the general form of configuration
* and save a reference for it (for convenience)
* @var Config_Simple $appConfig
*/
/*
* Starting the application
*/
$app = new Application($appConfig);
$app->setAutoloader($autoloader);
$app->init();
// build objects
$objectFiles = File::scanFiles($config['object_configs'], array('.php'), false, File::Files_Only);
foreach ($objectFiles as $file) {
$object = substr(basename($file), 0, -4);
echo 'build ' . $object . ' : ';
$builder = new Db_Object_Builder($object);
if ($builder->build()) {
echo 'OK';
} else {
echo 'Error! ' . strip_tags(implode(', ', $builder->getErrors()));
}
echo "\n";
}
示例15: function
<?php
$app = Application::init();
$app->route()->get('/', function () {
$name = Request::get('name', 'jm-factorin');
$user = UserService::createUserByName($name);
return View::render('default.index', array('name' => $user->name));
});