mosaxiv/cakephp-mix

Helper to use laravel-mix with CakePHP3

Installs: 3 119

Dependents: 0

Suggesters: 0

Security: 0

Stars: 5

Watchers: 2

Forks: 2

Open Issues: 0

Type:cakephp-plugin

v0.0.3 2018-08-07 14:07 UTC

This package is auto-updated.

Last update: 2024-04-15 04:58:24 UTC


README

Helper to use laravel-mix with CakePHP3.

This is similar to the mix() function of Laravel.

MIT License

Requirements

  • PHP 7.0+
  • CakePHP 3.4+

Installation

You can install this plugin into your CakePHP application using composer.

The recommended way to install composer packages is:

composer require mosaxiv/cakephp-mix

Usage

AppView Setup

load Helper

// src/View/AppView.php

namespace App\View;

use Cake\View\View;

class AppView extends View
{
    public function initialize()
    {
        $this->loadHelper('CakeMix.Mix');
    }
}

Helper Usage

load script

// /js/app.js
$this->Mix->script('app');

// <script src="/js/app.js"></script>
$this->Mix->htmlScript('app');

load css

// /css/app.css
$this->Mix->css('app');

// <script src="/css/app.css"></script>
$this->Mix->htmlCss('app');

TIPS

By using create-laravel-mix you can build environment fast.

Exsample:

npx create-laravel-mix react --public-dir webroot