lessphp load error with file LESS

410 views Asked by At

I'm new with the lessphp library, I'm using Joomla and I'm working with a template, I'd like to compile a less file with a php file, this is way I'm using phpless, to compile my LESS file I'm using this code:

require "lessc.inc.php";
$less = new lessc;
echo $less->compileFile($this->baseurl.'/templates/'.$this->template.'/config/config.less');

but also if the url is correct I'm constantly having this error:

load error: failed to find /mywebsite/templates/mytemplate/config/config.less

What I'm missing?

2

There are 2 answers

0
valentina.a87 On

Ok, I got the problem, I wrong the joomla string, I changed in this way and now it's working:

echo $less->compileFile(JPATH_SITE.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR.$this->template.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.less');

Thank you all!

0
Xavi Bonell On

I came across the same issue but working with WordPress, since this is the better-ranked answer about the issue by Google, I'll share here the way to do it in WP:

$less->compileFile(dirname(__FILE__).'/wp-content/themes/your-theme/config.less');