letsdrink / ouzo

Ouzo Framework - PHP MVC ORM
https://github.com/letsdrink/ouzo
MIT License
70 stars 8 forks source link

Improve performance of routes #210

Open bbankowski opened 9 years ago

bbankowski commented 9 years ago

e.g.

woru commented 9 years ago

Remove except option from allowAll() (which should also be removed) - one less regexp. Remove allowAll() from docs.

Replace regexps with strstr() where possible. If route does not contain parameters just check if ($this->getUri() == $uri)

woru commented 8 years ago

maybe Route::group() should really group route rules and evaluate them only if the prefix matches. That way we could group routes in our app and have less rules to evaluate.

woru commented 8 years ago

We should definitely implement Route::group() and Route::resource() as aggregates. I replaced one allowAll with 7 routes in panel. If we removed all allowAlls we would have roughly 29x7 more routes in panel.

woru commented 8 years ago

change routes parsing to prefix tree. console ouzo:routes -g should generate a file with a prefix tree.

/customers /customers/add /customers/add/comment /customers/search /customers/:id /customers/:id/add_product/:prod_id

$a = [
    'GET' => [
        'customers' => [
            '/' => 'customers#index',
            'add' => [
                '/' => 'customers#add',
                'comment' => 'customers#add_comment'
            ],
            'search' => 'customer_searches#search',
            ':param' => [
                'name' => 'id',
                'children' => [
                    '/' => 'customers#show',
                    'add_product' => [
                        ':param' => [
                            'name' => 'prod_id',
                            'children' => [
                                '/' => 'customer_products#add'
                            ]
                        ]
                    ]
                ]
            ]
        ]
    ]
];
woru commented 7 years ago

https://github.com/letsdrink/ouzo/commit/3804d41f097db57f6f587f932ef6a1fb431219a9