本文整理汇总了PHP中Slim\Slim::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Slim::get方法的具体用法?PHP Slim::get怎么用?PHP Slim::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Slim\Slim
的用法示例。
在下文中一共展示了Slim::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: slimSetup
public static function slimSetup(\Slim\Slim &$slim, One_Scheme $scheme)
{
//TODO: read specs from behaviour options or from a file
$opt = $scheme->get('behaviorOptions.restable');
$route = $opt['route'];
// retrieve
$slim->get("/{$route}", function () use($scheme) {
One_Controller_Rest::restGetAll($scheme);
});
// retrieve one
$slim->get("/{$route}/:idOrAlias", function ($idOrAlias) use($scheme) {
One_Controller_Rest::restGet($scheme, $idOrAlias);
});
// create new
$slim->post("/{$route}", function () use($scheme) {
One_Controller_Rest::restPost($scheme);
});
// update existing
$slim->put("/{$route}/:idOrAlias", function ($idOrAlias) use($scheme) {
One_Controller_Rest::restPut($scheme, $idOrAlias);
});
// delete existing
$slim->delete("/{$route}/:idOrAlias", function ($idOrAlias) use($scheme) {
One_Controller_Rest::restDelete($scheme, $idOrAlias);
});
}
示例2: defineRoutes
protected function defineRoutes(\Slim\Slim $app)
{
$app->get('/event/:eventSlug/:talkSlug', array($this, 'index'))->name('talk');
$app->post('/event/:eventSlug/:talkSlug/star', array($this, 'star'))->name('talk-star');
$app->get('/talk/:talkStub', array($this, 'quick'))->name('talk-quicklink');
$app->post('/event/:eventSlug/:talkSlug/add-comment', array($this, 'addComment'))->name('talk-add-comment');
}
示例3: defineRoutes
protected function defineRoutes(\Slim\Slim $app)
{
$app->get('/', array($this, 'index'));
$app->get('/apps', array($this, 'apps'))->name('apps');
$app->get('/about', array($this, 'about'))->name('about');
$app->map('/contact', array($this, 'contact'))->via('GET', 'POST')->name('contact');
$app->get('/not-allowed', array($this, 'notAllowed'))->name('not-allowed');
}
示例4: generateRoutes
public function generateRoutes()
{
foreach ($this->schema->table as $table) {
$tableName = $this->_urlFriendly($table['name']);
$this->slimApp->post($this->apiBasePath . "add-" . $tableName, $this->_addRecord($table));
$this->slimApp->get($this->apiBasePath . "fetch-" . $tableName . "s", $this->_fetchRecords($table));
$this->slimApp->get($this->apiBasePath . "get-" . $tableName . "/:id", $this->_getRecord($table));
$this->slimApp->get($this->apiBasePath . "get-" . $tableName . "-by/:key/:value", $this->_getRecordBy($table));
}
}
示例5: defineRoutes
protected function defineRoutes(\Slim\Slim $app)
{
$app->get('/event/:eventSlug/:talkSlug', array($this, 'index'))->name('talk');
$app->post('/event/:eventSlug/:talkSlug/star', array($this, 'star'))->name('talk-star');
$app->get('/talk/:talkStub', array($this, 'quick'))->name('talk-quicklink');
$app->get('/event/:eventSlug/:talkSlug/comments/:commentHash/report', array($this, 'reportComment'))->name('talk-report-comment');
$app->post('/event/:eventSlug/:talkSlug/add-comment', array($this, 'addComment'))->name('talk-add-comment');
$app->get('/:talkId', array($this, 'quickById'))->name('talk-quick-by-id')->conditions(array('talkId' => '\\d+'));
$app->get('/talk/view/:talkId', array($this, 'quickById'))->name('talk-by-id-web1')->conditions(array('talkId' => '\\d+'));
}
示例6: registration
/**
* 渡されたslimインスタンスにルートを登録
* @param \Slim\Slim $app
*/
public static function registration(\Slim\Slim $app)
{
// SlimのCSRF対策プラグインを有効化
$app->add(new \Slim\Extras\Middleware\CsrfGuard());
// トップページ
$app->get('/', '\\Tinitter\\Controller\\TimeLine:show');
// 投稿一覧
$app->get('/page/:page_num', '\\Tinitter\\Controller\\TimeLine:show');
// 新規投稿系、保存
$app->post('/post/commit', '\\Tinitter\\Controller\\Post:commit');
}
示例7: registration
public static function registration(\Slim\Slim $app)
{
// Slim縺ョCSRF蟇セ遲悶��繝ゥ繧ー繧、繝ウ繧呈怏蜉ケ蛹�
$app->add(new \Slim\Extras\Middleware\CsrfGuard());
// 繝医ャ繝励��繝シ繧ク
$app->get('/', '\\Tinitter\\Controller\\TimeLine:show');
// 謚慕ィソ荳�隕ァ
$app->get('/page/:page_num', '\\Tinitter\\Controller\\TimeLine:show');
// 譁ー隕乗兜遞ソ邉サ縲∽ソ晏ュ�
$app->post('/post/commit', '\\Tinitter\\Controller\\Post:commit');
}
示例8: addRoutesFromMeta
private function addRoutesFromMeta(Slim $application, ClassMetadata $meta, Controller $controller)
{
$entitiesRoute = $this->getEntitiesRoute($meta);
// Fetch entities route
$application->get($entitiesRoute, function () use($meta, $controller) {
$controller->getEntities($meta);
});
// Create entity
$application->post($entitiesRoute, function () use($meta, $controller) {
$controller->createEntity($meta);
});
$entityRoute = $this->getEntityRoute($meta, $entitiesRoute);
// Get entity
$application->get($entityRoute, function () use($meta, $controller) {
$controller->getEntity($meta, func_get_args());
});
// Update entity
$application->put($entityRoute, function () use($meta, $controller) {
$controller->updateEntity($meta, func_get_args());
});
// Patch entity
$application->patch($entityRoute, function () use($meta, $controller) {
$controller->patchEntity($meta, func_get_args());
});
// Delete entity
$application->delete($entityRoute, function () use($meta, $controller) {
$controller->deleteEntity($meta, func_get_args());
});
// Handling associated entities
foreach ($meta->getAssociationMappings() as $aName => $aData) {
$aTargetClass = $meta->getAssociationTargetClass($aName);
$aMeta = $this->getEntityMeta($aTargetClass);
$aEntitiesRoute = $entityRoute . '/' . $aName;
// Create associated entity
// allow to create entity and link source together
// POST /articles/1/tags will fetch article 1, create tag entity and
// associate it to article 1
$application->post($aEntitiesRoute, function () use($meta, $aMeta, $controller, $aData) {
$controller->createEntity($aMeta, $aData['fieldName'], $meta, func_get_args());
});
// List associated entities
$application->get($aEntitiesRoute, function () use($meta, $controller, $aData) {
$controller->getAssociatedEntities($aData['fieldName'], $meta, func_get_args());
});
// Associate two entities
// POST /articles/1/tags/2 will associate article 1 to tag 2
$aEntityRoute = $this->getEntityRoute($aMeta, $aEntitiesRoute);
$application->post($aEntityRoute, function () use($meta, $aMeta, $controller, $aData) {
$controller->associateEntities($aMeta, $aData['fieldName'], $meta, func_get_args());
});
}
return $application;
}
示例9: __construct
public function __construct(Neo4j\Client $client, Slim\Slim $app, Theme $theme = null, array $options = null)
{
$this->setOptions($options);
$this->app = $app;
$this->client = $client;
$this->schema = new Schema($client);
if ($theme) {
$this->setTheme($theme);
}
if ($this->hasOption('upload.directory')) {
$this->setUploadDirectory($this->getOption('upload.directory'));
}
// Set up the home route.
$app->get('/', Closure::bind(function () {
$controller = new Controllers\HomeController($this->app, $this->schema, $this->client);
$controller->read();
}, $this));
// Set up the uploads route.
$app->get($this->getOption('path.format.uploads'), Closure::bind(function ($file_name) {
$controller = new Controllers\UploadController($this->app);
$controller->read($file_name);
}, $this));
// Set up the search controller.
$app->get($this->getOption('path.format.search'), Closure::bind(function () {
$controller = new Controllers\SearchController($this->app, $this->schema, $this->client);
$controller->run();
}, $this))->name('search');
// Set up the resources controller.
$this->app->get($this->getOption('path.format.resources'), Closure::bind(function (array $resource_path) {
$theme = $this->getTheme();
// Pass if not an instance or child of the default theme, as Theme#renderResource won't be present.
// In non-standard use cases, this allows the user to use a regular Slim\View as the view.
if (!$theme) {
$this->getApp()->pass();
}
$controller = new Controllers\FileController($this->app);
if ($theme->hasResource($resource_path)) {
$controller->read($theme->getResourcePath($resource_path));
} else {
$this->getApp()->notFound(new Exceptions\Exception('Unknown resource "' . implode('/', $resource_path) . '".'));
}
}, $this))->name('resources');
// Set up a default handler for 404 errors.
// Only Penelope application-generated exceptions are permitted.
$app->notFound(function (Exceptions\Exception $e = null) {
if (!$e) {
$e = new Exceptions\NotFoundException('The requested page cannot be found.');
}
$controller = new Controllers\Controller($this->app);
$this->app->render('error', array('title' => $controller->_m('error_404_title'), 'error' => $e), 404);
});
}
示例10: enable
public function enable(Slim $app)
{
$this->app = $app;
$this->config = $this->app->config('api');
$this->factory = new Factory($this->config['resources']);
// Middleware
$this->app->add(new Database());
$this->app->add(new ApiMiddleware($this->config));
// Routes
$this->app->get($this->config['prefix'] . '/:resource/:id', [$this, 'getAction'])->conditions(['id' => '\\d+'])->name('resource_get');
$this->app->get($this->config['prefix'] . '/:resource', [$this, 'listAction'])->name('resource_get_list');
$this->app->put($this->config['prefix'] . '/:resource/:id', [$this, 'putAction'])->conditions(['id' => '\\d+'])->name('resource_put');
$this->app->post($this->config['prefix'] . '/:resource', [$this, 'postAction'])->name('resource_post');
$this->app->delete($this->config['prefix'] . '/:resource/:id', [$this, 'deleteAction'])->conditions(['id' => '\\d+'])->name('resource_delete');
}
示例11: register
/**
* @param Slim $app
* @param Resolver $resolver
*/
public function register(Slim $app, Resolver $resolver)
{
$app->get('/', function () use($app) {
$app->redirectTo('transfer_form');
});
$app->get('/transfer-form', $resolver->resolve($app, 'ewallet.transfer_form_controller:showForm', function () {
return [Identifier::fromString('ABC')];
}))->name('transfer_form');
$app->post('/transfer-funds', $resolver->resolve($app, 'ewallet.transfer_funds_controller:transfer', function () use($app) {
/** @var \EwalletModule\Bridges\Zf2\InputFilter\TransferFundsInputFilterRequest $request */
$request = $app->container->get('ewallet.transfer_filter_request');
$request->populate($app->request->post());
return [$request];
}))->name('transfer_funds');
}
示例12: setAssetsRoute
protected function setAssetsRoute()
{
$renderer = $this->debugbar->getJavascriptRenderer();
$this->app->get('/_debugbar/fonts/:file', function ($file) use($renderer) {
// e.g. $file = fontawesome-webfont.woff?v=4.0.3
$files = explode('?', $file);
$file = reset($files);
$path = $renderer->getBasePath() . '/vendor/font-awesome/fonts/' . $file;
if (file_exists($path)) {
$this->app->response->header('Content-Type', (new \finfo(FILEINFO_MIME))->file($path));
echo file_get_contents($path);
} else {
// font-awesome.css referencing fontawesome-webfont.woff2 but not include in the php-debugbar.
// It is not slim-debugbar bug.
$this->app->notFound();
}
})->name('debugbar.fonts');
$this->app->get('/_debugbar/resources/:file', function ($file) use($renderer) {
$files = explode('.', $file);
$ext = end($files);
if ($ext === 'css') {
$this->app->response->header('Content-Type', 'text/css');
$renderer->dumpCssAssets();
} elseif ($ext === 'js') {
$this->app->response->header('Content-Type', 'text/javascript');
$renderer->dumpJsAssets();
}
})->name('debugbar.resources');
$this->app->get('/_debugbar/openhandler', function () {
$openHandler = new OpenHandler($this->debugbar);
$data = $openHandler->handle($request = null, $echo = false, $sendHeader = false);
$this->app->response->header('Content-Type', 'application/json');
$this->app->response->setBody($data);
})->name('debugbar.openhandler');
}
示例13: routes
function routes(\Slim\Slim $app)
{
$base = $this->getBasePath();
$app->get($base . '/', function () use($app) {
$app->redirect($app->Doc->getBasePath() . '/api-doc/');
});
$app->get($base . '/api-doc/json', function () use($app) {
$app->Doc->json();
});
$app->get($base . '/api-doc/', function () use($app) {
$app->Doc->ui();
});
$app->get($base . '/api-doc/json/:name', function ($name) use($app) {
$app->Doc->api($name);
});
}
示例14: setUp
public function setUp()
{
parent::setUp();
$app = new Slim();
$app->get('/test', function () {
})->name('test');
$this->ext = new Xhgui_Twig_Extension($app);
}
示例15: registrationRoute
public static function registrationRoute(\Slim\Slim $app)
{
$app->get('/', function () use($app) {
$app->render('index.php');
});
$app->post('/form/', function () use($app) {
$app->render('index.php', ['nickname' => $_POST['nickname']]);
});
}