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

SitePoint Web Blog:
PHP vs Node.js Smackdown: Right of Reply
Jul 09, 2015 @ 09:53:22

in response to the previously posted Node.js vs PHP "Smackdown" article on the SitePoint Web blog, PHP blog editor Bruno Skvorc and an author from the SitePoint Javascript channel, James Hibbard, come back with their own rebuttal to some of the points made in the previous article from a more "PHP perspective."

In SitePoint's recent PHP vs Node.js Smackdown, Craig Buckler pitted these development disciplines against each other over a series of ten challenges, to determine which is the overall winner. As Craig notes in the article, these comparisons are always somewhat controversial. As a fun followup, we asked Bruno Skvorc (SitePoint's PHP editor) and James Hibbard (one of SitePoint's JavaScript editors) to provide a commentary on each of the rounds.

For each of the rounds, they start with a summary of the related findings by Craig in the first article and share comments from both Bruno and James. With his slant towards Javascript James often agrees with what the original article stated but Bruno usually disagrees or adds comments in to clarify the PHP side of the situation (from a more insider's perspective).

tagged: smackdown nodejs language comparison reply brunoskvorc jameshibbard

Link: http://www.sitepoint.com/php-vs-node-js-smackdown-right-of-reply/

SitePoint Web Blog:
SitePoint Smackdown: PHP vs Node.js
Jul 08, 2015 @ 11:09:25

The SitePoint Web blog has posted a "smackdown" comparing two popular languages, PHP and Node.js, based on several different points.

The web is ever-changing technology landscape. Server-side developers have a bewildering choice of long-standing heavy-weights such as Java, C, and Perl to newer, web-focused languages such as Ruby, Clojure and Go. It rarely matters what you choose, presuming your application works.

But how do those new to web development make an informed choice? I hope not to start a holy war, but I’m pitting two development disciplines against each other: PHP and Node.js.

He goes through ten "rounds" of evaluations on various points including how easy it is to get started, help & support options, development tools available and hosting & deployment options. In the end, it's his opinion that the winner overall (it was close) is Node.js. However, he does end with one word of advice:

My advice: assess the options and and pick a language based on your requirements. That’s far more practical than relying on ‘vs’ articles like this!
tagged: smackdown nodejs language features comparison winner

Link: http://www.sitepoint.com/sitepoint-smackdown-php-vs-node-js/

Frank de Jonge:
Rendering ReactJS templates server-side
May 21, 2015 @ 09:17:50

Frank de Jonge has posted a tutorial to his site showing how you can render React.js templates server-side in PHP. He makes use of the V8JS extension to execute Javascript inside of PHP and echo out the rendered result.

The last couple of months I've been working with ReactJS quite extensively. It's been a very rewarding and insightful journey. There is, however, one part that kept coming back to me: server-side rendering. How on earth am I going to use ReactJS when I want to render my templates on the server? So, I sat down and looked at the possibilities.

He suggests two options, running a small Node application or using the V8JS extension, and opts for trying the second option to meet his needs. He talks about the "why" of rendering server-side JS and gives a brief introduction to V8JS and the workflow he'll follow to use it. He helps you get this library via Composer to make working with it easier and provides an example of how to use it. After trying out this method, he then goes back to option #1, the small Node application (what he ended up choosing). He walks through the setup of this application, showing how to set it up inside a Lumen application and using Express to output the generated templates and data. He then hooks this into the PHP application via a simple HTTP client grabbing the results and pushing them back out to the page.

tagged: reactjs template serverside nodejs v8js extension http lumen

Link: http://blog.frankdejonge.nl/rendering-reactjs-templates-server-side/

Gonzalo Ayuso:
PHP Dumper using Websockets
May 11, 2015 @ 08:49:21

Gonzalo Ayuso has a quick post to his site showing you how to make a "PHP dumper" for websocket connections based on a simple Silex application.

Another crazy idea. I want to dump my backend output in the browser’s console. There’re several PHP dumpers. For example Raul Fraile’s LadyBug. There’re also libraries to do exactly what I want to do, such as Chrome Logger. But I wanted to use Websockets and dump values in real time, without waiting to the end of backend script. Why? The answer is simple: Because I wanted to it.

He shows how to create a simple socket server (with Express in Javascript) and the basic Silex application with a "DumperServiceProvider" added in that will handle returning the debugging data back to the waiting client. He connects the Silex application with the websocket and shows the code to listen for new messages on the socket and display them back out to the browser. You can see an example of the end result in this video on YouTube.

tagged: websocket tutorial dumper debug output client expressjs nodejs

Link: http://gonzalo123.com/2015/05/11/php-dumper-using-websockets/

Samuel Stenton:
Install Node.Js and Ghost on a Laravel Forge Server
Dec 10, 2014 @ 09:18:08

In this recent post to his site Samuel Stenton shows you how to get Ghost (a recent player in the blogging space) and Node.js installed on a Laravel Forge server. The Laravel Forge service makes it quick and easy to create and launch virtual machines on the cloud service of your choosing.

He's broken it down into five steps (not including signing up for Forge if you haven't already):

  • Step 1: Install Node.js
  • Step 2: Download and Configure Ghost
  • Step 3: Install and Run
  • Step 3: Configure NGINX to Serve our Ghost Blog Correctly
  • Step 5: Not finished quite yet!

That final step includes the instructions to restart the needed software when/if the server happens to be rebooted.

tagged: ghost laravel forge instance cloud tutorial nodejs install configure

Link: http://samuelstenton.com/install-ghost-laravel-forge-server/

Konrad Podgórski:
A better way to work with assets in Symfony 2
Jun 25, 2014 @ 13:02:11

Konrad Podgórski has a recent post to his site with his suggestion of a better way to deal with assets in Symfony 2-based applications with the help of some other tools, namely NodeJS, Bower and GruntJS.

I will explain how to work with assets in Symfony framework without having to use Assetic Bundle at all. [...] The process will be really fast and easy to understand even if you never used software listed here. However if you experience any problems do not hesitate to ask for help in comments. Post is quite long because it contain a lot of different configs but don't run away just yet. They are ready to copy & paste.

The setup will download the needed dependencies, merge and minify JS/CSS files, copy font files to the right place and deploy it all to an S3 bucket. He first walks you through the installation of the three tools complete with the commands and configurations to get them all integrated. With those installed and working, he then gets into three "scenarios", the steps in the process to build and deploy the completed version:

  • Download latest jQuery, Bootstrap, Font Awesome with Bower and copy the only necessary files to web/assets/*
  • Download dependencies with Bower, copy necessary files to web/assets/*. Then minify javascript and stylesheet files.
  • Download dependencies with Bower, merge them with your custom css and js files, then minify.

Finally, he includes the steps you'll need to follow to get the whole thing deployed out to S3 (or a CDN). In the next part of the series he'll continue the process and look at things like LESS/SASS, watching for changes in assets and how to use RequireJs.

tagged: assets symfony2 grunt bower nodejs tutorial install configure deploy

Link: http://konradpodgorski.com/blog/2014/06/23/better-way-to-work-with-assets-in-symfony-2/

Phil Sturgeon:
Benchmarking Codswallop: NodeJS v PHP
Nov 12, 2013 @ 09:21:29

Phil Sturgeonhas posted about some Node.js vs PHP benchmarks that someone linked him to concerning web scraping. The article suggests that Node.js "owns" PHP when it comes to this but, as Phil finds out, there's a bit more to the story than that.

Sometimes people link me to articles and ask for my opinions. This one was a real doozy. Oh goody, a framework versus language post. Let's try and chew through this probable linkbait [where] we're benchmarking NodeJS v PHP. Weird, but I'll go along with it. Well, now we're testing cheerio v PhpQuery which is a bit different, but fine, let's go along with it.

Through a little discovery, Phil noticed phpQuery using file_get_contents, a blocking method for fetching the remote pages to scrape. Node.js instead uses a non-blocking method, meaning multiple files can be fetched at the same time. In answer to this blocking vs non-blocking, he decided to run benchamrks against a few cases - Node.js/Cherrio, PHP/phpQuery and his own, more correct comparison to the Node option - PHP/ReactPHP/phpQuery. He's shared his results, showing a major difference between the straight phpQuery and the React-based version.

It seems likely to me that people just assume PHP can't do this stuff, because by default most people arse around PHP with things like MAMP, or on their shitty web-host where is is hard to install things and as such get used to writing PHP without utilizing many extensions. It is probably exactly this which makes people think PHP just can't do something, when it easily can.
tagged: nodejs reactphp webpage scraping benchmark compare

Link: http://philsturgeon.co.uk/blog/2013/11/benchmarking-codswallop-nodejs-v-php

Laravel 4 and NodeJs/Redis pub/sub realtime notifications
Oct 23, 2013 @ 11:48:36

On VilkomenJuist.nl there's a recent post showing you how to create a real-time notification system with PHP using Laravel, NodeJs and Redis.

Currently I am building an application where we can fill in live scores and I needed something to update all my visitors whenever a score has been updated by one of the admins. Whenever an admin updates the score via the Laravel 4 backend I fire an event and publish it to Redis. I’ve setup a simple NodeJS server which listens to Redis for incoming changes. NodeJS will redirect the message to all Socket.IO clients.

The post has all of the code and configuration you'll need to reproduce the setup. This includes the Laravel Redis config, code for the event handler and the Node server listening for the socket connection.

tagged: redis realtime notification nodejs socketio laravel tutorial configuration

Link: http://www.volkomenjuist.nl/blog/2013/10/20/laravel-4-and-nodejsredis-pubsub-realtime-notifications/

Travis-CI: What, Why, How
Sep 19, 2013 @ 11:10:31

If you've ever wanted to put together automated builds for your project but didn't want to have to worry about all the setup and systems involved, Travis-CI might fit your needs. To help get you started NetTuts.com has posted this introduction to the (free) service and its features.

Travis CI makes working in a team for a software project easier with automated builds. These builds are triggered automatically when each developer checks in their code to the repository. In this article, we will go through how we can integrate Travis CI easily with our project, which is hosted on Github. With automation, notification and testing in place, we can focus on our coding and creating, while Travis CI does the hard work of continuous integration!

They focus on its use in a Node-based project, but Travis-CI is language agnostic, so the ideas still apply to PHP-based apps too. They introduce you to the Travis interface and show you how to hook it into your Github account. They also point out another handy feature of Travis - executing on pull requests to see if the results would break anything if merged. Plenty of screenshots are included in the post showing you different states of passing and failing builds. They also include a bit about showing the build status image in your project's README Markdown file.

tagged: travisci continuous integration introduction nodejs

Link: http://net.tutsplus.com/tutorials/tools-and-tips/travis-ci-what-why-how/

Web and PHP:
July 2013 Issue - "PHP, meet Node.js"
Jul 03, 2013 @ 09:42:54

The Web and PHP Magazine has released its latest issue - the July 2013 edition of their magazine, "PHP, meet Node.js". This new issue has several different articles in it (not just ones about Node and PHP) like:

You can pick up this issue for free by heading over to the Web and PHP site and hitting the "download" link at the bottom.

tagged: webandphp magazine july2013 nodejs article release

Link: http://webandphp.com/July2013