Complete Guide to Laravel elixir For Beginners

Tools such as file watchers can run scripts or perform operations every time a file is modified. Additionally, IDEs such as PHPStorm will recognize file extensions and offer to watch the file for changes and allow the developer to perform certain operations. While this approach is acceptable, it is not very portable and each developer would have to create and share a configuration file with the various watchers within the IDE or text editor. This creates a dependency, relying on one single IDE for the entire team.

Also, other approaches such as Bash-shell scripts could be created that run at certain intervals. However, using these scripts requires UNIX-shell coding knowledge. As has been previously demonstrated, tools like artisan help automate many manual tasks. However, most of the default artisan commands were and are still designed to be executed manually.

Luckily, two tools that use the Node.js JavaScript platform have emerged: Grunt and gulp. Both Grunt and gulp have had a considerable amount of success, but gulp has recently become more popular. However, learning to quickly write tasks using gulp is not very easy, especially for a PHP developer who may not be familiar with JavaScript syntax.

Consider the following example code taken from the documentation of gulp:

gulp.task('scripts', ['clean'], function() {
  // Minify and copy all JavaScript (except vendor scripts)
  // with sourcemaps all the way down
  return gulp.src(paths.scripts)
    .pipe(sourcemaps.init())
      .pipe(coffee())
      .pipe(uglify())
      .pipe(concat('all.min.js'))
    .pipe(sourcemaps.write())
    .pipe(gulp.dest('build/js'));
});

About the author

Deven Rathore

I'm Deven Rathore, a multidisciplinary & self-taught designer with 3 years of experience. I'm passionate about technology, music, coffee, traveling and everything visually stimulating. Constantly learning and experiencing new things.

Pin It on Pinterest

Shares