The master branch is under active development and functionality may change or break at any time!
Getting started
Routing and controllers
Command line
Databases (SQL)
Databases (NoSQL)
Security
Packages
Learn more
- Array helper
- Caching
- Collections
- Command, event and query buses
- Date and time
- File system
- HTML helper
- Humanizer
- Image manipulation
- Internationalization
- Logging
- Number helper
- Pagination
- Retry helper
- Sessions
- String helper
- URL builder
- UUID helper
- Validation
- Views
Official packages
URL builder
The URL builder helps you build URLs for your Mako application.
Usage
The to
method will return a Mako URL to the chosen path.
// Will print http://example.org/foo/bar
$url = $urlBuilder->to('foo/bar');
// Will print http://example.org/foo/bar?key=value&key2=value2
$url = $urlBuilder->to('foo/bar', ['key1' => 'value1', 'key2' => 'value2']);
The toRoute
returns the URL of a named route.
$url = $urlBuilder->toRoute('home');
The base
method will return the base URL of your application.
$url = $urlBuilder->base();
The current
method will return the current URL of the main request.
$url = $urlBuilder->current();
The matches
method returns true
if the current URL path matches the pattern and false
if not.
// Basic URL matching
$matching = $urlBuilder->matches('/news');
// Matching is done using regular expressions so you can also use character classes
$matching = $urlBuilder->matches('/news/article/([0-9]+)');