Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Laravel News:
Bring Laravel Collections to JavaScript with Collect.js
Jun 19, 2017 @ 14:31:22

The Laravel News site has a quick post sharing an interesting Javascript library that brings the functionality of Laravel's collections over from PHP to the world of Javascript.

Collect.js is a port of Laravel Collections to JavaScript. It’s dependency free and makes working with arrays and objects easy. [...] It’s almost a one to one map with the Laravel version and it even includes the fairly new Collection Tap method.

There are some differences, however, including the requirement that all comparisons use strict equality versus the looser version PHP allows. The post includes the npm install command to get the library installed, gives a simple example of it in use and links to both the GutHub repo and the NPM page for more details.

tagged: laravel news collection collectjs functionality port library npm

Link: https://laravel-news.com/javascript-collections

SitePoint PHP Blog:
How to Use Laravel Mix in Non-Laravel Projects
May 24, 2017 @ 17:06:28

The SitePoint PHP blog has posted a new tutorial for those developers out there that like the idea of the Laravel Mix functionality for defining Webpack builds but aren't using the rest of the framework for their application.

If you, like me, just want to get up and running on a project as quickly as possible, you probably don’t want to spend time configuring build tools like Webpack. Laravel Mix solves this problem, and makes asset compiling incredibly easy, but what if you want to use it on a non-Laravel project? This article shows you how to accomplish that.

[...] Laravel Mix, formerly Elixir, could be defined as an API wrapper for Webpack. It has a fluent syntax and is generally easy to use. Setting up versioning, hot reloading, and asset building/compiling is a breeze and requires only a single configuration file and a few lines of code.

The post starts off with the requirements you'll need to create the build - besides the Mix code, naturally (NPM and Node). He includes the commands to get the required packages installed and how to create the initial Webpack "mix" file. They then add a few packages to be installed, create assets to be compiled and run the tool to perform the actual build. There's also a section about "cache busting" and, finally, setting up a local index file to test out the result. The tutorial ends with a few other helpful commands you might want to use during your development.

tagged: laravel mix webpack tutorial framework npm node example

Link: https://www.sitepoint.com/use-laravel-mix-non-laravel-projects/

DotDev.co:
Using Laravel Mix for Your WordPress Theme
May 12, 2017 @ 15:16:05

On the DotDev.co blog there's a recent tutorial posted from Eric Barnes showing you how to combine Laravel Mix and WordPress to make it easier to manage webpack dependencies.

Laravel Mix is a fluent wrapper around the webpack module bundler, and it provides common tools that help you compile CSS and JavaScript. It’s easy to work with, and although it comes baked into the Laravel framework, you can use it anywhere.

This site is using WordPress, and when I created the theme I used Mix to handle the asset compiling; it was simple to setup. Here is a quick overview of how I did it in four steps. Please note, you will need to have a recent version of Node and npm installed on your machine before continuing.

He then walks you through a four step process to set up the integration between the two:

  • Step 1. Create the package.json File
  • Step 2. Webpack Mix
  • Step 3. Create Your style.scss File
  • Step 4. Create an app.js

He ends the post with some helpful commands you can use while you're in the development process including compiling for both dev and production environments. More information about Mix can be found in the Laravel documentation.

tagged: laravel mix wordpress tutorial npm node css javascript install build

Link: https://dotdev.co/laravel-mix-wordpress/

SitePoint PHP Blog:
Flexible and Easily Maintainable Laravel + Angular Material Apps
Sep 29, 2015 @ 16:58:19

The SitePoint PHP blog has a tutorial posted showing you how to combine Laravel and AngularJS to create flexible and easily maintainable applications on both the frontend and backend of the app. He also covers a topic he says other tutorials leave out: scaling.

In this article, we’re going to set up a Laravel API with Angular Material for the front end. We’re also going to follow best practices that will help us scale with the number of developers working on the project and the complexity behind it. Most tutorials cover this topic from another perspective – they completely forget about scaling. While this tutorial is not targeted at small todo apps, it is extremely helpful if you’re planning to work with other developers on a big project.

He includes a link to the final product in action and spends the rest of the tutorial walking you through it's construction. First he sets up the Laravel application, also installing the debug bar for easier debugging. He installs gulp, bower and the "laravel-elixir-angular" package to make creating the AngularJS frontend simpler. He shows how to create the folders for the Angular application and the creation of the gulpfile.js configuration to build out the app. He uses bower to install the latest Angular, builds out the main module and connections the frontend to the backend.

From there he starts building out the actual application that outputs some basic content, generated by Angular. He hooks in some other pieces of functionality and libraries including: ui-router, Restangular, Toast and the use of dialogs. He ends with a look at deploying the application and maintaining code quality via jshint, phpcs and JSCS.

tagged: laravel application angularjs tutorial maintainable application library elixir npm gulp bower

Link: http://www.sitepoint.com/flexible-and-easily-maintainable-laravel-angular-material-apps/


Trending Topics: