I will not be doing more work on this framework. However, many of the philosophies and syntax are used in the node.js successor to this project. Check it out @ https://github.com/evantahler/actionHero If you are interested in helping to maintain this project, please open an Issue or Pull Request, and let me know!
DAVE is a minimalist, multi-node, transactional API framework written in PHP
Dave contains an end-to-end API test suite for TDD, a Task model, an Active Database Model, and a stand-alone development server (written in PHP) to get you started.
DAVE is an acronym that stands for Delete, Add, Edit, and View. These four methods make up the core functionality of many transactional web applications. The DAVE API aims to simplify and abstract may of the common tasks that these types of APIs require. DAVE does the work for you, and he's not CRUD. Dave was built to be both easy to use, but to be as simple as possible. I was tired of bloated frameworks that were designed to be monolithic applications which include M's, V's, and C's together in a single running application. As applications grow and become more 'service oriented', this is the eventual route which many applications go. I wanted to make is as simple as possible to create a new application with this mindset, and to allow for future flexibility.
The DAVE API defines a single access point and accepts GET, POST, or COOKIE input. You define "Action's" that handle the input, such as "AddUser" or "GeoLocate". The DAVE API is NOT "RESTful", in that it does not use the normal verbs (Get, Put, etc) and uses a single /path/. This was chosen to make it as simple as possible for devices/users to access the functions, including low-level embedded devices which may have trouble with all the HTTP verbs. To see how simple it is to handle basic actions, this package comes with a basic user system included. Look in /Actions/examples
to see the logic behind adding, editing, viewing, and deleting users. This includes log in. RESTful paths are optional if you really must have them, and be defined per Action.
The DAVE API understands 2 types of security methodology. "Public" actions can be called by anyone, and then can implement optional user-based security (checking userIDs and PasswordHashes?). Optionally, certain Actions can be defined as "Private", and will require a defined developer to authenticate with every request. This requires your developers to provide an MD5 hash of their APIKey and private DeveloperID to authenticate with. You can mix private and public actions. Of course, you can make your own actions for this as well!
Dave contains an end-to-end API test suite for TDD, a Task model, an Active Database Model, and a stand-alone development server (written in just PHP) to get you started.
If you have ever asked these questions of other web-frameworks, then DAVE might be the right fit for you:
To help with development, a single-threaded multi-request webserver is a part of this project. This will allow you to locally run this framework in "development mode". This webserver is written entirely in PHP and has support for basic static file-types (css, js, images, html) along with the sand-boxed execution of PHP scripts (including all of those required for this framework.). The server currently provides the normal $_GET, $_POST, $_COOKIE, $_REQUEST arrays and a basic emulation of $SERVER. Due to metaprogramming limitations in the default PHP installs on most servers/machines, it is impossible to modify the behavior of header() and setcookie(). To remedy this, please use _header() and _setcookie() in your DAVE projects. These functions will first attempt to use the default versions of these functions, and if they fail (AKA when using the StandAlone server), will emulate their behavior in other ways. This server implementation was inspired by nginx and rails unicorns, and makes use of spawning OS-level processes to do the heavy lifting for each request.
You certainly don't need to use the bundled SERVER to run dave. For production deployment, upload DAVE to /var/www/html
(or however you normally deploy). The SERVER was included to allow for local test-driven development common to other frameworks/languages to which the modern web developer may be accustomed too.
Run "php SERVER.php" from within the project directory to get started. Point your browser at http://localhost:3000
However, for production deployment, your traditional LAMP stack is best.
You can get started on your local machine in 5 minutes! This tutorial is for Unix-like machines (OSX OK!). We'll be using the included stand-alone server for development. You certainly don't need to use the bundled SERVER to run dave. For production deployment, upload DAVE to /var/www/html
(or however you normally deploy).
git clone git://github.com/evantahler/PHP-DAVE-API.git /path/where/you/want/it
OR just hit the download
button above/API/CONFIG.example.php
to /API/CONFIG.php
$CONFIG['SystemTimeZone']
(check http://www.php.net/manual/en/timezones.php for how to define your timezone)$CONFIG['App_dir']
(this is where the /API folder is)mysql -u root
create database daveapi;
exit
mysql -u root daveapi < BaseDBs/API_WITH_USER_TABLE.sql
crontab -e
*/1 * * * * /usr/bin/php /path/to/CRON.php > /path/to/CRON_LOG.txt
php /SERVER/SERVER.php
http://localhost:3000&OutputType=XML
time curl -v http://127.0.0.1:3000/ -d "OutputType=XML"
script/api --Action=DescribeActions
That's it! You should see JSON and XML output that describes all of the actions that the server could preform, and an Error asking you to supply an action. Give http://localhost:3000/?OutputType=XML&Action=ObjectTest
or http://localhost:3000/?OutputType=PHP&Action=SlowAction
a try to see some basic examples.