Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mstdmstd's avatar

Is it possible to change value in _variables.scss file depending on request parameters?

Hello! If there is a way in laravel 5.7 app /blade/scssproject to change value in resources/sass/_variables.scss file depending on request parameters?

That could be usefull for debugging. Something like that:

$debug_mode: <?php echo (  !empty( $_REQUEST['is_debug'] ? 1: ''  ); ?>;

But that raise compliation errors.

That syntax

$debug_mode: "<?php echo (  !empty( $_REQUEST['is_debug'] ? 1: ''  ); ?>";

does not raise compliation errors

But it does not work as I expected in other scss file, like:

.block_container {
  min-width: 300px !important;
  padding-right: 5px;
  padding-left: 5px;
  @if ($debug_mode  == 1) {
    background-color: yellow;
    border: 2px dotted blue;
  }
}

Can it be done in some other way ?

Thanks!

0 likes
1 reply
click's avatar
click
Best Answer
Level 35

No this is impossible. First of all css files does not understand anything else than css. So PHP or HTML isn't allowed there. And the other reason is that the scss file is compiled and this is done once. So all users will be served the exact same file.

What you probably can do is add a class="{{ $conditionToDebug ? 'debug_mode' : '' }}" to your tag. Now you can make css rules like this:

.debug_mode .block_container {
    background-color: yellow;
}

// or more scss like
.block_container {
        .debug_mode & {
        background-color: yellow;
        }
}

or another option is to make a separat debug.css file and only include that file in the head if you want that to happen Eg, based on a request parameter, debug mode, etc.

Please or to participate in this conversation.