Yii2 with Foundation 6: Installation instructions

So you want to use Foundation 6 with your Yii2 project huh? Look no further. The Bootstrap (which comes with Yii2 by default) has been replaced with Foundation 6 (at least from the frontend. Replacing it in the backend is optional).

Yii2 with Foundation 6 DEMO

Note: The steps below assume you have a PHP-enabled web server up and running.

Choose a starting point:

Starting a brand new Yii2 project from scratch

  1. Download the code from github.com/foundationize/yii2 into your project root (usually 'public_html') folder.

    Note: Do not do a git clone from this repository (unless you plan to contribute to it).

  2. If you don't already have it, install composer.

    To ensure you have the latest composer settings, first run the 'composer global require ...' command as outlined here.

    In your project root (public_html) folder, run a composer install (followed by update):

    $ composer install -v
    $ composer update -v

    If composer install was successful, you should now have a 'vendor' package in your project root.

  3. Configure your webserver's setup

    See the Yii2 webserver config guide.

  4. Make sure the public_html/web/assets and public_html/runtime directories are writable by the webserver.

  5. Edit config/web.php to match your site's needs. See the Yii2 configuration docs for more info.

  6. In views/layouts/main.php, replace the Google Analytics tracking code with your own (or remove it, up to you).

  7. Finally, we highly recommend creating an index-dev.php file inside your web/ folder containing:

    defined('YII_DEBUG') or define('YII_DEBUG', true);
    defined('YII_ENV') or define('YII_ENV', 'dev');

    Exclude this file from source control (add to .gitignore / whichever ignore mechanism your VCS system uses).

Add the Foundation 6 Yii2 extension to an existing Yii2 project

  1. Include the vendor package using composer.

    Using the command line: In your project root folder, run:

    $ composer require foundationize/yii2-foundation:dev-master

    Or, in your composer.json file inside your project root folder, add "foundationize/yii2-foundation": "dev-master" to your 'require' section, example:

        "minimum-stability": "dev",
        "require": {
        "php": ">=5.4.0",
        "yiisoft/yii2": ">=2.0.5",        
        "yiisoft/yii2-swiftmailer": "*",
        "foundationize/yii2-foundation": "dev-master"

    Run composer install & update:

    $ composer install -v
    $ composer update -v
  2. Add FoundationAsset to project_root/assets/AppAsset, as follows:

    class AppAsset extends AssetBundle
        public $basePath = '@webroot';
        public $baseUrl = '@web';
        public $css = [
        public $js = [
        public $depends = [
            'foundationize\foundation\FoundationAsset', // in with the new   
            // You might want to keep bootstrap if you want to use it for backend UI

    Your project should now include Foundation 6's CSS and JavaScript.

    That's it! You should be good to go with Foundation 6 in your Yii2 project.
    You can now use Foundation classes in div's and do responsive design, Foundation-style!

    Feedback? Please contact us.