aslani/yii2-bootstrap5-rtl

Twitter Bootstrap 5 RTL extension for the Yii 2.0 framework

v1.0.2 2025-05-13 06:44 UTC

This package is not auto-updated.

Last update: 2025-06-10 07:24:36 UTC


README

This is a Yii2 AssetBundle that replaces the default Bootstrap 5 CSS file with its Right-to-Left (RTL) version.

It is useful for web applications that use RTL languages such as Persian, Arabic, Hebrew, etc.

๐Ÿ“ฆ Installation

The preferred way to install this extension is through Composer.

Run the following command:

composer require aslani/yii2-bootstrap5-rtl

Or add this line to the require section of your composer.json file:

"aslani/yii2-bootstrap5-rtl": "*"

Then run:

composer update

โš ๏ธ Make sure you have installed bower-asset/bootstrap via Composer. This package relies on that to load the RTL CSS file.

โš™๏ธ Usage

In order to use the RTL version of Bootstrap in your Yii2 application, you just need to replace the default BootstrapAsset with BootstrapRtlAsset in your AppAsset (or any other AssetBundle).

Example:

namespace app\assets;

use yii\web\AssetBundle;

class AppAsset extends AssetBundle
{
    public $basePath = '@webroot';
    public $baseUrl = '@web';

    public $css = [
        'css/site.css',
    ];

    public $js = [];

    public $depends = [
        'yii\web\YiiAsset',
        //'yii\bootstrap\BootstrapAsset', // Remove or comment this line
        'aslani\bootstrap5\BootstrapRtlAsset', // Use this instead
    ];
}

This will make sure the following file is loaded instead of the default Bootstrap CSS:

vendor/bower-asset/bootstrap/dist/css/bootstrap.rtl.min.css

๐Ÿ› ๏ธ AssetBundle Details

The class provided by this package:

aslani\bootstrap5\BootstrapRtlAsset

Loads the following CSS file:

@bower/bootstrap/dist/css/bootstrap.rtl.min.css

If you are using an alternative path or a custom version of Bootstrap RTL, you can override the $sourcePath or $css property accordingly.

๐Ÿ’ก Tips

  • You may need to manually include an RTL-compatible version of Bootstrap 5 if itโ€™s not available by default in your bower-asset/bootstrap package.
  • If you see an error related to @bower alias, add this in your Yii2 config or bootstrap file:
Yii::setAlias('@bower', dirname(__DIR__) . '/vendor/bower-asset');

๐Ÿชช License

This project is released under the BSD-3-Clause License.
See the LICENSE file for details.

๐Ÿ™‹ Support

๐Ÿง‘ Author

Mehdi Aslani
๐Ÿ“ง Email: aslani.mhd@gmail.com
๐Ÿ“ฆ Packagist: aslani/yii2-bootstrap5-rtl