Download the PHP package nebiros/yasc without Composer
On this page you can find all versions of the php package nebiros/yasc. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package yasc
Short Description Yet Another Sinatra Clone
License BSD-3-Clause
Homepage https://github.com/nebiros/yasc
Informations about the package yasc
YASC
Yet Another Sinatra Clone
yasc
is a sinatra (kind of) clone written in php
and highly influenced by zend framework 1.x, the routing system is based on
limonade's code, is a tiny framework that uses user defined functions as actions
(like in the MVC pattern) and annotations to route the requested url to a function.
Features
- Functions based.
- RESTful.
- Tiny ^_^.
- Routing system based on regex patterns, named params, pairs param (like zend framework 1.x).
- View helpers.
- Function helpers.
- Layouts support.
- Class autoloading based on the Framework Interop Group.
- Models support.
Default project structure
yasc
uses this project structure:
app.php
views/
helpers/
models/
If you create these folders in your project they are auto-loaded in your application. Default namespaces:
helpers/Helper_*
models/Model_*
Accessors
I saw that invoking the requested function with a lot of arguments is too ugly and a little bit verbose (just a little?), so I add some accessors to be used in each function.
Prerequisites
yasc
requires PHP 5.2.4 or later.
Installation
Easiest way to install yasc
is through composer,
or add it as a git submodule
.
Create a index.php or a app.php file and include yasc
, like:
Add a function and a pattern using an annotation for your application index, your script will be something like this:
Now, go to your favorite browser and run your script:
http://localhost/app.php
Follow the examples and you'r done :).
Setup
Maybe you want to hide your script file from the URL, http://app.com/app.php/some/thing (I know, pretty URLs, SEO shut, blah, blah) and get something fancier like: http://app.com/some/thing, ok, well, create a VirtualHost and add a .htaccess file to your application folder like this:
Virtual host configuration
<VirtualHost *:80>
DocumentRoot "/path/to/your/application/public"
ServerName app.com
<Directory "/path/to/your/application/public">
Options -Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
.htaccess file
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
NOTE: Your app file must be named index.php in order to work with this .htaccess
file.
Simple Example
Configuration
Pre- and Post-Dispatch Hooks
We provide two functions, pre_dispatch
and post_dispatch
, that may be called before and after an action is
invoked.
Advanced Examples
TODO
Support for PUT and DELETE methods.Support regex in annotations.Add PUT and DELETE annotations.Add layouts support.Add view helpers support.- Caching.
- Tests.
Improve documentation.