2017 © Pedro Peláez
 

library yii2-scssphp

Yii2 bindings for leafo/scssphp

image

lucidtaz/yii2-scssphp

Yii2 bindings for leafo/scssphp

  • Wednesday, July 18, 2018
  • by LucidTaZ
  • Repository
  • 1 Watchers
  • 1 Stars
  • 325 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 1 Open issues
  • 8 Versions
  • 29 % Grown

The README.md

Build Status Scrutinizer Code Quality Code Coverage, (*1)

Yii2 bindings for SCSS-PHP

This library provides easy integration of scssPhp/scssphp into Yii2. Scssphp is a native PHP SCSS (SASS) compiler. This enables you to seamlessly use SCSS while using Yii's method of asset publication., (*2)

Usage

Configure web.php to disable Yii's built-in asset converter and use the new one:, (*3)

<?php

$config = [
    // Other configuration...

    'components' => [
        'assetManager' => [
            'converter' => 'lucidtaz\yii2scssphp\ScssAssetConverter',
        ],

        // Other components...
    ],

    // Other configuration...
];

If the AppAsset is placed in /assets and the scss file in /assets/source/site.scss, your AppAsset.php could look like:, (*4)

<?php

namespace app\assets;

use yii\web\AssetBundle;

class AppAsset extends AssetBundle
{
    public $sourcePath = '@app/assets/source';
    public $css = [
        'site.scss',
    ];
    public $depends = [
        'yii\web\YiiAsset',
        'yii\bootstrap\BootstrapAsset',
    ];
}

In other words; you can just use the .scss file(s) in the $css array., (*5)

Customizing the SCSS parser

The underlying library, yii2-scssphp, can be customized in case more flexibility is needed. To this end, properties of the ScssPhp\ScssPhp\Compiler object can be overridden in the DI container, as follows:, (*6)

<?php

$config = [
    // Other configuration...

    'components' => [
        'assetManager' => [
            'converter' => 'lucidtaz\yii2scssphp\ScssAssetConverter',
        ],

        // Other components...
    ],
    'container' => [
        'definitions' => [
            \ScssPhp\ScssPhp\Compiler::class => function () {
                // You can also use a child class here:
                $compiler = new \ScssPhp\ScssPhp\Compiler();
                $compiler->setOutputStyle(\ScssPhp\ScssPhp\OutputStyle::COMPRESSED);

                return $compiler;
            }
        ],
    ],

    // Other configuration...
];

This usage in config.php is supported from Yii 2.0.11. Before that you should use the DI container directly. In that case, please refer to the Yii Dependency Injection readme., (*7)

Contributing

When contributing code, please make sure the tests keep passing. Additionally the code is checked by phpstan to detect any statically analyzable issues., (*8)

To run these checks, simply execute composer ci., (*9)

That being said, please do not hesitate to contribute when the tests fail. If you need assistance in making the build green for your pull request, just let me know in the PR., (*10)

The Versions

18/07 2018

dev-master

9999999-dev

Yii2 bindings for leafo/scssphp

  Sources   Download

MIT

The Requires

 

The Development Requires

by Thijs Zumbrink

22/04 2018

0.2.1

0.2.1.0

Yii2 bindings for leafo/scssphp

  Sources   Download

MIT

The Requires

 

The Development Requires

by Thijs Zumbrink

22/04 2018

dev-feature/extensibility

dev-feature/extensibility

Yii2 bindings for leafo/scssphp

  Sources   Download

MIT

The Requires

 

The Development Requires

by Thijs Zumbrink

21/04 2018

0.2.0

0.2.0.0

Yii2 bindings for leafo/scssphp

  Sources   Download

MIT

The Requires

 

The Development Requires

by Thijs Zumbrink

14/01 2018

dev-integration-test

dev-integration-test

Yii2 bindings for leafo/scssphp

  Sources   Download

MIT

The Requires

 

The Development Requires

by Thijs Zumbrink

18/07 2017

0.1.2

0.1.2.0

Yii2 bindings for leafo/scssphp

  Sources   Download

MIT

The Requires

 

The Development Requires

by Thijs Zumbrink

29/09 2016

0.1.1

0.1.1.0

Yii2 bindings for leafo/scssphp

  Sources   Download

MIT

The Requires

 

The Development Requires

by Thijs Zumbrink

29/04 2016

0.1.0

0.1.0.0

Yii2 bindings for leafo/scssphp

  Sources   Download

MIT

The Requires

 

The Development Requires

by Thijs Zumbrink