Skip to content

Commit

Permalink
Merge pull request #1 from ishanvyas22/readme
Browse files Browse the repository at this point in the history
Update readme
  • Loading branch information
ishanvyas22 authored Oct 28, 2019
2 parents c784550 + 0617fd6 commit 680fbab
Showing 1 changed file with 54 additions and 3 deletions.
57 changes: 54 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,62 @@
# Mix plugin for CakePHP

Provides integration with your CakePHP application & [Laravel Mix](https://laravel-mix.com).

## Installation

You can install this plugin into your CakePHP application using [composer](https://getcomposer.org).
1. Get project into your system

Via [composer](https://packagist.org/packages/ishanvyas22/asset-mix):
```bash
composer require ishanvyas22/asset-mix
```
2. Load plugin using below command:
```bash
bin/cake plugin load Mix -b
```
3. Load `Mix` helper from the plugin into your `AppView.php` file:
```php
$this->loadHelper('Mix.Mix');
```

## Usage

The recommended way to install composer packages is:
After compiling your assets(js, css) with laravel mix, it creates a `mix-manifest.json` file into your `webroot` directory which contains information to map the files.

- To generate script tag for compiled javascript file(s):

```php
echo $this->Mix->script('app');
```
composer require ishanvyas22/asset-mix

Above code will render:

```html
<script src="/js/app.js"></script>
```

As you can see it works same as [Html helper](https://book.cakephp.org/3.0/en/views/helpers/html.html#linking-to-javascript-files). There is not need to provide full path or even file extension.

- To generate style tag for compiled css file(s):

```php
echo $this->Mix->css('main');
```

Output:

```html
<link rel="stylesheet" href="/css/main.css">
```

If [versioning](https://laravel-mix.com/docs/4.0/versioning) is enabled, output will look something like below:

```html
<link rel="stylesheet" href="/css/main.css?id=9c4259d5465e35535a2a">
```

## Reference
To see this plugin into action you can refer to this [project](https://github.com/ishanvyas22/cakephpvue-spa), which will provide more insight.

## Issues
Feel free to submit issues and enhancement requests.

0 comments on commit 680fbab

Please sign in to comment.