| Recommend this page to a friend! |
| Info | Documentation | Reputation | Support forum | Blog | Links |
| Ratings | Unique User Downloads | Download Rankings | ||||
| Not yet rated by the users | Total: 35 | All time: 11,039 This week: 673 | ||||
| Version | License | PHP version | Categories | |||
| zeus-framework 1.0 | MIT/X Consortium ... | 5 | HTTP, PHP 5, Libraries |
| Description | Author | |
This package implements a framework that reads annotation to route requests. |
A lightweight framework with an annotation-based approach for routing.
Using annontation @Route you set a unique pattern. When Zeus detect this
pattern in a request, redirects to properly class/method and execute it
STATICALLY.
<?php
namespace MyBlog;
class Post
{
/ @Route("post/show/$id") */
public static function show($id)
{
// code goes here
}
/ @Route("post/create") */
public static function create()
{
// code goes here
}
/ @Route("post/edit/$id") */
public static function edit($id)
{
// code goes here
}
}
?>
This library can be found on Packagist. We endorse that everything will work fine if you install this through composer.
Add in your composer.json:
{
"require": {
"natanaelsimoes/zeus-framework": "0.1.0"
}
}
or in your bash:
$ composer require natanaelsimoes/zeus-framework
You need to create 2 files on your project root folder: zeus.json containing
Zeus configuration (see more at Configuration section below), and index.php
just calling Zeus for the first time.
<?php
include_once 'vendor/autoload.php';
Zeus\Framework::start();
?>
To configure Zeus, a zeus.json file needs to be created at project root
folder. Following is the configuration file with all possible parameters.
{
"database": {
"driver": "mysql",
"host": "localhost",
"port": "3306",
"dbname": "information_schema",
"username": "root",
"password": ""
},
"routes": {
"initialDirectory": "src/",
"index": "post"
},
"development": true,
"cache": "xcache"
}
Database connection is provided by Doctrine.
Drivers supported are pdo_mysql, pdo_sqlite, pdo_pgsql, pdo_oci,
pdo_sqlsrv, oci8.
If your project will not use any database, you can remove this parameter.
! This parameter is MANDATORY !
It tells the framework to look recursively inside initialDirectory for methods
with @Route annotation. When no pattern is given by user (as for homepage),
index informs what pattern to execute.
! This parameter is MANDATORY !
Sets the project to development mode (if true) or production mode (if false)
If you need to use a cache system, in cache parameter inform which of the
following will be used by framework:
* apc (APC)
* couchbase (Couchbase)
* file (Filesystem, saved on /cache in root)
* mem (Memcached)
* mongodb (MongoDB, not implemented yet)
* phpfile (PhpFile, saved on /cache in root)
* redis (Redis)
* riak (Riak, not implemented yet)
* wincache (WinCache)
* xcache (Xcache)
* zend (ZendData)
* none (No cache is used)
Cache is made currently based on URL. Inside the class/method you want to cache, do as follow:
/ @Route("post/create") */
public static function create()
{
Zeus\Cache::getInstance()->getCache();
// code goes here
Zeus\Cache::getInstance()->setCache();
}
Method Zeus\Cache::getInstance()->getCache() verifies if there is a valid
cache version of what user requested. If exists, prints and performs exit.
If not valid (expired ttl) or not exists, continues generating the page normaly,
then creates the cached version at Zeus\Cache::getInstance()->setCache().
If your project will not use cache, you can remove this parameter.
For testing you need to change parameter "url" in test.json providing HTTP
path to test/ folder
| File | Role | Description | ||
|---|---|---|---|---|
| Data | Auxiliary data | |||
| Data | Auxiliary data | |||
| Lic. | License text | |||
| Doc. | Documentation | |||
| / | src |
| File | Role | Description | ||
|---|---|---|---|---|
| |
Doc. | Documentation | ||
| |
Class | Class source | ||
| |
Class | Class source | ||
| |
Class | Class source | ||
| |
Class | Class source | ||
| |
Class | Class source | ||
| |
Class | Class source | ||
| / | src | / | Cache |
| File | Role | Description |
|---|---|---|
| |
Class | Class source |
| |
Class | Class source |
| / | tests |
| The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
| Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
| 100% |
|
|
| Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.