Class Phalcon\Mvc\Url

implements Phalcon\Mvc\UrlInterface, Phalcon\Di\InjectionAwareInterface

This components aids in the generation of: URIs, URLs and Paths

  1. <?php
  2. //Generate a URL appending the URI to the base URI
  3. echo $url->get('products/edit/1');
  4. //Generate a URL for a predefined route
  5. echo $url->get(array('for' => 'blog-post', 'title' => 'some-cool-stuff', 'year' => '2012'));

Methods

public setDI (unknown $dependencyInjector)

Sets the DependencyInjector container

public Phalcon\DiInterface getDI ()

Returns the DependencyInjector container

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

Sets a prefix for all the URIs to be generated

  1. <?php
  2. $url->setBaseUri('/invo/');
  3. $url->setBaseUri('/invo/index.php/');

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

Sets a prefix for all static URLs generated

  1. <?php
  2. $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 (unknown $basePath)

Sets a base path for all the generated paths

  1. <?php
  2. $url->setBasePath('/var/www/htdocs/');

public string getBasePath ()

Returns the base path

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

Generates a URL

  1. <?php
  2. //Generate a URL appending the URI to the base URI
  3. echo $url->get('products/edit/1');
  4. //Generate a URL for a predefined route
  5. echo $url->get(array('for' => 'blog-post', 'title' => 'some-cool-stuff', 'year' => '2012'));

public string getStatic ([unknown $uri])

Generates a URL for a static resource

public string path ([unknown $path])

Generates a local path