News Feed
Sections




News Archive
feed this:

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

Jurian Sluiman:
SoflomoCache manage your ZF2 cache services
May 09, 2014 @ 09:53:32

Jurian Sluiman has posted about the release of a tool that aims to help you with cache handling in your Zend Framework 2 applications, the SoflomoCache component.

aching is an essential part in scaling your application, but Zend Framework 2 was missing a utility to manage your caches. Until now! During deployments we usually flushed the cache in a tedious and cumbersome way by directly accessing the apc_* functions in a custom script. This could certainly be improved and so we wrote a command line utility to manage all our cache services.

He includes a few snippets of code showing how to implement the component in your configuration and use it via ZF2's dependency injection handling. He also includes a list of the commands that can be used along with it to flush the cache, either all simultaneously or a single one (defined as a CLI option). It can also flush by namespace and handle the refresh of your combined configuration and module map.

0 comments voice your opinion now!
zendframework2 cache management component project service

Link: https://juriansluiman.nl/article/134/soflomo-cache-manage-your-zf2-cache-services

Dutch Web Alliance:
Using Varnish with ESI for a REST API
May 08, 2014 @ 10:23:35

In the latest post to the Dutch Web Alliance blog Bas de Nooijer looks at a handy use of ESI in Varnish as a part of the output for a REST API. ESI (Edge Side Includes) let you handle the caching and reuse of fragments of the output from your application and define different caching rules/techniques for each.

For a project I'm currently working on we are implementing a REST API. Performance for this API is critical, so amongst some other solutions Varnish is used. This was done with minimal effort, as the API already had the correct caching headers. There was a noticeable improvement, however I had the feeling this could be improved much more. I realised I can basically compare our REST API to any website, it uses HTTP in the same way. The main diffence is the content being JSON instead of HTML. Just like most websites, our API composes content in many different ways, for instance 'standalone' resources, collections of resources or embedded resources. In a website this would be a clear use case for ESI, so why not use it in our API?

He starts off by asking the question "why use ESI in an API" and compares the ESI method to the more traditional caching rules and handling. He includes two diagrams showing the flow of each handling type along with a brief description of how it would extract and combine the data. With the background out of the way, he gets into the code. He shows how to enable JSON caching in Varnish and the JSON tag information you'll need to include to tell Varnish to do its job.

0 comments voice your opinion now!
varnish rest api tutorial cache esi edge side include

Link: https://dutchweballiance.nl/techblog/using-varnish-with-esi-for-a-rest-api

Edd Mann:
Storing PHP Sessions/File Caches in Memory using TMPFS
April 17, 2014 @ 11:19:59

Edd Mann (of the Three Devs & A Maybe podcast) has shared a method of session storage he worked up to help increase performance in his application. He shows how to store sessions in memory with the help of TMPFS.

Yesterday I was looking through some application logs and noticed a significant bottleneck with I/O reads in the implemented file cache. [...] This was when I found 'tmpfs', saving me from all sorts of issues relating to adding yet another application to the production stack. 'tmpfs' appears as a mounted partition on your system, however, under the hood it allocates and uses a section of physical memory (non-persistent through reboots). [...] his results in the desired speed boosts, without tampering with the application logic itself. Even better, if the mount is unsuccessful for some reason, it will safety fall-back to using the persistent hard-disk solution.

Since PHP sessions make it easy to change the "save_path" location for the data in an ini value, setup is easy. He includes the needed configuration change and the commands you'll need to mount the tmpfs partition on your local file system.

0 comments voice your opinion now!
tmpfs session file cache memory tutorial comamnds ini

Link: http://eddmann.com/posts/storing-php-sessions-file-caches-in-memory-using-tmpfs

NetTuts.com:
Laravel Unwrapped Session, Auth and Cache
March 11, 2014 @ 11:57:10

On NetTuts.com today there's a new tutorial introducing you to the Laravel framework and how to use its session, authentication/authorization and caching systems.

