Skip to content
This repository was archived by the owner on May 4, 2018. It is now read-only.

Commit 353b3e1

Browse files
committed
Update README
1 parent 13b6e90 commit 353b3e1

File tree

1 file changed

+1
-165
lines changed

1 file changed

+1
-165
lines changed

README.md

Lines changed: 1 addition & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -1,165 +1 @@
1-
### This repo is no longer maintained. If you would like to take over ownership please [get in touch](mailto:[email protected]).
2-
3-
#Arrest MySQL
4-
5-
Arrest MySQL is a "plug-n-play" RESTful API for your MySQL database. Arrest MySQL provides a REST API that maps directly to your database stucture with no configuation.
6-
7-
For example lets suppose you have set up Arrest MySQL at http://api.example.com and your database has a table in it called "customers". To get a list of customers you would simply need to do:
8-
9-
```GET http://api.example.com/customers```
10-
11-
Where "customers" is the table name. As a response you would get a JSON formatted list of customers. Or say you only want to get one customer, then you would do this:
12-
13-
```GET http://api.example.com/customers/123```
14-
15-
Where "123" here is the ID of the customer. For more information on using Arrest MySQL see the Usage section below.
16-
17-
##Requirements
18-
19-
1. Apache Server with PHP 5+
20-
2. MySQL 5+
21-
22-
##30 Second Installation
23-
24-
Simply put these files into a folder somewhere on your server. Then edit config.php and fill in your database details and you are good to go.
25-
26-
##Usage
27-
28-
If you edit index.php you will see how incredibly simple it is to set up Arrest MySQL. Note that you are left to **provide your own authentication** for your API when using Arrest MySQL.
29-
30-
```php
31-
<?php
32-
require('config.php');
33-
require('lib/arrest-mysql.php');
34-
35-
try {
36-
37-
/**
38-
* Note: You will need to provide a base_uri as the second param if this file
39-
* resides in a subfolder e.g. if the URL to this file is http://example.com/some/sub/folder/index.php
40-
* then the base_uri should be "some/sub/folder"
41-
*/
42-
$arrest = new ArrestMySQL($db_config);
43-
44-
/**
45-
* By default it is assumed that the primary key of a table is "id". If this
46-
* is not the case then you can set a custom index by using the
47-
* set_table_index($table, $field) method
48-
*/
49-
//$arrest->set_table_index('my_table', 'some_index');
50-
51-
$arrest->rest();
52-
53-
} catch (Exception $e) {
54-
echo $e;
55-
}
56-
?>
57-
```
58-
59-
###API Design
60-
61-
The actual API design is very straight forward and follows the design patterns of most other API's.
62-
63-
```
64-
create > POST /table
65-
read > GET /table[/id]
66-
update > PUT /table/id
67-
delete > DELETE /table/id
68-
```
69-
70-
To put this into practice below are some example of how you would use an Arrest MySQL API:
71-
72-
```
73-
// Get all rows from the "customers" table
74-
GET http://api.example.com/customers
75-
// Get a single row from the "customers" table (where "123" is the ID)
76-
GET http://api.example.com/customers/123
77-
// Get 50 rows from the "customers" table
78-
GET http://api.example.com/customers?limit=50
79-
// Get 50 rows from the "customers" table ordered by the "date" field
80-
GET http://api.example.com/customers?limit=50&order_by=date&order=desc
81-
82-
// Create a new row in the "customers" table where the POST data corresponds to the database fields
83-
POST http://api.example.com/customers
84-
85-
// Update customer "123" in the "customers" table where the PUT data corresponds to the database fields
86-
PUT http://api.example.com/customers/123
87-
88-
// Delete customer "123" from the "customers" table
89-
DELETE http://api.example.com/customers/123
90-
```
91-
92-
###Responses
93-
94-
All responses are in the JSON format. For example a GET response from the "customers" table might look like:
95-
96-
```json
97-
[
98-
{
99-
"id": "114",
100-
"customerName": "Australian Collectors, Co.",
101-
"contactLastName": "Ferguson",
102-
"contactFirstName": "Peter",
103-
"phone": "123456",
104-
"addressLine1": "636 St Kilda Road",
105-
"addressLine2": "Level 3",
106-
"city": "Melbourne",
107-
"state": "Victoria",
108-
"postalCode": "3004",
109-
"country": "Australia",
110-
"salesRepEmployeeNumber": "1611",
111-
"creditLimit": "117300"
112-
},
113-
...
114-
]
115-
```
116-
117-
Successful POST, PUT, and DELETE responses will look like
118-
119-
```json
120-
{
121-
"success": {
122-
"message": "Success",
123-
"code": 200
124-
}
125-
}
126-
```
127-
128-
Errors are in the format:
129-
130-
```json
131-
{
132-
"error": {
133-
"message": "No Content",
134-
"code": 204
135-
}
136-
}
137-
```
138-
139-
The following codes and message are avaiable:
140-
141-
* 200 Success
142-
* 204 No Content
143-
* 404 Not Found
144-
145-
##Credits
146-
147-
Arrest MySQL was created by [Gilbert Pellegrom](http://gilbert.pellegrom.me) from [Dev7studios](http://dev7studios.com).
148-
149-
Please contribute by [reporting bugs](Arrest-MySQL/issues) and submitting [pull requests](Arrest-MySQL/pulls).
150-
151-
##License (MIT)
152-
153-
Copyright © 2013 Dev7studios
154-
155-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
156-
files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy,
157-
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
158-
is furnished to do so, subject to the following conditions:
159-
160-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
161-
162-
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
163-
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
164-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
165-
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1+
### This repo is no longer maintained. Development has continued over at [ArrestDB](https://github.com/alixaxel/ArrestDB)

0 commit comments

Comments
 (0)