-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from ishanvyas22/readme
Update readme
- Loading branch information
Showing
1 changed file
with
54 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |