本文整理汇总了PHP中Slim::put方法的典型用法代码示例。如果您正苦于以下问题:PHP Slim::put方法的具体用法?PHP Slim::put怎么用?PHP Slim::put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Slim
的用法示例。
在下文中一共展示了Slim::put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* REST actions
*
* This function contains the REST actions with the assignments to
* the functions.
*/
public function __construct()
{
// runs the CConfig
$com = new CConfig(DBSetting::getPrefix() . ',course,link', dirname(__FILE__));
// runs the DBSetting
if ($com->used()) {
return;
}
$this->_conf = $com;
// initialize slim
$this->_app = new \Slim\Slim(array('debug' => true));
$this->_app->response->headers->set('Content-Type', 'application/json');
// POST AddCourse
$this->_app->post('(/:pre)/course', array($this, 'addCourse'));
// POST DeleteCourse
$this->_app->delete('(/:pre)/course/:courseid', array($this, 'deleteCourse'));
// PUT EditSetting
$this->_app->put('(/:pre)/' . $this->getPrefix() . '/setting/:setid', array($this, 'editSetting'));
// DELETE DeleteSetting
$this->_app->delete('(/:pre)/' . $this->getPrefix() . '/setting/:setid', array($this, 'deleteSetting'));
// POST AddSetting
$this->_app->post('(/:pre)/' . $this->getPrefix() . '/course/:courseid', array($this, 'addSetting'));
// GET GetExistsCourseSettings
$this->_app->get('(/:pre)/link/exists/course/:courseid', array($this, 'getExistsCourseSettings'));
// GET GetCourseSettings
$this->_app->get('(/:pre)/' . $this->getPrefix() . '/course/:courseid', array($this, 'getCourseSettings'));
// GET GetSetting
$this->_app->get('(/:pre)/' . $this->getPrefix() . '/setting/:setid', array($this, 'getSetting'));
// GET GetSettingByName
$this->_app->get('(/:pre)/' . $this->getPrefix() . '/course/:courseid/name/:setname', array($this, 'getSettingByName'));
// run Slim
$this->_app->run();
}
示例2: __construct
/**
* REST actions
*
* This function contains the REST actions with the assignments to
* the functions.
*/
public function __construct()
{
// runs the CConfig
$com = new CConfig(DBAttachment2::getPrefix() . ',course,link', dirname(__FILE__));
// runs the DBAttachment2
if ($com->used()) {
return;
}
$this->_conf = $com;
// initialize slim
$this->_app = new \Slim\Slim(array('debug' => true));
$this->_app->response->headers->set('Content-Type', 'application/json');
// POST AddCourse
$this->_app->post('(/:pre)/course(/)', array($this, 'addCourse'));
// POST DeleteCourse
$this->_app->delete('(/:pre)/course/:courseid(/)', array($this, 'deleteCourse'));
// PUT EditAttachment
$this->_app->put('(/:pre)/' . $this->getPrefix() . '(/attachment)/:aid(/)', array($this, 'editAttachment'));
// DELETE DeleteAttachment
$this->_app->delete('(/:pre)/' . $this->getPrefix() . '(/attachment)/:aid(/)', array($this, 'deleteAttachment'));
// POST AddAttachment
$this->_app->post('(/:pre)/' . $this->getPrefix(), array($this, 'addAttachment'));
// GET GetExistsCourseAttachments
$this->_app->get('(/:pre)/link/exists/course/:courseid(/)', array($this, 'getExistsCourseAttachments'));
// GET GetAttachment
$this->_app->get('(/:pre)/' . $this->getPrefix() . '(/attachment)/:aid(/)', array($this, 'getAttachment'));
// GET GetExerciseAttachments
$this->_app->get('(/:pre)/' . $this->getPrefix() . '/exercise/:eid(/)', array($this, 'getExerciseAttachments'));
// GET GetSheetAttachments
$this->_app->get('(/:pre)/' . $this->getPrefix() . '/exercisesheet/:esid(/)', array($this, 'getSheetAttachments'));
// GET GetCourseAttachments
$this->_app->get('(/:pre)/' . $this->getPrefix() . '/course/:courseid(/)', array($this, 'getCourseAttachments'));
// run Slim
$this->_app->run();
}
示例3: __construct
/**
* REST actions
*
* This function contains the REST actions with the assignments to
* the functions.
*
* @param Component $conf component data
*/
public function __construct()
{
// runs the CConfig
$com = new CConfig(LCourse::getPrefix(), dirname(__FILE__));
// runs the LCourse
if ($com->used()) {
return;
}
$conf = $com->loadConfig();
// initialize slim
$this->app = new \Slim\Slim(array('debug' => true));
$this->app->response->headers->set('Content-Type', 'application/json');
// initialize component
$this->_conf = $conf;
$this->query = CConfig::getLink($conf->getLinks(), "controller");
$this->_deleteCourse = CConfig::getLinks($conf->getLinks(), "deleteCourse");
$this->_postCourse = CConfig::getLinks($conf->getLinks(), "postCourse");
// initialize lURL
$this->lURL = $this->query->getAddress();
//POST AddCourse
$this->app->post('/' . $this->getPrefix() . '(/)', array($this, 'AddCourse'));
//PUT EditCourse
$this->app->put('/' . $this->getPrefix() . '/course/:courseid(/)', array($this, 'editCourse'));
//DELETE DeleteCourse
$this->app->delete('/' . $this->getPrefix() . '/course/:courseid(/)', array($this, 'deleteCourse'));
//POST AddCourseMember
$this->app->post('/' . $this->getPrefix() . '/course/:courseid/user/:userid/status/:status(/)', array($this, 'addCourseMember'));
//GET GetCourseMember
$this->app->get('/' . $this->getPrefix() . '/course/:courseid/user(/)', array($this, 'getCourseMember'));
//GET GetCourses
$this->app->get('/' . $this->getPrefix() . '/user/:userid(/)', array($this, 'getCourses'));
//run Slim
$this->app->run();
}
示例4: __construct
/**
* the component constructor
*/
public function __construct()
{
// runs the CConfig
$com = new CConfig(CControl::getPrefix() . ',link,definition', dirname(__FILE__));
// runs the DBSubmission
if ($com->used()) {
return;
}
// initialize slim
$this->_app = new \Slim\Slim();
$this->_app->response->headers->set('Content-Type', 'application/json');
// POST AddPlatform
$this->_app->post('/platform', array($this, 'addPlatform'));
// DELETE DeletePlatform
$this->_app->delete('/platform', array($this, 'deletePlatform'));
// GET GetExistsPlatform
$this->_app->get('/link/exists/platform', array($this, 'getExistsPlatform'));
// GET GetTableReferences
$this->_app->get('/tableReferences', array($this, 'getTableReferences'));
// PUT EditLink
$this->_app->put('/link/:linkid(/)', array($this, 'editLink'));
// DELETE DeleteLink
$this->_app->delete('/link/:linkid(/)', array($this, 'deleteLink'));
// POST SetLink
$this->_app->post('/link(/)', array($this, 'setLink'));
// GET GetLink
$this->_app->get('/link/:linkid(/)', array($this, 'getLink'));
// PUT EditComponent
$this->_app->put('/component/:componentid(/)', array($this, 'editComponent'));
// DELETE DeleteComponent
$this->_app->delete('/component/:componentid(/)', array($this, 'deleteComponent'));
// POST SetComponent
$this->_app->post('/component(/)', array($this, 'setComponent'));
// GET GetComponent
$this->_app->get('/component/:componentid(/)', array($this, 'getComponent'));
// GET GetComponentDefinitions
$this->_app->get('/definition(/)', array($this, 'getComponentDefinitions'));
// GET SendComponentDefinitions
$this->_app->get('(/definition)/send(/)', array($this, 'sendComponentDefinitions'));
// GET GetComponentDefinition
$this->_app->get('/definition/:componentid(/)', array($this, 'getComponentDefinition'));
// run Slim
$this->_app->run();
}
示例5: __construct
/**
* REST actions
*
* This function contains the REST actions with the assignments to
* the functions.
*/
public function __construct()
{
// runs the CConfig
$com = new CConfig(DBForm::getPrefix() . ',course,link', dirname(__FILE__));
// runs the DBForm
if ($com->used()) {
return;
}
$conf = $com->loadConfig();
// initialize component
$this->_conf = $conf;
$this->query = array(CConfig::getLink($conf->getLinks(), 'out'));
// initialize slim
$this->_app = new \Slim\Slim();
$this->_app->response->headers->set('Content-Type', 'application/json');
// POST AddCourse
$this->_app->post('/course(/)', array($this, 'addCourse'));
// POST DeleteCourse
$this->_app->delete('/course/:courseid(/)', array($this, 'deleteCourse'));
// PUT EditForm
$this->_app->put('/' . $this->getPrefix() . '(/form)/:formid(/)', array($this, 'editForm'));
// DELETE DeleteForm
$this->_app->delete('/' . $this->getPrefix() . '(/form)/:formid(/)', array($this, 'deleteForm'));
// POST AddForm
$this->_app->post('/' . $this->getPrefix() . '(/)', array($this, 'addForm'));
// GET GetForm
$this->_app->get('/' . $this->getPrefix() . '(/form)/:formid(/)', array($this, 'getForm'));
// GET GetCourseForms
$this->_app->get('/' . $this->getPrefix() . '/course/:courseid(/)', array($this, 'getCourseForms'));
// GET GetExistsCourseForms
$this->_app->get('/link/exists/course/:courseid(/)', array($this, 'getExistsCourseForms'));
// GET GetSheetForms
$this->_app->get('/' . $this->getPrefix() . '/exercisesheet/:esid(/)', array($this, 'getSheetForms'));
// GET GetExerciseForms
$this->_app->get('/' . $this->getPrefix() . '/exercise/:eid(/)', array($this, 'getExerciseForms'));
// run Slim
$this->_app->run();
}
示例6: __construct
/**
* REST actions
*
* This function contains the REST actions with the assignments to
* the functions.
*/
public function __construct()
{
// runs the CConfig
$com = new CConfig(DBChoice::getPrefix() . ',course,link', dirname(__FILE__));
// runs the DBChoice
if ($com->used()) {
return;
}
// initialize component
$this->_conf = $com;
// initialize slim
$this->_app = new \Slim\Slim(array('debug' => true));
$this->_app->response->headers->set('Content-Type', 'application/json');
// POST AddCourse
$this->_app->post('(/:preChoice(/:preForm(/:preExercise)))/course', array($this, 'addCourse'));
// DELETE DeleteCourse
$this->_app->delete('(/:preChoice(/:preForm(/:preExercise)))/course(/course)/:courseid', array($this, 'deleteCourse'));
// PUT EditChoice
$this->_app->put('(/:preChoice(/:preForm(/:preExercise)))/' . $this->getPrefix() . '(/choice)/:choiceid(/)', array($this, 'editChoice'));
// DELETE DeleteChoice
$this->_app->delete('(/:preChoice(/:preForm(/:preExercise)))/' . $this->getPrefix() . '(/choice)/:choiceid(/)', array($this, 'deleteChoice'));
// POST AddChoice
$this->_app->post('(/:preChoice(/:preForm(/:preExercise)))/' . $this->getPrefix() . '(/)', array($this, 'addChoice'));
// GET GetChoice
$this->_app->get('(/:preChoice(/:preForm(/:preExercise)))/' . $this->getPrefix() . '(/choice)/:choiceid(/)', array($this, 'getChoice'));
// GET GetCourseChoices
$this->_app->get('(/:preChoice(/:preForm(/:preExercise)))/' . $this->getPrefix() . '/course/:courseid(/)', array($this, 'getCourseChoices'));
// GET GetExistsCourseChoices
$this->_app->get('(/:preChoice(/:preForm(/:preExercise)))/link/exists/course/:courseid(/)', array($this, 'getExistsCourseChoices'));
// GET GetSheetChoices
$this->_app->get('(/:preChoice(/:preForm(/:preExercise)))/' . $this->getPrefix() . '/exercisesheet/:esid(/)', array($this, 'getSheetChoices'));
// GET GetExerciseChoices
$this->_app->get('(/:preChoice(/:preForm(/:preExercise)))/' . $this->getPrefix() . '/exercise/:eid(/)', array($this, 'getExerciseChoices'));
// GET GetFormChoices
$this->_app->get('(/:preChoice(/:preForm(/:preExercise)))/' . $this->getPrefix() . '/form/:formid(/)', array($this, 'getFormChoices'));
// run Slim
$this->_app->run();
}
示例7: __construct
/**
* REST actions
*
* This function contains the REST actions with the assignments to
* the functions.
*
* @param Component $conf component data
*/
public function __construct()
{
// runs the CConfig
$com = new CConfig(DBAttachment::getPrefix(), dirname(__FILE__));
// runs the DBAttachment
if ($com->used()) {
return;
}
$conf = $com->loadConfig();
// initialize component
$this->_conf = $conf;
$this->query = array(CConfig::getLink($conf->getLinks(), 'out'));
$this->query2 = array(CConfig::getLink($conf->getLinks(), 'out2'));
// initialize slim
$this->_app = new \Slim\Slim();
$this->_app->response->setStatus(409);
$this->_app->response->headers->set('Content-Type', 'application/json');
// POST AddPlatform
$this->_app->post('/platform', array($this, 'addPlatform'));
// DELETE DeletePlatform
$this->_app->delete('/platform', array($this, 'deletePlatform'));
// GET GetExistsPlatform
$this->_app->get('/link/exists/platform', array($this, 'getExistsPlatform'));
// PUT EditAttachment
$this->_app->put('/' . $this->getPrefix() . '(/attachment)/:aid(/)', array($this, 'editAttachment'));
// DELETE DeleteAttachment
$this->_app->delete('/' . $this->getPrefix() . '(/attachment)/:aid(/)', array($this, 'deleteAttachment'));
// DELETE DeleteExerciseAttachments
$this->_app->delete('/' . $this->getPrefix() . '/exercise/:eid(/)', array($this, 'deleteExerciseAttachment'));
// DELETE DeleteExerciseFileAttachment
$this->_app->delete('/' . $this->getPrefix() . '/exercise/:eid/file/:fileid(/)', array($this, 'deleteExerciseFileAttachment'));
// POST AddAttachment
$this->_app->post('/' . $this->getPrefix() . '(/)', array($this, 'addAttachment'));
// GET GetAttachment
$this->_app->get('/' . $this->getPrefix() . '(/attachment)/:aid(/)', array($this, 'getAttachment'));
// GET GetAllAttachments
$this->_app->get('/' . $this->getPrefix() . '(/attachment)(/)', array($this, 'getAllAttachments'));
// GET GetExerciseAttachments
$this->_app->get('/' . $this->getPrefix() . '/exercise/:eid(/)', array($this, 'getExerciseAttachments'));
// GET GetSheetAttachments
$this->_app->get('/' . $this->getPrefix() . '/exercisesheet/:esid(/)', array($this, 'getSheetAttachments'));
// run Slim
$this->_app->run();
}
示例8: function
//Sample POST route for PHP >=5.3
Slim::post('/post', function () {
echo '<p>Here are the details about your POST request:</p>';
print_r(Slim::request());
});
//Sample POST route for PHP <5.3
/*
Slim::post('/post', 'post_example');
function post_example() {
echo '<br/><br/>Here are the details about your POST request:<br/><br/>';
print_r(Slim::request());
}
*/
//Sample PUT route for PHP >=5.3
Slim::put('/put', function () {
echo '<p>Here are the details about your PUT request:</p>';
print_r(Slim::request());
});
//Sample PUT route for PHP <5.3
/*
Slim::put('/put', 'put_example');
function put_example() {
echo '<br/><br/>Here are the details about your PUT request:<br/><br/>';
print_r(Slim::request());
}
*/
//Sample DELETE route for PHP >=5.3
Slim::delete('/delete', function () {
echo '<p>Here are the details about your DELETE request:</p>';
print_r(Slim::request());
});
//Sample DELETE route for PHP <5.3
示例9: function
} else {
echo json_encode(array("status" => false, "message" => "Book ID {$id} does not exist"));
}
});
$app->post("/book", function () use($app, $db) {
$app->response()->header("Content-Type", "application/json");
$book = $app->request()->post();
$result = $db->books->insert($book);
echo json_encode(array("id" => $result["id"]));
});
$app->put("/book/:id", function ($id) use($app, $db) {
$app->response()->header("Content-Type", "application/json");
$book = $db->books()->where("id", $id);
if ($book->fetch()) {
$post = $app->request()->put();
$result = $book->update($post);
echo json_encode(array("status" => (bool) $result, "message" => "Book updated successfully"));
} else {
echo json_encode(array("status" => false, "message" => "Book id {$id} does not exist"));
}
});
$app->delete("/book/:id", function ($id) use($app, $db) {
$app->response()->header("Content-Type", "application/json");
$book = $db->books()->where("id", $id);
if ($book->fetch()) {
$result = $book->delete();
echo json_encode(array("status" => true, "message" => "Book deleted successfully"));
} else {
echo json_encode(array("status" => false, "message" => "Book id {$id} does not exist"));
}
});
示例10: getItems
<?php
require 'Slim/Slim.php';
$app = new Slim();
$app->get('/items', 'getItems');
$app->get('/items/:id', 'getItem');
$app->get('/items/search/:query', 'findByName');
$app->post('/items', 'addItem');
$app->put('/items/:id', 'updateItem');
$app->delete('/items/:id', 'deleteItem');
$app->run();
function getItems()
{
$sql = "select * FROM item ORDER BY name";
try {
$db = getConnection();
$stmt = $db->query($sql);
$items = $stmt->fetchAll(PDO::FETCH_OBJ);
$db = null;
// echo '{"items": ' . json_encode($items) . '}';
echo json_encode($items);
} catch (PDOException $e) {
echo '{"error":{"text":' . $e->getMessage() . '}}';
}
}
function getItem($id)
{
$sql = "SELECT * FROM item WHERE id=:id";
try {
$db = getConnection();
$stmt = $db->prepare($sql);
示例11: function
<h2>Slim Framework Extras</h2>
<p>
Custom View classes for Smarty, Twig, Mustache, and other template
frameworks are available online in a separate repository.
</p>
<p><a href="https://github.com/codeguy/Slim-Extras" target="_blank">Browse the Extras Repository</a></p>
</section>
</body>
</html>
EOT;
echo $template;
});
//POST route
$app->post('/post', function () {
echo 'This is a POST route';
});
//PUT route
$app->put('/put', function () {
echo 'This is a PUT route';
});
//DELETE route
$app->delete('/delete', function () {
echo 'This is a DELETE route';
});
/**
* Step 4: Run the Slim application
*
* This method should be called last. This is responsible for executing
* the Slim application using the settings and routes defined above.
*/
$app->run();
示例12: array
<?php
set_include_path(implode(PATH_SEPARATOR, array(realpath(dirname(__FILE__) . '/library'), get_include_path())));
require_once 'Slim/Slim.php';
require_once 'controller/ProdutosController.php';
$app = new Slim();
$pcontroller = new ProdutosController();
$app->get('/produtos', function () use($pcontroller) {
echo json_encode($pcontroller->listarProdutos());
});
$app->post('/produtos', function () use($pcontroller, $app) {
$produto = json_decode(file_get_contents("php://input"));
echo json_encode($pcontroller->salvarProduto($produto));
});
$app->put('/produtos', function () use($pcontroller, $app) {
$produto = $app->request()->put();
unset($produto['$$hashKey']);
echo json_encode($pcontroller->atualizarProduto($produto));
});
$app->delete('/produtos/:id', function ($id) use($pcontroller) {
echo $pcontroller->removerProduto($id);
});
$app->run();
示例13: getConnection
<?php
require 'Slim/Slim.php';
$app = new Slim();
$app->get('/users', 'getUsers');
$app->post('/users', 'addUser');
$app->get('/users/:id', 'getUser');
$app->get('/users/search/:query', 'findByName');
$app->put('/users/:id', 'updateUser');
$app->delete('/users/:id', 'deleteUser');
$app->run();
function getConnection()
{
$dbhost = "127.0.0.1";
$dbuser = "root";
$dbpass = "root";
$dbname = "angular-mysql";
$dbh = new PDO("mysql:host={$dbhost};dbname={$dbname}", $dbuser, $dbpass);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $dbh;
}
function getUsers()
{
$sql = "select * FROM users ORDER BY id";
try {
$db = getConnection();
$stmt = $db->query($sql);
$users = $stmt->fetchAll(PDO::FETCH_OBJ);
$db = null;
echo json_encode($users);
} catch (PDOException $e) {
示例14: getWines
<?php
require 'Slim/Slim.php';
$app = new Slim();
$app->get('/wines', 'getWines');
$app->get('/wines/:id', 'getWine');
$app->get('/wines/search/:query', 'findByName');
$app->post('/wines', 'addWine');
$app->put('/wines/:id', 'updateWine');
$app->delete('/wines/:id', 'deleteWine');
$app->run();
function getWines()
{
$sql = "select * FROM wine ORDER BY name";
try {
$db = getConnection();
$stmt = $db->query($sql);
$wines = $stmt->fetchAll(PDO::FETCH_OBJ);
$db = null;
// echo '{"wine": ' . json_encode($wines) . '}';
echo json_encode($wines);
} catch (PDOException $e) {
echo '{"error":{"text":' . $e->getMessage() . '}}';
}
}
function getWine($id)
{
$sql = "SELECT * FROM wine WHERE id=:id";
try {
$db = getConnection();
$stmt = $db->prepare($sql);
示例15: getBeers
<?php
require 'Slim/Slim.php';
$app = new Slim();
$app->get('/beers', 'getBeers');
$app->get('/beers/:id', 'getBeer');
$app->get('/beers/search/:query', 'findByName');
$app->post('/beers', 'addBeer');
$app->put('/beers/:id', 'updateBeer');
$app->delete('/beers/:id', 'deleteBeer');
$app->run();
function getBeers()
{
$sql = "select * FROM wine ORDER BY name";
try {
$db = getConnection();
$stmt = $db->query($sql);
$beers = $stmt->fetchAll(PDO::FETCH_OBJ);
$db = null;
// echo '{"wine": ' . json_encode($beers) . '}';
echo json_encode($beers);
} catch (PDOException $e) {
echo '{"error":{"text":' . $e->getMessage() . '}}';
}
}
function getBeer($id)
{
$sql = "SELECT * FROM wine WHERE id=:id";
try {
$db = getConnection();
$stmt = $db->prepare($sql);