Raven Framework is a High-Performance PHP framework with expressive, elegant syntax. Designed to be fast, easy to use (and learn) and highly scalable.
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
1. Download the files. It's recommended that you use git to install Raven.
$ git clone [email protected]:danccas/Raven.git
This will install Raven, requires PHP 7.1 or newer.
2. Configure your webserver.
For Apache, edit your .htaccess
file with the following:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
Note: If you need to use Raven in a subdirectory add the line RewriteBase /subdir/
just after RewriteEngine On
.
For Nginx, add the following to your server declaration:
server {
location / {
try_files $uri $uri/ /index.php;
}
}
- Web Applications using MVC pattern
- Routing system and basic Middleware support. (PHP-Router)
- Basic Logger
- Request Validation
- Html/Form Builder
- and more...
- PHP >= 7.1
- OpenSSL PHP Extension
- PDO PHP Extension
- JSON PHP Extension
Routing in Raven is done by matching a URL pattern with a callback function.
Route::any('/', function(){
echo 'hello world!';
});
The callback can be any object that is callable. So you can use a regular function:
function hello(){
echo 'hello world!';
}
Route::any('/', 'hello');
Or a class method:
class Awakening {
public static function hello() {
echo 'hello world!';
}
}
Route::any('/', array('Awakening', 'hello'));
Or an object method:
class Awakening
{
public function __construct() {
$this->name = 'John Doe';
}
public function hello() {
echo "Hello, {$this->name}!";
}
}
$Awakening = new Awakening();
Route::any('/', array($Awakening, 'hello'));
Routes are matched in the order they are defined. The first route to match a request will be invoked.
By default, route patterns are matched against all request methods. You can respond to specific methods by placing an identifier before the URL.
Route::get('/', function(){
echo 'I received a GET request.';
});
Route::post('/', function(){
echo 'I received a POST request.';
});
You can also map multiple methods to a single callback by using a |
delimiter:
Route::any('/', function(){
echo 'I received either any request.';
});
You can use regular expressions in your routes:
Route::any('/user/:id', array('id' => '[0-9]+'), function(){
// This will match /user/1234
});
You can specify named parameters in your routes which will be passed along to your callback function.
Route::any('/:name/:id', array('name' => '[\w]+', 'id' => '[0-9]+'), function(){
echo "hello, {$this->route['name']} ({$this->route['id']})!";
});
You can specify named parameters that are optional for matching by wrapping segments in parentheses.
Route::any('/blog(/:year(/:month(/:day)?)?)?', function(){
// $this->route
// This will match the following URLS:
// /blog/2012/12/10
// /blog/2012/12
// /blog/2012
// /blog
});
Any optional parameters that are not matched will be passed in as NULL.
Matching is only done on individual URL segments. If you want to match multiple
segments you can use the *
wildcard.
Route::path('/blog/', function(){
// This will match /blog/2000/02/01
});
Route allows you to override its default functionality to suit your own needs, without having to modify any code.
For example, when Route cannot match a URL to a route, it invokes the notFound
method which sends a generic HTTP 404
response. You can override this behavior
by using the else
method:
Route::else(function(){
// Display custom 404 page
Route::view('errors/404.html');
});
Instead of running Route as a global static class, you can optionally run it as an object instance.
require 'core/route.php';
$app = Route::g()->init();
$app->any('/', function(){
echo 'hello world!';
});
So instead of calling the static method, you would call the instance method with the same name on the Engine object.