Items in category php

JavaScript and Underscore.js type methods in PHP

PHP

I’ve been working with PHP since 2000 and with JavaScript even longer. Over last decade JavaScript evolved drastically. It had a promising design from the very beginning and gained its current incredible shape with the shift to ES2015 (Harmony). PHP though didn’t change that much. Apparently it’s doomed always to suffer from its own legacy. It arrived in middle 90s as a simple CGI app to maintain Rasmus Lerdorf’s home page and have been more like spontaneously developing ever since.

Bringing Google Analytics Reports to Your Application

PHP

Reasonably statistic analyses belong to CMS ACP reports. So, CMS vendors tend to include some into their products. However, they often make statistical data collection and analysis a part of CMS. It usually gains some primitive reports and affects application performance. I believe any sound statistic analysis can be delivered only by a dedicated specialized application. Meantime CMS can be used to represent the reports prepared by that application. Have you ever fancied displaying Google Analytics Reports in your CMS?

MVC on command line

PHP

If you work with Zend Framework, you likely tried ZF Console (Zend_Tool on command line). But have you tried to extend it? Why? To have common interface for all your Cli-scripts related to ZF-base project. How do you find the idea to program Cli-scripts in MVC? Zend Framework provides us with the tool to do it. First, you have to make ZF shell script zf.sh and assisting zf.php globally accessible. Wherever you have located them, just make a symlink on zf.

Anonymous Functions and Closures in PHP

PHP

If you are used to switch between JS and PHP programming, it obviously happened to you to miss some of JS flexibility in PHP. I felt it every time when declaring a callback function , being eager to apply something from JS like that: var scope = 'internal'; setTimeout(_callback, 100); // Callbacks var _callback = function() { alert(scope); } And when I needed a recursive use, even like that: (function(delay){ timer = setTimeout(function(){ timer = setTimeout(arguments.