Mohd Sayeed Mohd Sayeed - 2 months ago 25
PHP Question

How can integrate gulpjs in CakePhp 2.x ?

I want to integrate gulpjs into Php Framework (CakePhp 2.x), what would be best practice to use gulp to achieve following feature in CakePhp:


  • Minification of CSS, JavaScript, and images.

  • Automatically reload the browser after change.

  • Sass Compilation

    Note: I am new in gulpjs, please suggest use cases of gulpjs in Cakephp 2.x.


Answer

install Nodejs https://nodejs.org/en/download/.

install Npm https://docs.npmjs.com/cli/install.

install gulp globally. npm install --global gulp-cli

create a package.json file in your root directory.

navigate to your project directory from terminal : npm install --save-dev gulp-install

Create a gulpfile.js at the root of your project.

var gulp = require('gulp'); gulp.task('default', function() {// place code for your default task here });

Run gulp from terminal gulp

Now you have gulp installation in your project. you can refer here https://www.npmjs.com/package/gulp-sass for saas and gulp task.

Similarly you can find minify and other plugins from http://gulpjs.com/plugins/.

There is good video tutorial to get you started.