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

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/

Stoyan Stefanov:
Server-side React with PHP – part 2
Sep 19, 2013 @ 09:35:38

In a a previous post Stoyan Stefanov introduced a setup where you could render React templates on the server-side with the help of PHP and the v8 parsing. In this second part of the series, he extends that system and shows how to use it to update views based on new data.

Part 1 ended with todos. The first one was to couple the server-side generated code with the client-side React, so that any updates past the initial page load will be handled by React's client JS, which is where React shines. Let's see how you can do just that.

He gives an example similar to his previous one - displaying a table - but shows how to inject some values from PHP as a JSON string into the component. This time he saves the output of that rendering into a variable and reuses it as a part of a whole site render later.

tagged: react javascript js v8 serverside render tutorial data

Link: http://www.phpied.com/server-side-react-with-php-part-2/

PHPMaster.com:
Server-Side Device Detection with Browscap
Jul 25, 2013 @ 13:09:12

In a new tutorial posted to PHPMaster.com today, Lukas White talks about using the Browscap functionality to do server-side device/client detection in your applications.

An alternative solution to the problem is to use server-side device detection and then take certain actions based on that information. One possibility is to simply forward requests for a mobile site to a different URL. Another possibility is to adapt the layout – or indeed content – programmatically as it’s generated on the server. Taking a server-side approach is the basis of this article, which looks in detail at the Browser Capabilities Project, or Browscap for short, to provide the information on which to base these decisions.

He starts with some of the basics - User-Agent strings that most devices will send to your site and their structure. He then talks about the Browscap project and the PHP support for its use. He shows how to get it all installed via Composer and how to use the "browscap-php" library to get the current browser information. He includes an example of the output and shows how to use this to redirect the user to a mobile site if needed. He also adds in a bit at the end about using it for layout switching or for showing the user the correct download links based on their client.

tagged: serverside useragent browscap tutorial detection

Link: http://phpmaster.com/server-side-device-detection-with-browscap

L2Admin.com:
Battle of the server side scripting languages - Perl, Python & PHP
Jul 21, 2010 @ 08:34:20

New on the L2Admin.com site today is the first part of a series they're doing comparing three of the popular server-side scripting languages for web development - PHP, Perl and Python - and what benefits each can give.

For a very long time I have wondered if there were any real benefits between Perl, PHP or Python from a performance standpoint [...] So after much wondering I have decided to answer the question for myself once and for all. I am going to perform three tests that I think typify the use cases for all three languages, I am also going to code the same tests in C and in static HTML.

This first post shoes the results from the most basic of tests - a "hello world" that's echoed out to the page. He ran the tests with Apache's ab tool for 10,000 times and recorded the request per second, average request time and the overhead as compared to plain HTML. It's interesting to see the jump from the HTML baselines when the languages start getting involved with the stock PHP install coming in as the slowest of the group.

tagged: serverside scripting language compare benchmark

Link:

SitePoint Server Side Coding Blog:
Cache it! Solve PHP Performance Problems
Nov 09, 2007 @ 19:16:00

On the SitePoint "Server Side Coding" blog, there's this look at caching to help solve some PHP performance issues.

In the good old days when building web sites was as easy as knocking up a few HTML pages, the delivery of a web page to a browser was a simple matter of having the web server fetch a file. [...] Then dynamic web pages came along and spoiled the party by introducing two problems: a delay for processing and a check of the file's age before it's sent to the browser.

They talk about what caching can do for you, what you can do (both server and client side) to prevent caching, working with the headers sent from and back out to the browser, using output buffering, partial caching and using PEAR::Cache_Lite in your application.

tagged: caching serverside clientside pear cachelite package partial caching serverside clientside pear cachelite package partial

Link:

SitePoint Server Side Coding Blog:
Cache it! Solve PHP Performance Problems
Nov 09, 2007 @ 19:16:00

On the SitePoint "Server Side Coding" blog, there's this look at caching to help solve some PHP performance issues.

