Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/johnmurray/pinatra
Sinatra clone in PHP
https://github.com/johnmurray/pinatra
Last synced: about 2 months ago
JSON representation
Sinatra clone in PHP
- Host: GitHub
- URL: https://github.com/johnmurray/pinatra
- Owner: JohnMurray
- Created: 2013-01-03T21:09:00.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2023-03-29T20:25:16.000Z (almost 2 years ago)
- Last Synced: 2024-10-15T23:26:01.741Z (3 months ago)
- Language: PHP
- Size: 29.3 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Pinatra
__Update:__ I finished everything that I had planned to do... So, unless someone
else finds this project interesting, I believe that I am done working on it for
now. Mainly because there are better/more-mature projects out there.If the name of this project isn't enough to let you know what it is, this is a
Sinatra clone in PHP. Currently this is not a serious project, just a little
something for me to try and learn a little more about PHP.My background is
mainly in Ruby and I have a strong love for Sinatra. So, I'm taking about the
task to implement the basic feature-set that is present in Sinatra. Mainly
the minimalistic route matching and hooks that Sinatra exposes for whipping
up dandy little web-apps/api's very quickly.## Getting Started
A simple hello-world example in good 'ole Sinatra fashion:
```php
# index.php
require 'pinatra.php';Pinatra::get('/hi', function () { return 'Hello World!'; });
Pinatra::run();
``````bash
php -S 0.0.0.0:8181
```Before hooks:
```php
// before everything, set a custom header
Pinatra::before('*', function () { header("MyApp: v${version}"); });// before user's view their profile, force an update of
// their stream (silly example)
Pinatra::before('/user-profile/:id', function($id) {
update_user_stream($id);
});
```After hooks:
```php
// update site's hit-counter (also silly, but you get the point right?)
Pinatra::after('*', function () {
update_site_hit_counter();
});
```## Compatability
This little framework is only compatible with PHP v5.4.x since it was just
for fun and I don't care about any sort of backwards compatability.## On the Calendar
The items that I will be adding/implementing next are (roughly) as follows:
+ ~~Parametric URIs (variables actually passed to the handler functions)~~
+ ~~Refactoring of handle_request function~~
+ ~~Configuration blocks~~
+ ~~Testing before and after hooks~~ (working)
+ ~~POST functionality~~
+ ~~PUT functionality~~
+ ~~DELETE functionality~~
+ ~~HEAD functionality~~## Contributing
This project is dead.