Skip to content

Commit 6c20c7d

Browse files
committed
added all the files, updated readme
1 parent 93d0971 commit 6c20c7d

File tree

119 files changed

+12888
-18
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+12888
-18
lines changed

.htaccess

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
RewriteEngine On
2+
3+
# Some hosts may require you to use the `RewriteBase` directive.
4+
# If you need to use the `RewriteBase` directive, it should be the
5+
# absolute physical path to the directory that contains this htaccess file.
6+
#
7+
#RewriteBase /slim/
8+
9+
RewriteCond %{REQUEST_FILENAME} !-f
10+
RewriteRule ^ index.php [QSA,L]

README.md

+26-18
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
Slim PHP Mongo REST server
22
==========================
33

4-
MongoDB REST server using Slim PHP
4+
MongoDB REST server using Slim PHP.
5+
6+
I've just thrown this up quickly, there might be an error or two. But I am hoping to polish it a bit and add a few features to bring it more in line with the Node.js one I have used before. Probably a good starting point for people looking to do more advanced things, or just of interest anyone looking into Slim or Mongo with PHP. And if someone uses it and I get a pull request, all the better!
57

68
Requirements
79
============
@@ -24,7 +26,7 @@ Fetch collection
2426
Get all in collection (respecting limit set in mongo-list.php)
2527

