Recommend this page to a friend! |
Download .zip |
Info | Documentation | View files (22) | Download .zip | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2021-10-02 (14 days ago) | Not yet rated by the users | Total: 27 This week: 1 | All time: 10,328 This week: 189 |
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
Files |
File | Role | Description | ||
---|---|---|---|---|
src (7 files, 3 directories) | ||||
tests (5 files, 1 directory) | ||||
apigen.neon | Data | Auxiliary data | ||
composer.json | Data | Auxiliary data | ||
LICENSE | Lic. | License text | ||
README.md | Doc. | Documentation |
Files | / | src |
File | Role | Description | ||
---|---|---|---|---|
Annotations (1 file) | ||||
Cache (2 files) | ||||
Common (1 file) | ||||
404.html | Doc. | Documentation | ||
Cache.php | Class | Class source | ||
Configuration.php | Class | Class source | ||
Database.php | Class | Class source | ||
Entity.php | Class | Class source | ||
Framework.php | Class | Class source | ||
Routes.php | Class | Class source |
Files | / | src | / | Cache |
File | Role | Description |
---|---|---|
CacheTime.php | Class | Class source |
Dummy.php | Class | Class source |
Files | / | tests |
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.