当前位置: 首页>>代码示例>>PHP>>正文


PHP Slim::put方法代码示例

本文整理汇总了PHP中Slim\Slim::put方法的典型用法代码示例。如果您正苦于以下问题:PHP Slim::put方法的具体用法?PHP Slim::put怎么用?PHP Slim::put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Slim\Slim的用法示例。


在下文中一共展示了Slim::put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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');
 }
开发者ID:nogo,项目名称:api,代码行数:15,代码来源:ResourceController.php

示例2: 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);
     });
 }
开发者ID:pdelbar,项目名称:onethree,代码行数:26,代码来源:restable.php

示例3: put

 function put($pattern, $controller, $method, $filter = null)
 {
     if (!is_callable($filter)) {
         $filter = function () {
         };
     }
     return parent::put($pattern, $filter, function () use($controller, $method) {
         $instance = new $controller();
         $args = func_get_args();
         call_user_func_array(array($instance, $method), $args);
     });
 }
开发者ID:fmunoz92,项目名称:mili,代码行数:12,代码来源:Router.php

示例4: 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;
 }
开发者ID:petitchevalroux,项目名称:newswatcher-api,代码行数:53,代码来源:RestDoctrineRouter.php

示例5: _initRoutes

 private function _initRoutes()
 {
     $this->_slim->contentType('application/json');
     $this->_slim->get('/basket/', array($this, 'getBaskets'));
     $this->_slim->get('/product/', array($this, 'getProducts'));
     $this->_slim->get('/basket/:id', array($this, 'getBasket'));
     $this->_slim->get('/basket/:id/item/', array($this, 'getBasketItems'));
     $this->_slim->get('/basket/:id/item/:prodId', array($this, 'getBasketItem'));
     $this->_slim->post('/basket/:id/item/', array($this, 'postBasketItem'));
     $this->_slim->put('/basket/:id/item/:prodId', array($this, 'putBasketItem'));
     $this->_slim->delete('/basket/:id/item/:prodId', array($this, 'deleteBasketItem'));
 }
开发者ID:skieff,项目名称:BSA2015-Basket-RestApi,代码行数:12,代码来源:RestApi.php

示例6: news

    $news = new news();
    $news->worker('new_post', $data);
});
$app->get('/news/:id', function ($id) {
    require '../news/news.worker.php';
    $news = new news();
    $news->worker('get_post', $id);
});
$app->get('/news/edit/:id', function ($id) {
    require '../news/news.worker.php';
    $news = new news();
    $news->worker('edit_post', $id);
});
$app->put('/news/edit/:id', function () {
    require '../news/news.worker.php';
    $data = json_decode(Slim::getInstance()->request()->getBody(), true);
    $news = new news();
    $news->worker('save_edit', $data);
});
$app->delete('/news/:id', function ($id) {
    require '../news/news.worker.php';
    $news = new news();
    $news->worker('delete_post', $id);
});
$app->get('/featured', function () {
    require '../news/news.worker.php';
    $news = new news();
    $news->worker('featured');
});
// //////////////////////////////
// Forum
// Get Categories
开发者ID:TheDoxMedia,项目名称:pgs,代码行数:32,代码来源:index.php

示例7: getSession

<?php

