0

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?

slavoo
  • 5,798
  • 64
  • 37
  • 39
valentina.a87
  • 117
  • 1
  • 3
  • 15
  • Is the file there at `/mywebsite/templates/mytemplate/config/config.less` dare I ask? – Andrejs Sep 13 '16 at 11:02
  • Hello, thank you for the answer, yes the file is in that directory and I could reach it if I copy the path in the browser url field, I don't know if could depends that I'm working on Mamp. – valentina.a87 Sep 13 '16 at 11:07
  • Just making sure: it really is at the top of your system, `/`, not at the top of your project directory, `./`? – henry Sep 13 '16 at 16:22
  • Hello, ok, I checked the code of my Joomla and I substitute with this code: echo $less->compileFile(JURI::base().'templates/'.$this->template.'/config/vikcomponent_owr.less'); With this modification I saw that the url printed on the website error has been changed with: load error: failed to find http://localhost:8888/mywebsite/templates/mytemplate/config/config.less however if I copy this exactly url in my browser url field I can see the file, I can't understand why this is happening, I think this problem depends on Joomla – valentina.a87 Sep 14 '16 at 09:27

2 Answers2

0

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!

valentina.a87
  • 117
  • 1
  • 3
  • 15
0

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');
Xavi Bonell
  • 91
  • 1
  • 9