Class Phalcon\Url
| Namespace | Phalcon | | Uses | Phalcon\Di\DiInterface, Phalcon\Di\AbstractInjectionAware, Phalcon\Mvc\RouterInterface, Phalcon\Mvc\Router\RouteInterface, Phalcon\Url\Exception, Phalcon\Url\UrlInterface | | Extends | AbstractInjectionAware | | Implements | UrlInterface |
This components helps in the generation of: URIs, URLs and Paths
// Generate a URL appending the URI to the base URI
echo $url->get("products/edit/1");
// Generate a URL for a predefined route
echo $url->get(
[
"for" => "blog-post",
"title" => "some-cool-stuff",
"year" => "2012",
]
);
Properties¶
/**
* @var null | string
*/
protected baseUri;
/**
* @var null | string
*/
protected basePath;
/**
* @var RouterInterface | null
*/
protected router;
/**
* @var null | string
*/
protected staticBaseUri;
Methods¶
public function get( mixed $uri = null, mixed $args = null, bool $local = null, mixed $baseUri = null ): string;
// Generate a URL appending the URI to the base URI
echo $url->get("products/edit/1");
// Generate a URL for a predefined route
echo $url->get(
[
"for" => "blog-post",
"title" => "some-cool-stuff",
"year" => "2015",
]
);
// Generate a URL with GET arguments (/show/products?id=1&name=Carrots)
echo $url->get(
"show/products",
[
"id" => 1,
"name" => "Carrots",
]
);
// Generate an absolute URL by setting the third parameter as false.
echo $url->get(
"https://phalcon.io/",
null,
false
);
// Generate a URL for a static resource
echo $url->getStatic("img/logo.png");
// Generate a URL for a static predefined route
echo $url->getStatic(
[
"for" => "logo-cdn",
]
);
Class Phalcon\Url\Exception
| Namespace | Phalcon\Url | | Extends | \Phalcon\Exception |
Phalcon\Url\Exception
Exceptions thrown in Phalcon\Url will use this class
Interface Phalcon\Url\UrlInterface
| Namespace | Phalcon\Url |
Interface for Phalcon\Url\UrlInterface