/*
	Author - Diego Alejandro Ramirez
	Contact - darasat@gmail.com
*/
require 'Slim/Slim.php';
use Slim\Slim;
Slim::registerAutoloader();
$app = new Slim();
$app->get('/session', 'getSession');
$app->get('/getPhotos', 'getPhotos');
$app->get('/getPhoto/:id', 'getPhoto');
$app->post('/addPhoto', 'addPhoto');
$app->put('/updatePhoto/:id', 'updatePhoto');
$app->delete('/deletePhoto/:id', 'deletePhoto');
$app->run();
// Get Database Connection
function getSession()
{
    $db = new DB_Connection();
}
function DB_Connection()
{
    $dbhost = "127.0.0.1";
    $dbuser = "root";
    $dbpass = "";
    $dbname = "ino";
    $dbh = new PDO("mysql:host={$dbhost};dbname={$dbname}", $dbuser, $dbpass);
    $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    return $dbh;
开发者ID:Tecnoparque,项目名称:AppFotoPerfil,代码行数:31,代码来源:index.php

示例8: function

*/
$app->get('/', function () use($emojiController) {
    //echo "Welcome to SweetEmoji";
    $emojiController->all();
});
/*
| "/emojis" get all emoji from the database
*/
$app->get('/emojis', function () use($emojiController) {
    $emojiController->all();
});
/*
| "/emojis" create new emoji
*/
$app->put('/emojis', $authenticated, function () use($emojiController) {
    $emojiController->addEmoji();
});
/*
| "/emojis" update emoji
*/
$app->patch('/emojis/:id', $authenticated, function ($id) use($emojiController) {
    $emojiController->updateEmoji($id);
});
/*
| "/emojis" find an emoji by id
| POST method
*/
$app->get('/emojis/:id', function ($id) use($emojiController) {
    $emojiController->findEmoji($id);
});
/*
开发者ID:emeka-osuagwu,项目名称:sweetemoji,代码行数:31,代码来源:index.php

示例9: index

  $.get('service.php/links', function (x) {
  alert('Antwort = \n' + x);
  })
  })();
*/
$app->get('/', 'index');
//Alle Links abfragen
$app->get('/links', 'getLinks');
//Ein Link abfragen mit Id
$app->get('/links/:id', 'getLinks');
//Links durchsuchen
$app->get('/links/search/:query', 'findByName');
//Link einfügen
$app->post('/links', 'addLink');
//Link ändern
$app->put('/links/:id', 'updateLink');
//Link löschen
$app->post('/linkss/:id', 'deleteLink');
//deklaration für Anfrage mit Methode OPTIONS
$app->run();
function index()
{
    echo 'auf der Index Seite';
}
function getLinks($id = null)
{
    if (!$id) {
        echo 'jjj';
    } else {
        echo $id;
    }
开发者ID:antic183,项目名称:angularjs-examples1,代码行数:31,代码来源:service.php

示例10: readEquipments

<?php

require 'Slim/Slim.php';
\Slim\Slim::registerAutoloader();
use Slim\Slim;
$app = new Slim(array('debug' => true));
$app->get('/equipments', 'readEquipments');
$app->get('/equipments/:id', 'readEquipment');
$app->post('/equipments', 'createEquipment');
$app->put('/equipments/:id', 'updateEquipment');
$app->delete('/equipments/:id', 'deleteEquipment');
$app->get('/peoples', 'readPeople');
$app->get('/peoples/:id', 'readPerson');
$app->post('/peoples', 'createPerson');
$app->put('/peoples/:id', 'updatePerson');
$app->delete('/peoples/:id', 'deletePerson');
$app->run();
$mongoHost = 'localhost';
function readEquipments()
{
    try {
        global $mongoHost;
        $connection = new MongoClient($mongoHost);
        $db = $connection->Equipments;
        $collection = $db->equipments;
        $cursor = $collection->find();
        $equipments = [];
        foreach ($cursor as $obj) {
            array_push($equipments, $obj);
        }
        echo json_encode($equipments);
开发者ID:kennybear,项目名称:A3,代码行数:31,代码来源:controller.php

示例11: Slim

<?php

namespace Oda;

require '../../../../../../header.php';
require '../../../../../../vendor/autoload.php';
require '../../../../../../config/config.php';
use cebe\markdown\GithubMarkdown;
use Slim\Slim;
use stdClass, Oda\SimpleObject\OdaPrepareInterface, Oda\SimpleObject\OdaPrepareReqSql, Oda\OdaLibBd, Oda\InterfaceRest\UserInterface;
$slim = new Slim();
//--------------------------------------------------------------------------
$slim->notFound(function () {
    $params = new OdaPrepareInterface();
    $INTERFACE = new OdaRestInterface($params);
    $INTERFACE->dieInError('not found');
});
$slim->get('/', function () {
    $markdown = file_get_contents('./doc.markdown', true);
    $parser = new GithubMarkdown();
    echo $parser->parse($markdown);
});
//----------- USER -------------------------------
$slim->put('/user/pwd/', function () use($slim) {
    $params = new OdaPrepareInterface();
    $params->slim = $slim;
    $params->arrayInput = array("userCode", "pwd", "email");
    $INTERFACE = new UserInterface($params);
    $INTERFACE->resetPwd();
});
$slim->run();
开发者ID:Happykiller,项目名称:ODA_FW_SERVER,代码行数:31,代码来源:index.php

示例12: getUsers

    ini_set('display_errors', 1);
    error_reporting(E_ALL);
}
date_default_timezone_set("UTC");
// registra
Slim::registerAutoloader();
// inicializa e configura as rotas
$app = new Slim(array('mode' => ENVIRONMENT == ENVIRONMENT_PROD ? 'production' : 'development'));
if (CROSS_ORIGIN_ENABLED) {
    $app->response()->header('Access-Control-Allow-Origin', ACCESS_CONTROL_ALLOW_ORIGIN);
}
$app->get('/users/:userId/devices', 'authorize', 'getUserDevices');
$app->get('/users', 'authorize', 'getUsers');
$app->get('/devices', 'authorize', 'getDevices');
$app->post('/devices', 'authorize', 'createDevice');
$app->put('/devices', 'authorize', 'updateDevice');
$app->delete('/devices', 'authorize', 'deleteDevice');
$app->post('/notifications', 'authorize', 'sendNotification');
$app->run();
/**
 * Busca usuários que possuem dispositivos cadastrados
 *
 * Permite paginação através do parâmetros:
 * 	- page: página a ser retornada
 * 	- limit: quantidade de resultados a serem retornados
 */
function getUsers()
{
    global $log;
    $app = Slim::getInstance();
    try {
开发者ID:selombanybah,项目名称:push-notification,代码行数:31,代码来源:api.php

示例13: function

});
$app->get('/contacts/:id', $contentNegotiation, function ($id) use($app) {
    //This value should be specific to the current resource
    $lastModifiedTime = gmdate('D, d M Y H:i:s ') . ' GMT';
    $app->response()->header('Last-Modified', $lastModifiedTime);
    $app->status(200);
    echo $app->render($app->template, ['contact' => ['contact_id' => $id, 'name' => $app->faker->firstName, 'last_name' => $app->faker->lastName]]);
});
$app->put('/contacts/:id', $contentNegotiation, function ($id) use($app) {
    $contactInformation = $app->request()->getBody();
    parse_str($contactInformation, $contact);
    $contact['contact_id'] = $id;
    if (empty($contact['name'])) {
        $contact['name'] = $app->faker->firstName;
    }
    if (empty($contact['last_name'])) {
        $contact['last_name'] = $app->faker->lastName;
    }
    $lastModifiedTime = time();
    $app->lastModified($lastModifiedTime);
    $app->status(200);
    echo $app->render($app->template, ['contact' => $contact]);
});
$app->delete('/contacts/:id', function ($id) use($app) {
    //Delete contact here
    $app->status(204);
});
$app->options('/contacts/:id', function ($id) use($app) {
    $validOptions = ['GET', 'HEAD', 'PUT', 'DELETE', 'OPTIONS'];
    $app->response()->header('Allow', implode(',', $validOptions));
});
开发者ID:comphppuebla,项目名称:guzzlesfd,代码行数:31,代码来源:index.php

示例14:

// Route to accept the signup form
$app->get('/login', 'getlogin');
$app->post('/login', 'validateLogin');
// Route to accept the login form
$app->get('/error', 'error');
// Show Errors
$app->get('/logout', 'logout');
// Logout
// Backend
// User section routes
// user Dashboard
$app->get('/dashboard/user/:id', 'showAccount');
// Show the account information
$app->get('/dashboard/user_details/:id', 'showDetails');
// Show user Details
$app->put('/dashboard/update/:id', 'updateDetails');
// Update user Details
$app->put('/dashboard/account_type/:id', 'updateAccountType');
// Update user Details
$app->put('/dashboard/account_pass/:id', 'updateAccountPass');
// Update user Details
$app->delete('/dashboard/update/:id', 'deleteDetails');
// Delete user Details
$app->get('/dashboard/user_deposit/:id', 'deposit');
// Show the Deposit Page
$app->put('/dashboard/deposit/:id', 'updateDeposit');
// Route to accept the Deposit form
$app->get('/dashboard/user_withdrawal/:id', 'withdrawal');
// Show the Withdrawal Page
$app->put('/dashboard/withdrawal/:id', 'updateWithdrawal');
// Route to accept the Withdrawal form
开发者ID:rorynee,项目名称:bankOfRoryDatabaseAssignment,代码行数:31,代码来源:index.php

示例15: function

    }
});
// Post
$app->post('/:resource(/(:action)(/))', function ($resource, $subResource = null) use($app) {
    $resource = Resource::load($app->version, $resource, $subResource);
    if ($resource === null) {
        Resource::error(Resource::STATUS_NOT_FOUND, 'Cannot find requested resource.');
    } else {
        $resource->post();
    }
});
// Put
$app->put('/:resource(/(:action)(/))', function ($resource, $subResource = null) use($app) {
    $resource = Resource::load($app->version, $resource, $subResource);
    if ($resource === null) {
        Resource::error(Resource::STATUS_NOT_FOUND, 'Cannot find requested resource.');
    } else {
        $resource->put();
    }
});
// Delete
$app->delete('/:resource(/(:action)(/))', function ($resource, $subResource = null) use($app) {
    $resource = Resource::load($app->version, $resource, $subResource);
    if ($resource === null) {
        Resource::error(Resource::STATUS_NOT_FOUND, 'Cannot find requested resource.');
    } else {
        $resource->delete();
    }
});
// Options
$app->options('/:resource(/(:action)(/))', function ($resource, $subResource = null) use($app) {
    $resource = Resource::load($app->version, $resource, $subResource);
开发者ID:rohanabraham,项目名称:lxHive,代码行数:32,代码来源:index.php


注:本文中的Slim\Slim::put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。