W3cubDocs

/Phalcon 2

Class Phalcon\Mvc\Url

implements Phalcon\Mvc\UrlInterface, Phalcon\DI\InjectionAwareInterface

This components aids 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(array('for' => 'blog-post', 'title' => 'some-cool-stuff', 'year' => '2012'));

Methods

public setDI (Phalcon\DiInterface $dependencyInjector)

Sets the DependencyInjector container

public Phalcon\DiInterface getDI ()

Returns the DependencyInjector container

public Phalcon\Mvc\Url setBaseUri (string $baseUri)

Sets a prefix for all the URIs to be generated

$url->setBaseUri('/invo/');
$url->setBaseUri('/invo/index.php/');

public Phalcon\Mvc\Url setStaticBaseUri (string $staticBaseUri)

Sets a prefix for all static URLs generated

$url->setStaticBaseUri('/invo/');

public string getBaseUri ()

Returns the prefix for all the generated urls. By default /

public string getStaticBaseUri ()

Returns the prefix for all the generated static urls. By default /

public Phalcon\Mvc\Url setBasePath (string $basePath)

Sets a base path for all the generated paths

$url->setBasePath('/var/www/htdocs/');

public string getBasePath ()

Returns the base path

public string get ([string|array $uri], [unknown $args], [bool|null $local])

Generates a URL

//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(array('for' => 'blog-post', 'title' => 'some-cool-stuff', 'year' => '2012'));

public string getStatic ([string|array $uri])

Generates a URL for a static resource

public string path ([string $path])

Generates a local path

© 2011–2016 Phalcon Framework Team
Licensed under the Creative Commons Attribution License 3.0.
https://docs.phalconphp.com/en/2.0.0/api/Phalcon_Mvc_Url.html