Routing
Public Dir
Files in the public
dir of your package will be automatically routed to.
-
public/index.php
Delivers at/
. index.php files will be delivered without the file name or extension -
public/dir/file.php
files will be delivered at/dir/file/
-
public/resource.js
and other non.php
files will be delivered at/resource.ext
Route Patterns
The patterns apply both for the public
dir and by adding routes via $lia->addRoute()
. The file extension (for .php) is removed prior to calling parsePattern()
Examples:
- /blog/{category}/{post} is valid for url /blog/black-lives/matter
- /blog/{category}.{post}/ is valid for url /blog/environment.zero-waste/
- /blog/{category}{post}/ is valid for url /blog/{category}{post}/ and has NO dynamic paramaters
- /blog/{category}/@GET.{post}/ is valid for GET /blog/kindness/is-awesome/ but not for POST request
- /@POST.dir/sub/@GET.file/ is valid for both POST /dir/sub/file/ and GET /dir/sub/file/
Methods: @POST, @GET, @PUT, @DELETE, @OPTIONS, @TRACE, @HEAD, @CONNECT
- We do not currently check the name of the method, just @ABCDEF for length 3-7
- These must appear after a
/
or after another '@METHOD.' or they will be taken literally - lower case is not valid
- Each method MUST be followed by a period (.)
Paramaters:
- {under_scoreCamel} specifies a named, dynamic paramater
- {param} must be surrounded by path delimiters (/) OR periods (.) which will be literal characters in the url
- {param} MAY be at the end of a pattern with no trailing delimiter
TODO
- {paramName:regex} would specify a dynamic portion of a url that MUST match the given regex.
- Not currently implemented
- {?param} would specify a paramater that is optional
- Not currently implemented