0

This might be a dummy question now but bevertheless giving it a try: I am just trying to setup scssphp in my cakephp 4 but seem to have a knot in my head. Can anymone shed some light on what I need to do to get it running?

My simple idea was to just include the code below into the app controller initialize function

<?php
require "scssphp/scss.inc.php";
$scss = new scssc();
$scss->setImportPaths("stylesheets/");

// will search for `stylesheets/style.scss'
echo $scss->compile('@import "style.scss"');

And I create the "scssphp" folder structure with the "scss.inc.php" right under webroot:

  • webroot/scssphp/scss.inc.php
  • webroot/scssphp/style.php
  • webroot/scssphp/stylesheets/style.scss

But then I get

Warning (2): require(/scssphp/scss.inc.php): failed to open stream: No such file or directory [APP/Controller/AppController.php, line 84]
Warning (2): require(/scssphp/scss.inc.php) [<a href='https://secure.php.net/function.require'>function.require</a>]: failed to open stream: No such file or directory [APP/Controller/AppController.php, line 84]
Fatal error: require() [function.require]: Failed opening required '/scssphp/scss.inc.php' (include_path='.:/usr/local/lib/php') in /somepath/myapp.com/dev/src/Controller/AppController.php on line 84

Any help is greatly appreciated!

Update: this article describes how to include external classes quite well and helped me in a first step to solve the issue describe above: How can I use my own external class in CakePHP 3.0?

wild-old
  • 46
  • 4
  • It seems that your code searches in folder `/usr/local/lib/php` for the file `scssphp/scss.inc.php`, instead of in folder `path/to/project-root/webroot`. For the moment, use something like `__DIR__ . 'relative-path/to/controller-file/webroot/scssphp/scss.inc.php'`, with `__DIR__` pointing to parent folder of controller file. – PajuranCodes May 14 '21 at 18:05
  • Thanks dakis, that seems to have helped with finding the file. However, now I run into the next problem and get a Class 'App\Controller\scssc' not found error. – wild-old May 15 '21 at 06:57

0 Answers0