url
The url service provider will let you traverse the URI Path.
Start with take a look at the router example bellow:
The router pattern above expects 3 path arguments.
page: expects string that matches "blog"
slug: expects any string value
id: expects any number
The Url provider will make it easy for you to extract the URI path value.
Get URI
The examples bellow will use the router above and the URI value: https://example.com/blog/my-post/10
Get full URL
Result: https://example.com/blog/my-post/10
Get full Root URL
Result: https://example.com
Get full URI Path
Result: /blog/my-post/10
Get current URI Path
The get method will return the current, e.g. the last URI path item.
Result: 10
Get URI path as array
Result: ["blog", "my-post", 10]
Get URI parts
Result: ["page" => ["blog"], "slug" => ["my-post"], "id" => [10]]
Travers the URI Path
You can Utilize the select
method and combine it with one of the get method above in the method list.
Get current path
By utilizing the get
method you can extract the current URI Path, the current path will count as the last value .
Result: my-post
Result: /blog/10
Result: https://example.com/blog/my-post
Get URL directories
Get full URL to public directory
Result: https://example.com/public/
Get full URL to public directory
Result: https://example.com/resources/
Get full URL to public directory
Result: https://example.com/resources/js/main.js
Result: https://example.com/public/js/main.js
Get full URL to JavaScript directory
Result: https://example.com/resources/
Get full URL to CSS directory
Result: https://example.com/public/css/style.css
Get full URL to public directory
Result: https://example.com/resources/
Last updated