PHPackages                             andrew-natoli/rapid-rest - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. andrew-natoli/rapid-rest

AbandonedProject[API Development](/categories/api)

andrew-natoli/rapid-rest
========================

Rapid prototyping and development of CRUD REST API's for personal use.

1.0.1(10y ago)6394[4 issues](https://github.com/AndrewNatoli/PHP-RapidREST/issues)MITPHPPHP &gt;=5.3.0

Since Oct 15Pushed 9y ago4 watchersCompare

[ Source](https://github.com/AndrewNatoli/PHP-RapidREST)[ Packagist](https://packagist.org/packages/andrew-natoli/rapid-rest)[ Docs](http://andrewnatoli.com/portfolio/php-rapidrest/)[ RSS](/packages/andrew-natoli-rapid-rest/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

\#PHP-RapidREST
===============

[](#php-rapidrest)

**RapidREST allows you to have a working CRUD API in sixty seconds!**

Background
==========

[](#background)

=============

#### First I had a problem...

[](#first-i-had-a-problem)

I've been looking build simple test applications that implement API's as a learning experience but dreaded the time commitment for designing databases and doing the actual programming for an application I'd abandon after three days. Architecting a clever, re-usable way to handle database access was my main problem so I started [PHP Model Buddy](https://github.com/AndrewNatoli/PHP-ModelBuddy). Months have gone by and my dwindling free time to experiment has left me with a half-finished database access framework.

#### ...then came RedBeanPHP...

[](#then-came-redbeanphp)

I recently discovered [RedBeanPHP](http://redbeanphp.com/) and my problem was solved. If you're not familiar with it, RedBeanPHP is an on-the-fly ORM for PHP. Want to create a record in a table that doesn't exist? Boom, the table and columns are made. It's absolutely perfect if you want to get up and running quickly.

#### ...and the Slim Framework. Problem solved!

[](#and-the-slim-framework-problem-solved)

Rather than re-inventing the wheel I decided to use [Slim Framework](http://www.slimframework.com/) in RapidREST to handle the API routes. Check /config/routes.php and you'll thank me for doing so.

\#Installation
==============

[](#installation)

### Requirements...

[](#requirements)

You'll need an apache server with **mod\_rewrite** and **PHP &gt;= 5.3.0**

**Composer** is needed to install the dependencies.

Install with Composer
---------------------

[](#install-with-composer)

```
php composer.phar create-project andrew-natoli/rapid-rest -sdev

```

OR... Use git &amp; composer
----------------------------

[](#or-use-git--composer)

### Clone the Repo!

[](#clone-the-repo)

```
git clone https://github.com/AndrewNatoli/PHP-RapidREST.git

```

### Install the dependencies!

[](#install-the-dependencies)

Now use [composer](https://getcomposer.org/download/) to install [Slim Framework](http://www.slimframework.com/) and [RedBeanPHP](http://redbeanphp.com).

```
sudo php composer.phar update

```

Once installed... connect to the database!
------------------------------------------

[](#once-installed-connect-to-the-database)

Open **/config/rapidrest-config.php** to configure your database connection.

All Done!
---------

[](#all-done)

Enjoy your CRUD API!

Base Wildcard Endpoints
=======================

[](#base-wildcard-endpoints)

============= There are five base universal routes in RapidREST. They're perfect for prototyping small applications but I suggest removing and re-writing their controllers before moving your app to production if it's going to be public.

ReadBeanPHP will automatically build the table schema for you based on the information you send.

#### GET list - yourapi.com/:table/

[](#get-list---yourapicomtable)

Returns all of the records and their contents in the specified table.

```
{
  "statuscode": 200,
  "data": [{
    "id": "1",
    "title": "Important Message",
    "text": "Hello, world!"
  }, {
    "id": "2",
    "title": "Also important",
    "text": "This is a message"
  }],
  "count": 2
}

```

#### GET record - yourapi.com/:table/:id

[](#get-record---yourapicomtableid)

Returns the specified record from a table.

```
{
  "statuscode": 200,
  "data": [{
	"id": "1",
	"text": "Bacon!",
	"title": "Important Message"
  }]
}

```

#### POST record - yourapi.com/:table/

[](#post-record---yourapicomtable)

Creates a new record in the table.

```
{
  "statuscode": 200,
  "data": {
	"id": 3
  }
}

```

#### PUT record - yourapi.com/:table/:id

[](#put-record---yourapicomtableid)

Updates an existing record in the table.

```
{
  "statuscode": 200,
  "data": {
	"id": 2
  }
}

```

#### DELETE record - yourapi.com/:table/:id

[](#delete-record---yourapicomtableid)

Deletes a record from the table.

```
{
	"statuscode": 200,
	"deleted": true
}

```

Response Formats
================

[](#response-formats)

============= These return a JSON response by the way. If a record can't be found, updated, created, etc. the program will spit out a JSON error message.

**GET** requests will list the found record(s) within the "data" array:

**POST** and **PUT** will return the ID of the created (or updated) record:

**DELETE** will response with whether not a record was deleted.

**Exceptions** look like this:

```
{"message":"Record not found.","statusCode":404}

```

Making Changes...
=================

[](#making-changes)

============= As mentioned earlier, you'll probably want to remove the stock API routes and controllers when you take your application public. This is a quick guide to where everything is so you can evolve your RapidREST Prototype API into a production-worthy API.

#### Where everything is...

[](#where-everything-is)

- Configure your database connection in **/config/rapidrest-config.php**
- Define your custom routes in **/config/routes.php**
- Include custom classes in **/config/loader.php**
- The stock API controllers are found in **/lib/RapidRest/RapidRest.php**
- You can also find the APIException and JSON Response classes within **/lib/RapidRest/**

#### Namespaces...

[](#namespaces)

- RedBeanPHP operates in the root namespace.
- APIException() is in API\\Exceptions
- JSON() is in API\\Response

#### How to...

[](#how-to)

##### Throw an exception:

[](#throw-an-exception)

Kill the process and return a JSON-encoded error message!

```
use API\Exceptions\APIException
throw new APIException("Record not found!",404);

```

##### Output data to the client

[](#output-data-to-the-client)

It's reccomended you use the Response classes rather than simply using json\_encode() to allow for easy changes to your code in the future. You can extend the base JSON or abstract Response class and define your own methods to whitelist values or output additional data.

```
use API\Response\JSON
$response = array();
$response['data'] = $array_or_object;
return new JSON($response);

```

#### What else you'll need to know for production...

[](#what-else-youll-need-to-know-for-production)

- While **/config/routes.php** shows you basically everything you need to know for creating custom routes, do a little research about Slim Framework to make yourself comfy.
- Learn how to use **RedBeanPHP4** for building your custom controllers. Be sure you understand its strict database conventions.

Contributing...
===============

[](#contributing)

============= Pull requests welcome :)

Acknowledgements...
===================

[](#acknowledgements)

============= Cheers to necenzurat for devising a way of installing RedBeanPHP through composer.

And of course, Cheers to the developers of [Slim Framework](http://www.slimframework.com/) and [RedBeanPHP](http://redbeanphp.com).

License
=======

[](#license)

============= ##The MIT License (MIT)

Copyright (c) 2014 Andrew Natoli

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance7

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~427 days

Total

2

Last Release

3800d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/54fea9e04b30c3b5f15d9c9df249254236fb8b9fb06f4bf99db369746dcfd565?d=identicon)[AndrewNatoli](/maintainers/AndrewNatoli)

---

Top Contributors

[![AndrewNatoli](https://avatars.githubusercontent.com/u/4162073?v=4)](https://github.com/AndrewNatoli "AndrewNatoli (20 commits)")[![gitter-badger](https://avatars.githubusercontent.com/u/8518239?v=4)](https://github.com/gitter-badger "gitter-badger (1 commits)")

### Embed Badge

![Health badge](/badges/andrew-natoli-rapid-rest/health.svg)

```
[![Health](https://phpackages.com/badges/andrew-natoli-rapid-rest/health.svg)](https://phpackages.com/packages/andrew-natoli-rapid-rest)
```

###  Alternatives

[b13/slimphp-bridge

Provides a middleware for registering Slim PHP applications within TYPO3 Frontend Sites

2047.2k1](/packages/b13-slimphp-bridge)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
