
Creating URL Routing Episode 2
This article was originally published on bmf-tech.com . Overview Continuing from Creating URL Routing Episode 1 . I finished a working version and published it as a package named packagist - ahi-router . Changes from Episode 1 In Episode 1, I attempted to create routing using a tree structure for the data structure. While libraries that consider performance seem to prepare logic to generate tree structures and implement optimized search algorithms, writing the logic to generate the tree structure seemed to take too much time, so I decided to focus on just the search part. Previously, the data structure for routing definitions was defined as follows: <?php $routes = [ '/' => [ 'GET' => 'HomeController@get' , ], '/users' => [ '/' => [ 'GET' => 'UserController@get' , ], '/:user_id' => [ '/' => [ 'GET' => 'UserController@get' , 'POST' => 'UserController@post' , ], '/events' => [ '/' => [ 'GET' => 'EventController@get' , ], '/:id' => [ 'GET' => 'EventController@get' , 'POST' => 'EventContro
Continue reading on Dev.to
Opens in a new tab


