Brain-WP / Cortex

Routing system for WordPress
MIT License
348 stars 20 forks source link

Simple example not fired. #16

Closed vittore closed 8 years ago

vittore commented 8 years ago

I do this simple wp plugin file.

include __DIR__ . '/vendor/autoload.php';
function myplugin_wp_activate() {}
function myplugin_wp_deactivate(){}
register_activation_hook(__FILE__, 'myplugin_wp_activate');
register_deactivation_hook(__FILE__, 'myplugin_wp_deactivate');

use Brain\Cortex;
use Brain\Cortex\Route;

add_action('wp_loaded', function () {
    Cortex::boot();

    add_action('cortex.routes', function (Route\RouteCollectionInterface $routes) {

        $routes->addRoute(new Route\QueryRoute(
            '{code:[A-Z]+}/test',
            function (array $matches) {
                echo "here!";
                die;

                return [
                    'code' => $matches['code']
                ];
            }
        ));
    });
});

But when I try the url http://mydomain/MYCODE/test I don't get the "here!" text. Where is my mistake?

v.

vittore commented 8 years ago

Found my mistake: bad version :) With "brain/cortex": "~1.0.0@dev" into composer.json all go right. Thanks for your hard work. v.