One thing though that not a lot of programmers take advantage of is Laravel's component-based system. Since its conversion to composer-powered components, Laravel 4 has become a very modular system, similar to the verbosity of more mature frameworks like Symfony. [...] In this tutorial, we'll be diving into a group of these components, learning how they work, how they're used by the framework, and how we can extend their functionality.

First up is the session component that lets you store the data in various places (file, cookie, etc) and how service providers fit into this. Next up is the Auth component, showing how to use the service providers to hook into a custom auth handler for finding and validating user logins. Finally, there's the Cache component. He shows how to apply a service provider to configure it, passing the data off to a MongoDB database to be stored.

0 comments voice your opinion now!
laravel tutorial session cache authentication serviceprovider framework

Link: http://code.tutsplus.com/tutorials/laravel-unwrapped-session-auth-and-cache--cms-19952

Master Zend Framework:
Make Module Configs Cacheable with the ZF2 Factory Interface
March 07, 2014 @ 11:25:09

Matthew Setter has a new post today on the "Master Zend Framework" site looking at the use of caching for Zend Framework 2 module configurations.

For the longest time, I've been using closures in my Zend Framework 2 Modules Module class. I know they're not always the best approach, but they're not necessarily wrong either. But after reviewing Gary Hockin's recent talk at PHP Conference UK, I was reminded that outside of APC and OPCache, closures aren't cacheable. [...] So in today's tutorial, I'm going to show you a simple example of how to migrate from closures using [caching with Memcached, Redis and so on].

He starts with an example of the standard closure approach, returning an array from his "getServiceConfig" method with sub-array and object creation nested inside. He then refactors it to use the "FactoryInterface" to handle the configuration setup for the "delete form" handling.

0 comments voice your opinion now!
module configuration cache zendframework2

Link: http://www.masterzendframework.com/tutorial/zf2-factory-interface-closure-migration

SitePoint PHP Blog:
HHVM revisited
December 23, 2013 @ 10:57:01

The SitePoint PHP blog has a new post from Bruno Skvorc talking about a technology that's growing more and more popular all the time in the PHP ecosystem - HHVM, the virtual machine version of Facebook's HipHop software.

Just over two years have passed since the last post about HHVM by Matt Turland. What changed in that time? Did anything? Let's see just how successful PHP's quest for performance was.

Bruno takes a step back and, for those not sure what the HHVM is, explains the technology a bit and what some of the project's goals are. He talks about its compatibility with current software (like OSes and web servers) and the inclusion of FastCGI support. He also talks about some of the other main issues around the use of the HHVM like:

  • Performance considerations
  • Pre-analyzing
  • Authoritative Cache
0 comments voice your opinion now!
hhvm update article performance fastcgi cache

Link: http://www.sitepoint.com/hhvm-revisited/

Davey Shafik:
Everything You Need to Know About OpCode Caches
October 01, 2013 @ 10:49:48

Davey Shafik has a new post to his site today sharing everything you need to know about opcode caches, the mechanism that's works "behind the scenes" to cache the execution of the opcode paths for later reuse.

Last year I wrote a talk called "Fast, Not Furious: How to Find and Fix Slow Code" - a performance talk covering profiling, memcache and some other stuff. As I often do - to hedge my bets = I stuck a few slides on the end "just in case" I ran through everything too quickly and needed to fill in time. These slides were on APC, the Alternative PHP Cache, and went just a little into tokens and how APC works under the hood. I really enjoyed presenting those 6 slides, and I've been wanting to expand on that topic ever since then. Well, after a few weeks of hard work, some input from some great people, including Sara Golemon, Elizabeth Smith and Julien Pauli, I'm so very happy to publish PHP Performance I: Everything You Need to Know About OpCode Caches.

The result is published over on the Engine Yard Developer Center and has been made into a 20 minute screencast (with original slides here). He covers what they are, which ones are out there, the common execution cycle and what happens when the opcodes are cached.

