All Projects → ishanvyas22 → asset-mix

ishanvyas22 / asset-mix

Licence: MIT license
Provides helpers functions for CakePHP to use Laravel Mix.

Programming Languages

PHP
23972 projects - #3 most used programming language
javascript
184084 projects - #8 most used programming language
SCSS
7915 projects
Vue
7211 projects

Projects that are alternatives of or similar to asset-mix

Cakephp Jwt Auth
A CakePHP plugin for authenticating using JSON Web Tokens
Stars: ✭ 153 (+466.67%)
Mutual labels:  cakephp, cakephp-plugin
cakephp-error-email
ErrorEmail Plugin for CakePHP3.x
Stars: ✭ 16 (-40.74%)
Mutual labels:  cakephp, cakephp-plugin
Cakephp Csvview
CakePHP: A view class for generating CSV
Stars: ✭ 174 (+544.44%)
Mutual labels:  cakephp, cakephp-plugin
Orderly
Default ordering for your CakePHP tables
Stars: ✭ 21 (-22.22%)
Mutual labels:  cakephp, cakephp-plugin
cakephp-i18n
A CakePHP plugin with I18n related tools.
Stars: ✭ 40 (+48.15%)
Mutual labels:  cakephp, cakephp-plugin
Cakephp Imagine Plugin
CakePHP wrapper for the powerful Imagine image processing library. Makes images manipulation easy and powerful.
Stars: ✭ 140 (+418.52%)
Mutual labels:  cakephp, cakephp-plugin
cakephp-feed
CakePHP Plugin with RssView to create RSS feeds.
Stars: ✭ 13 (-51.85%)
Mutual labels:  cakephp, cakephp-plugin
Cakephp Tinyauth
CakePHP TinyAuth plugin for an easy and fast user authentication and authorization. Single or multi role. DB or config file based.
Stars: ✭ 114 (+322.22%)
Mutual labels:  cakephp, cakephp-plugin
cakephp-ajax
AJAX for CakePHP: A plugin to ease handling AJAX requests.
Stars: ✭ 55 (+103.7%)
Mutual labels:  cakephp, cakephp-plugin
cakephp-shim
CakePHP plugin to "shim" functionality up and down for major versions of the framework.
Stars: ✭ 37 (+37.04%)
Mutual labels:  cakephp, cakephp-plugin
Cakephp Ide Helper
IDE Helper plugin for CakePHP
Stars: ✭ 138 (+411.11%)
Mutual labels:  cakephp, cakephp-plugin
cakephp-translate
A CakePHP plugin to manage translations of your static content the easy way via web backend.
Stars: ✭ 18 (-33.33%)
Mutual labels:  cakephp, cakephp-plugin
Cakephp Proffer
An upload plugin for CakePHP 3
Stars: ✭ 121 (+348.15%)
Mutual labels:  cakephp, cakephp-plugin
Search
CakePHP: Easy model searching
Stars: ✭ 153 (+466.67%)
Mutual labels:  cakephp, cakephp-plugin
Migrations
CakePHP database migrations plugin
Stars: ✭ 114 (+322.22%)
Mutual labels:  cakephp, cakephp-plugin
auth
Auth objects for CakePHP
Stars: ✭ 28 (+3.7%)
Mutual labels:  cakephp, cakephp-plugin
Cakephp Hybridauth
CakePHP plugin for HybridAuth
Stars: ✭ 81 (+200%)
Mutual labels:  cakephp, cakephp-plugin
Acl
Plugin for managing ACL in CakePHP applications.
Stars: ✭ 113 (+318.52%)
Mutual labels:  cakephp, cakephp-plugin
plum search
Plum Search plugin for CakePHP
Stars: ✭ 20 (-25.93%)
Mutual labels:  cakephp, cakephp-plugin
cakephp-swagger-bake
Automatically generate OpenAPI, Swagger, and Redoc documentation from your existing CakePHP code.
Stars: ✭ 48 (+77.78%)
Mutual labels:  cakephp, cakephp-plugin

AssetMix plugin for CakePHP

Latest Stable Version Total Downloads License CakePHP Tests PHPStan Check Coding Style Check

Provides integration with your CakePHP application & Laravel Mix.

This branch works with CakePHP 4.0+, see version map for more details.

❤️ Support The Development

Do you like this project? Support it by donating:

Buy Me A Coffee

or Paypal me

or Contact me on Codementor

Follow me

Installation

  1. Install the AssetMix plugin with composer:

    Via composer:

    composer require ishanvyas22/asset-mix
  2. Load plugin using below command:

    bin/cake plugin load AssetMix
  3. Generate basic Javascript, CSS & Sass scaffolding:

    bin/cake asset_mix generate

    Note: Above command will generate scaffolding for vue, but you can generate Bootstrap/jQuery, React or Inertia scaffolding too.

  4. Install frontend dependencies

    npm install

    or

    yarn install
  5. Compile your assets

    • For development:
    npm run dev
    • To watch changes:
    npm run watch
    • For production:
    npm run prod
  6. Load AssetMix helper from the plugin into your AppView.php file:

    $this->loadHelper('AssetMix.AssetMix');

Usage

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):
echo $this->AssetMix->script('app');

Above code will render:

<script src="/js/app.js" defer="defer"></script>

As you can see it works same as HtmlHelper. There is not need to provide full path or even file extension.

  • To generate style tag for compiled css file(s):
echo $this->AssetMix->css('main');

Output:

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

If versioning is enabled, output will look something like below:

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

Generate command

The generate command is used to generate starter code for your Javascript application to get you started developing your frontend.

Get help:

bin/cake asset_mix -h

Generate default scaffolding (with vue):

bin/cake asset_mix generate

Above command will generate:

  • package.json
  • webpack.mix.js
  • assets/
    • css/
    • js/
    • sass/

assets/ directory is where you will store your js, css files which will compile down into your respective webroot/ directory.

Custom directory name:

bin/cake asset_mix generate --dir=resources

You can also use custom directory name instead of default assets directory, above command will create resources directory where you can put your js, css, etc asset files.

Don't want to use Vue.js? Don't worry this plugin doesn't dictate on which Javascript library you should use. This plugin provides ability to quickly generate scaffolding for Vue as well as Bootstrap, and React.

Generate basic Bootstrap/jQuery scaffolding:

bin/cake asset_mix generate bootstrap

Generate React scaffolding:

bin/cake asset_mix generate react

Generate scaffolding for Inertia.js:

# for vue
bin/cake asset_mix generate inertia-vue

# or for react
bin/cake asset_mix generate inertia-react

Generate React scaffolding inside resources directory:

bin/cake asset_mix generate react --dir=resources

Version map

AssetMix version Branch CakePHP version PHP minimum version
1.x master >=4.0.0 >=7.2
0.x cake3 >=3.5.0 >=5.6

Changelog

Please see CHANGELOG for more information about recent changes.

Reference

To see this plugin into action you can refer to this project, which will provide more insight.

License

The MIT License (MIT). Please see License File for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].