Phalcon url
NOTE
All classes are prefixed with Phalcon
Url¶
-
Namespace
Phalcon\Mvc
-
Uses
Phalcon\Di\AbstractInjectionAware
Phalcon\Di\DiInterface
Phalcon\Mvc\RouterInterface
Phalcon\Mvc\Router\RouteInterface
Phalcon\Mvc\Url\Exception
Phalcon\Mvc\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",
]
);
Mvc\Url\Exception¶
-
Namespace
Phalcon\Mvc\Url
-
Uses
-
Extends
\Exception
-
Implements
Phalcon\Mvc\Url\Exception
Exceptions thrown in Phalcon\Url will use this class
Mvc\Url\UrlInterface ¶
-
Namespace
Phalcon\Mvc\Url
-
Uses
-
Extends
-
Implements
Interface for Phalcon\Mvc\Url\UrlInterface