Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

How to implement phalcon classes?

I sees many pages in the Phalcon's document said implement but none of them show how to implement.

For example: URL class.

I was extended my URL generator class in app/Extend/Phalcon/Mvc/Url.php


namespace Extend\Phalcon\Mvc;

class Url extends \Phalcon\Mvc\Url

     * Returns the prefix for all the generated urls. By default /
     * @return string
    public function getBaseUri()
        return 'hey';


Now, i want to use it properly in my controller like this. echo $this->url->getBaseUri();. But it didn't work.

So, i replaced namespace\class in app/config/services.php from use Phalcon\Mvc\Url as UrlResolver; to use Extension\Phalcon\Mvc\Url as UrlResolver;

But i'm getting this error Fatal error: Class 'Extension\Phalcon\Mvc\Url' not found



  • Fatal error: Class 'Extension\Phalcon\Mvc\Url' not found* are you sure loader it


Ok this case is my fault that i use wrong namespace. But please show me example how to implement another class (extend class or whatever) that Phalcon said in the document.

Lets begin with Tag class. The tag class can call with chaining method in controller (and view, maybe, i'm not sure).

namespace Extend\Phalcon;

class Tag extends \Phalcon\Tag

    public static function linkTo($parameters, $text=null){ 
        return 'no link';


I had already add this in app/config/services.php

$di->set('tag', function() {
    $tag = new \Extend\Phalcon\Tag();
    return $tag;
}, true);

I can call $this->tag->linkTo('somewhere', 'go to somewhere'); successfully. But i cannot call to \Phalcon\Tag::linkTo('whereever', 'some where else'); and got no link text.