本文整理汇总了PHP中S::hook方法的典型用法代码示例。如果您正苦于以下问题:PHP S::hook方法的具体用法?PHP S::hook怎么用?PHP S::hook使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类S
的用法示例。
在下文中一共展示了S::hook方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: S
<?php
require 'Slim/Slim.php';
require 'app/libs/S.php';
\Slim\Slim::registerAutoloader();
$app = new S();
$app->hook('slim.before', function () use($app) {
$app->response->header("Content-Type", "application/json; charset=utf-8");
});
$app->hook('slim.after', function () use($app) {
$app->output();
});
$app->get('/', function () use($app) {
$app->contents['messages'] = 'Welcome to S Web Services. Please provide application token to use the API.';
});
$app->run();
示例2: S
<?php
require 'Slim/Slim.php';
require 'vendor/php-activerecord/ActiveRecord.php';
require 'app/libs/S.php';
\Slim\Slim::registerAutoloader();
$app = new S();
$app->hook('slim.before', function () use($app) {
$app->conn = ActiveRecord\Config::instance();
$app->conn->set_model_directory('app/models');
$app->conn->set_connections(array('development' => 'mysql://training:admin1234@localhost/training_development', 'test' => 'mysql://training:admin1234@localhost/training_test', 'production' => 'mysql://training:admin1234@localhost/training_production'));
header("Access-Control-Allow-Origin: *");
$app->response->header("Content-Type", "application/json; charset=utf-8");
});
$app->hook('slim.after', function () use($app) {
$app->output();
});
$app->get('/', function () use($app) {
$app->contents['messages'] = 'Welcome to S Web Services. Please provide application token to use the API.';
});
require 'app/routes.php';
$app->run();