How do I create a custom Twig extension which includes third party code?
Douglas McDonald's answer is correct with one issue though. The import statement is actually case sensitive


  Craft::import('plugins.myplugin.twigextensions.MyTwigExtension');


I also have 2 additional notes:


The getName() method is deprecated so you shouldn't bother with it
The getFilters() method can be written much shorter, for example:


public function getFilters()
{
    return [
        'myfilter' =&gt; new \Twig_Filter_Method($this, 'myfilter'),
    ];
}