1. Go to this page and download the library: Download saturn/taurus library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// Add it to the API version's base folder, i.e. /application/1.0/BaseAPI.php
use taurus\core\BaseAPI;
class API extends BaseAPI {
}
// /application/1.0/Resources/Example.php
// This end point is accessible by calling: http://api.example.dev/1.0/Example or:
// http://api.example.dev/1.0/Example/remove/15
use taurus\core\Resource;
class Example extends Resource {
protected function main() {
$data = $this->model->getExamples($id);
if (isset($data["error"])) {
$data = $data["error"];
$this->statusCode = 500;
}
$this->response($data, $this->statusCode);
}
protected function remove() {
$id = $this->arguments[0];
if (isset($id)) {
$response = $this->model->deleteExample($id);
$this->statusCode = 200;
} else {
$response = "No id given";
$this->statusCode = 400;
}
$this->response($response, $this->statusCode);
}
}
// /application/1.0/Resources/ExampleModel.php
use taurus\core\Model;
class ExampleModel extends Model {
public function getExamples() {
$query = "SELECT name FROM Examples";
return $this->database->read($query);
}
public function deleteExample($id) {
$query = "DELETE FROM Examples WHERE id = :id";
$param = array("id" => $id);
$response = $this->database->write($query, $param);
return $response;
}
}
- application/
- 1.0/
- Resources/
+ Example.php // The end point
- Models/
+ ExampleModel.php // The Model file for Example (optional)
- BaseAPI.php (Each API version must extend the Base API class.)
- 1.1/
- Resources/
- Models/
- BaseAPI.php
- index.php
- .htaccess
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.