0 comments voice your opinion now!
opcode cache presentation screencast guide tutorial apc zend opcache

Link: http://daveyshafik.com/archives/68838-everything-you-need-to-know-about-opcode-caches.html

Reddit.com:
Question about the relevance of benchmarking
September 27, 2013 @ 09:46:10

On Reddit.com there's a new post from someone relatively new to PHP wondering what the relevance of benchmarks is in a time when most performant sites use caching (full page or data) to increase their speed.

I was speaking to another PHP developer today who is a lot smarter than me. I was curious about Static Site Generators taking over the future of the web. [He] told me that most of the time, big sites have a cache that people hit. So people don't even have to wait for PHP to be interpreted. This begs the question . . . How are performance metrics relevant for different frameworks, when these sites are being cached anyway?

There's several comments on the post now with a few different opinions like:

  • "Most of the benchmarks you'll see are dishonest and/or skewed as they don't paint an accurate picture of what's going on, or how they would be used in the real world."
  • "As soon as you start taking too much time to return a page to a user you have a knock-on effect where you develop a queue of other users waiting for their page to be returned as well."
  • "So far as performance benchmarks go, the framework and language used in your application becomes redundant once you add a caching layer as the page performance is then limited by what caching layer you use."
  • "as a rule of thumb "logged out users see cached content" "logged in users see uncached content""
0 comments voice your opinion now!
relevance benchmarking script framework application cache

Link: http://www.reddit.com/r/PHP/comments/1n5ygr/i_am_an_idiot_question_about_the_relevance_of

The PHP.cc:
PHP 5.5 Out-of-the-Box Bytecode Cache
June 25, 2013 @ 09:04:14

In a new post to their site, the PHP.cc (well, Sebastian Bergmann) takes a look at the bytecode caching feature that's included in the latest release of PHP, version 5.5.

PHP is an interpreted language. The default PHP runtime, the one that can be obtained from php.net, compiles PHP sourcecode to an intermediate representation called PHP bytecode which is then executed. A bytecode cache stores this compiled representation of PHP sourcecode in shared memory. This eliminates the need to load and compile sourcecode on each request which leads to a significant increase in performance (up to 70% more requests per second).

He looks some at "the past" of PHP and how it made it up from the world of PHP 4.x to PHP 5.4 and the de-facto bytecode cache before now, APC. With the introduction of PHP 5.5, though, developers have access to an integrated version of the ZendOptimizer+ cache built right into the language. They include a little bit of documentation about how to enable it and how to install it via PECL if it's not already built in.

0 comments voice your opinion now!
bytecode cache zendoptimizer language included pecl

Link: http://thephp.cc/viewpoints/blog/2013/06/php-5-5-out-of-the-box-bytecode-cache

Rob Allen:
Caching your ZF2 merged configuration
June 19, 2013 @ 09:43:28

Rob Allen has a a new post to his site today showing how you can cache the merged settings from all of your configuration files combined in a Zend Framework v2 application.

Zend Framework 2's ModuleManager has the ability to cache the merged configuration information for your application. This is very useful as it allows you to separate out your configuration within the config/autoload directory into logical files without worrying about the performance implications of lots of files.

There's some ZF2 configuration options that tell it to cache this data once it's loaded the first time, but he notes one issue with this - caching in development. It can be annoying when you make a change and nothing happens because it's cached. To prevent this he shows you how to only cache if the application is marked as in production (based on the "APPLICATION_ENV"). Separate main configuration files are made for each environment, one that caches and one (for dev) that doesn't.

0 comments voice your opinion now!
cache merged configuration zendframework2 tutorial production development

Link: http://akrabat.com/zend-framework-2/caching-your-zf2-merged-configuration


Community Events





Don't see your event here?
Let us know!


interview list introduction series code threedevsandamaybe release refactor opinion developer unittest podcast wordpress language community configure testing framework laravel install

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework