new
: passing controller's properties to rules
<?php
ways::rule('is-admin-section', function($data, $args, $props){
var_dump($props);
return $args['section'] === 'admin';
});
release
: version 2.4.1
new
: passing data and args to rules
<?php
ways::rule('is-admin-section', function($data, $args){
return $args['section'] === 'admin';
});
ways::listen("/{section}/login", function(){
echo "admin login";
}, ['rules' => ['is-admin-section']]);
release
: version 2.4.0
fix
: rules for default action Runrelease
: version 2.3.4
fix
: fix flow of the data before bootstrap and invokerelease
: version 2.3.3
fix
: bug fix in rulesrelease
: version 2.3.2
fix
. Fix lost data resulting from "file control points"fix
. Other fixes for nested calls of control pointsfix
. Other minor fixesrelease
. Urgent release 2.3.1!
fix
: fix nested calls of control pointsfix
: check if exists methods, before execute an actionimprovement
: The * pattern is now for all protocols.
<?php
ways::listen("*", function($data){
$data['track'] = 1;
return $data;
});
ways::listen("app://config", function(){
$data['config'] = [1,2,3];
return $data;
});
$config = ways::invoke("app://config");
echo json_encode($config); // {"track":1,"config":[1,2,3]}
improvement
: Independent "ways" for invocations: The execution of the PHP script (CLI or HTTP) have a main "request id" or "thread id", that is named WAY ID. Then each ways::invoke() have their own way id.
<?php
ways::listen("app://config", function(){
$data['config'] = [1,2,3];
return $data;
});
$config = ways::invoke("app://config");
echo json_encode($config); // {"track":1,"config":[1,2,3]}
// the second call did not work in 2.2.0 version
$config = ways::invoke("app://config");
echo json_encode($config); // {"track":1,"config":[1,2,3]}
- Release 2.3.0 version
- Support namespaces! Now
divengine\ways
detect namespace instruction.
<?php
namespace MyApp;
#listen = /
class MyController {
static function Run() {
echo "Hello universe";
}
}
- Adding rules!
ways::rule('some-rule', function() {return true or false;});
ways::listen("/secret", function() {...}, [
ways::PROPERTY_RULES => [
'some-rule',
function () {
return true; // another rule
}
]
]);
- Structural changes:
divengine
namespace andways
classname
- IMPORTAN bugfix! As in divengine\ways, as you are executing, more control points can be loaded depending on the flow that you have designed for the user's actions, since the list of control points is possibly a "list that is dynamically increasing".
Solution: Fix divengine\ways::callAll()
method adding & before item foreach
foreach (self::$__listen as $pattern => &$methods) { ... }
Now the expected behavior must happen
- New method
divengine\ways::invoke($way, $data)
<?php
$entry = divengine\ways::invoke('model://entries/1', [
'filter' => 'monkey island'
]);
- new constant for default GET variable of way information: DIV_WAYS_DEFAULT_WAY_VAR
- more flexibility of ::match ::getCurrentWay
- new methods for ::setDefaultWay and ::setWayVar
- listen ways from CLI !!
- hook on the fly! ::listen() return the ID of closure
- release 1.3 version
- fix merge of hook data resulting
- Use $_SERVER['REQUEST_URI'] if any way is detected via GET vars. This improvement allow the use of built-in PHP web server in development environment.
index.php
<?php
include "divengine\ways.php"
divengine\ways::listen("/my/way", function($data, $args) {
echo "Hello world";
});
divengine\ways::bootstrap('_url'); // $_GET['_url'] is missing, then assume $_GET['_url'] = $_SERVER['REQUEST_URI']
cli
$ php -S localhost:9090
web-browser
http://localhost:9090/my/way
- allow listen by method in controller registration
Blog.php
<?php
#id = blog
#listen = /feed
#listen@Entry = /blog/{entry}
#listen@Post = post://blog/post
class Blog {
static function Run($data = [], $args = [])
{
echo "This is the feed";
return $data;
}
static function Entry($data = [], $args = [])
{
echo "This is the entry {$args['entry']}";
return $data;
}
static function Post($data = [], $args = [])
{
echo "Posting a blog entry ...";
return $data;
}
}
bootstrap.php
<?php
include "divengine\ways.php";
divengine\ways::register("control/Blog.php");
- New method divengine\ways::redirect($way)
- important bugfix when normalize the ways
- fix match method and more complexity
<?php
// documentation/chapter-1
divengine\ways::listen("documentation/chapter-{id|is_int}", function($data, $args){
echo "Chapter #{$args['id']}";
});
- better control of the ways (executing single instance of each controller)
- improvement example
- release 1.2
- better match method
- argument checker
<?php
divengine\ways::listen("blog/{id:is_int}", function($data, $args){
echo "{$args['id']} is integer";
});
- improvement example
- drop the obsolete bulkRegister
- improvement/fix match() method
- capture URL arguments
<?php
divengine\ways::listen("blog/{id}", function($data, $args){
echo "Entry #{$args['id']}";
});
- release 1.1 version