In the good old days when building web sites was as easy as knocking up a few HTML pages, the delivery of a web page to a browser was a simple matter of having the web server fetch a file. [...] Then dynamic web pages came along and spoiled the party by introducing two problems: a delay for processing and a check of the file's age before it's sent to the browser.

They talk about what caching can do for you, what you can do (both server and client side) to prevent caching, working with the headers sent from and back out to the browser, using output buffering, partial caching and using PEAR::Cache_Lite in your application.

tagged: caching serverside clientside pear cachelite package partial caching serverside clientside pear cachelite package partial

Link:

Raphael Stolt's Blog:
Using the Zend Framework plugins for server-sided Ajax request identification
Apr 03, 2007 @ 12:08:00

Many thanks to Raphael Stolt for letting us know about his latest post, a tutorial on using the Zend Framework with Ajax to perform a server-side identification request.

He used a "@ajaxaction" marker in a previous article to implement the Ajax requests, but with other tools there could be an issue with the response. To help with this, he's worked up a handler to detect what needs to be done with the response. He applies this to create the authentication system, making it easy to include a simple ACL method into his application.

He includes code examples for the Controller to handle the detection, how to implement it, and the class to work with those "doclet" markers for the Ajax actions.

tagged: ajax serverside zendframework plugin request identification ajax serverside zendframework plugin request identification

Link:

Raphael Stolt's Blog:
Using the Zend Framework plugins for server-sided Ajax request identification
Apr 03, 2007 @ 12:08:00

Many thanks to Raphael Stolt for letting us know about his latest post, a tutorial on using the Zend Framework with Ajax to perform a server-side identification request.

He used a "@ajaxaction" marker in a previous article to implement the Ajax requests, but with other tools there could be an issue with the response. To help with this, he's worked up a handler to detect what needs to be done with the response. He applies this to create the authentication system, making it easy to include a simple ACL method into his application.

He includes code examples for the Controller to handle the detection, how to implement it, and the class to work with those "doclet" markers for the Ajax actions.

tagged: ajax serverside zendframework plugin request identification ajax serverside zendframework plugin request identification

Link:

Ajaxian.com:
AjaxCore: PHP Ajax Framework
Nov 22, 2006 @ 10:14:00

As mentioned over on Ajaxian.com, there's a new Ajax framework in town that's looking to "ease the development of rich Ajax applications, by generating the appropriate JavaScript code" - AjaxCore.

AjaxCore takes all the dirty work of JavaScript code generation and provides a solid foundation. The concept is to extend a Generic AjaxCore class and defining methods that handle the Ajax driven events and binding them to HTML objects.

It uses Prototype to work with the DOM and Ajax connections and to help you with binding the scripts to the different elements on the page. Code can be linked to certain elements and have that (server-side) code automatically executed when an element is referenced. You can find out more from the AjaxCore homepage and the Ajaxian post also includes a simple inline example to get you started.

tagged: ajaxcore framework ajax bind element serverside ajaxcore framework ajax bind element serverside

Link:

Ajaxian.com:
AjaxCore: PHP Ajax Framework
Nov 22, 2006 @ 10:14:00

As mentioned over on Ajaxian.com, there's a new Ajax framework in town that's looking to "ease the development of rich Ajax applications, by generating the appropriate JavaScript code" - AjaxCore.

AjaxCore takes all the dirty work of JavaScript code generation and provides a solid foundation. The concept is to extend a Generic AjaxCore class and defining methods that handle the Ajax driven events and binding them to HTML objects.

It uses Prototype to work with the DOM and Ajax connections and to help you with binding the scripts to the different elements on the page. Code can be linked to certain elements and have that (server-side) code automatically executed when an element is referenced. You can find out more from the AjaxCore homepage and the Ajaxian post also includes a simple inline example to get you started.

tagged: ajaxcore framework ajax bind element serverside ajaxcore framework ajax bind element serverside

Link: