Documentation

Class Phalcon\Mvc\Url

extends abstract class Phalcon\Di\Injectable

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

Source on GitHub

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

<?php

 //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 Phalcon\Mvc\Url setBaseUri (string $baseUri)

Sets a prefix for all the URIs to be generated

<?php

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

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

Sets a prefix for all static URLs generated

<?php

$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

<?php

$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

<?php

 //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'));
 echo $url->get(array('for' => 'blog-post', 'hostname' => true, '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

public boolean isLocal (string $uri)

Check whether the URI is local

public setDI (Phalcon\DiInterface $dependencyInjector) inherited from Phalcon\Di\Injectable

Sets the dependency injector

public Phalcon\DiInterface getDI ([unknown $error], [unknown $notUseDefault]) inherited from Phalcon\Di\Injectable

Returns the internal dependency injector

public setEventsManager (Phalcon\Events\ManagerInterface $eventsManager) inherited from Phalcon\Di\Injectable

Sets the event manager

public Phalcon\Events\ManagerInterface getEventsManager () inherited from Phalcon\Di\Injectable

Returns the internal event manager

public boolean fireEvent (string $eventName, [mixed $data], [unknown $cancelable]) inherited from Phalcon\Di\Injectable

Fires an event, implicitly calls behaviors and listeners in the events manager are notified

public mixed fireEventCancel (string $eventName, [mixed $data], [unknown $cancelable]) inherited from Phalcon\Di\Injectable

Fires an event, can stop the event by returning to the false

public boolean hasService (string $name) inherited from Phalcon\Di\Injectable

Check whether the DI contains a service by a name

public Phalcon\Di\ServiceInterface setService (unknown $name) inherited from Phalcon\Di\Injectable

Sets a service from the DI

public object|null getService (unknown $name) inherited from Phalcon\Di\Injectable

Obtains a service from the DI

public mixed getResolveService (string $name, [array $args], [unknown $noerror], [unknown $noshared]) inherited from Phalcon\Di\Injectable

Resolves the service based on its configuration

public attachEvent (string $eventType, Closure $callback) inherited from Phalcon\Di\Injectable

Attach a listener to the events

public __get (unknown $property) inherited from Phalcon\Di\Injectable

Magic method __get

public __sleep () inherited from Phalcon\Di\Injectable

...

public __debugInfo () inherited from Phalcon\Di\Injectable

...