當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。