2628
```javascript
27-
$.get(
29+
$.getJSON(
2830
'/database/collection',
2931
function(data) {
3032
console.log(data);
@@ -35,20 +37,26 @@ $.get(
3537
Get blogs with phone in the title
3638

3739
```javascript
38-
$.get(
39-
'/database/collection',
40-
{
41-
filter: {
42-
type: 'blogs'
40+
$.ajax({
41+
url: '/database/collection',
42+
type: 'POST',
43+
contentType: 'application/json',
44+
dataType: 'json',
45+
data: JSON.stringify({
46+
filter: {
47+
type: 'blogs'
48+
},
49+
wildcard: {
50+
title: 'phone'
51+
}
52+
}),
53+
success: function(data) {
54+
console.log(data);
4355
},
44-
wildcard: {
45-
title: 'phone'
56+
error: function (data) {
57+
console.log(data);
4658
}
47-
},
48-
function(data){
49-
console.log(data);
50-
}
51-
);
59+
});
5260
```
5361

5462
And in Backbone
@@ -114,9 +122,9 @@ $.ajax({
114122
});
115123
```
116124

117-
What's coming next
118-
==================
125+
Todo
126+
====
119127

120128
* Save/Update/Delete multiple
121-
* Fast update using save()
122-
* More configurable filter/regex options for listing
129+
* Alternate update using save()
130+
* Check it works... :-D

Slim/LICENSE

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2011 Josh Lockhart
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is furnished
8+
to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

Slim/README.markdown

+163
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
# Slim Framework for PHP 5
2+
3+
Slim is a micro framework for PHP 5 that helps you quickly write simple yet powerful RESTful web applications and APIs. Slim is easy to use for both beginners and professionals. Slim favors cleanliness over terseness and common cases over edge cases. Its interface is simple, intuitive, and extensively documented — both online and in the code itself. Thank you for choosing Slim for your next project. I think you're going to love it.
4+
5+
## Features
6+
7+
* Clean and simple [DSL](http://en.wikipedia.org/wiki/Domain-specific_language) for writing powerful web applications
8+
* HTTP routing
9+
* Supports all standard and custom HTTP request methods
10+
* Route parameters and conditions
11+
* Route redirects
12+
* Route passing
13+
* Route halting
14+
* Route middleware
15+
* Named routes and `urlFor()` helper
16+
* Easy configuration
17+
* Easy templating with custom Views (e.g. Twig, Mustache, Smarty)
18+
* Flash messaging
19+
* Signed cookies with AES-256 encryption
20+
* HTTP caching (ETag and Last-Modified)
21+
* Logging
22+
* Error handling
23+
* Custom Not Found handler
24+
* Custom Error handler
25+
* Debugging
26+
* Built upon the Rack protocol
27+
* Extensible middleware and hook architecture
28+
* Supports PHP >= 5.2.0
29+
30+
## "Hello World" application (PHP >= 5.3)
31+
32+
The Slim Framework for PHP 5 supports anonymous functions. This is the preferred method to define Slim application routes. This example assumes you have setup URL rewriting with your web server (see below).
33+
34+
```php
35+
<?php
36+
require 'Slim/Slim.php';
37+
$app = new Slim();
38+
$app->get('/hello/:name', function ($name) {
39+
echo "Hello, $name!";
40+
});
41+
$app->run();
42+
```
43+
44+
## "Hello World" application (PHP < 5.3)
45+
46+
If you are running PHP < 5.3, the second argument to the application's `get()` instance method is the name of a callable function instead of an anonymous function. This example assumes you have setup URL rewriting with your web server (see below).
47+
48+
```php
49+
<?php
50+
require 'Slim/Slim.php';
51+
$app = new Slim();
52+
$app->get('/hello/:name', 'hello');
53+
function hello($name) {
54+
echo "Hello, $name!";
55+
}
56+
$app->run();
57+
```
58+
59+
## Get Started
60+
61+
### Install Slim
62+
63+
Download the Slim Framework for PHP 5 and unzip the downloaded file into your virtual host's public directory. Slim will work in a sub-directory, too.
64+
65+
### Setup your webserver
66+
67+
#### Apache
68+
69+
Ensure the `.htaccess` and `index.php` files are in the same public-accessible directory. The `.htaccess` file should contain this code:
70+
71+
RewriteEngine On
72+
RewriteCond %{REQUEST_FILENAME} !-f
73+
RewriteRule ^ index.php [QSA,L]
74+
75+
#### Nginx
76+
77+
Your nginx configuration file should contain this code (along with other settings you may need) in your `location` block:
78+
79+
if (!-f $request_filename) {
80+
rewrite ^ /index.php last;
81+
}
82+
83+
This assumes that Slim's `index.php` is in the root folder of your project (www root).
84+
85+
#### lighttpd ####
86+
87+
Your lighttpd configuration file should contain this code (along with other settings you may need). This code requires lighttpd >= 1.4.24.
88+
89+
url.rewrite-if-not-file = ("^" => "/index.php")
90+
91+
This assumes that Slim's `index.php` is in the root folder of your project (www root).
92+
93+
### Build Your Application
94+
95+
Your Slim application will be defined in `index.php`. First, `require` the Slim Framework:
96+
97+
```php
98+
require 'Slim/Slim.php';
99+
```
100+
101+
Next, initialize the Slim application:
102+
103+
```php
104+
$app = new Slim();
105+
```
106+
107+
Next, define your application's routes:
108+
109+
```php
110+
$app->get('/hello/:name', function ($name) {
111+
echo "Hello $name";
112+
});
113+
```
114+
115+
Finally, run your Slim application:
116+
117+
```php
118+
$app->run();
119+
```
120+
121+
For more information about building an application with the Slim Framework, refer to the [official documentation](http://github.com/codeguy/Slim/wiki/Slim-Framework-Documentation).
122+
123+
## Documentation
124+
125+
* [Stable Branch Documentation](http://www.slimframework.com/documentation/stable)
126+
* [Development Branch Documentation](http://www.slimframework.com/documentation/develop)
127+
128+
## Community
129+
130+
### Forum and Knowledgebase
131+
132+
Visit Slim's official forum and knowledge base at <http://help.slimframework.com> where you can find announcements, chat with fellow Slim users, ask questions, help others, or show off your cool Slim Framework apps.
133+
134+
### Twitter
135+
136+
Follow [@slimphp](http://www.twitter.com/slimphp) on Twitter to receive the very latest news and updates about the framework.
137+
138+
### IRC
139+
140+
You can find me, Josh Lockhart, hanging out in the ##slim chat room during the day. Feel free to say hi, ask questions, or just hang out. If you're on a Mac, check out Colloquy; if you're on a PC, check out mIRC; if you're on Linux, I'm sure you already know what you're doing.
141+
142+
## Resources
143+
144+
Additional resources (ie. custom Views and plugins) are available online in a separate repository.
145+
146+
<https://github.com/codeguy/Slim-Extras>
147+
148+
Here are more links that may also be useful.
149+
150+
* Road Map: <http://github.com/codeguy/Slim/wiki/Road-Map>
151+
* Source Code: <http://github.com/codeguy/Slim/>
152+
153+
## About the Author
154+
155+
Slim is created and maintained by Josh Lockhart, a web developer by day at [New Media Campaigns](http://www.newmediacampaigns.com), and a [hacker by night](http://github.com/codeguy).
156+
157+
Slim is in active development, and test coverage is continually improving.
158+
159+
## Open Source License
160+
161+
Slim is released under the MIT public license.
162+
163+
<http://www.slimframework.com/license>

0 commit comments

Comments
 (0)