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

SitePoint PHP Blog:
Image Scraping with Symfony's DomCrawler
March 31, 2014 @ 09:06:43

On the SitePoint PHP blog today there's a new post showing you how to use the Symfony DomCrawler component to scrape content, images mostly, from a remote website. The DomCrawler is one component of the Symfony framework.

A photographer friend of mine implored me to find and download images of picture frames from the internet. I eventually landed on a web page that had a number of them available for free but there was a problem: a link to download all the images together wasn't present. I didn't want to go through the stress of downloading the images individually, so I wrote this PHP class to find, download and zip all images found on the website.

He talks briefly about how the class works and then gets into the contents of the class. He walks through all the code and explains in chunks what each part does in the lifecycle of the request. The end result is a Zip archive file of all images from the remote website, packaged up for easy transport.

0 comments voice your opinion now!
domcrawler symfony framework component tutorial image scrape

Link: http://www.sitepoint.com/image-scraping-symfonys-domcrawler/

CodeGeekz:
Cropping Images in PHP Based on their Entropy
February 03, 2014 @ 11:25:42

On the CodeGeekz site there's a new post showing you how to use the Imagick extension and a custom library to crop images based on their entropy (keeping the "busiest" part of the image).

The need to resize and crop images in order to create thumbs, is a very common scenario for most websites. For example a blog like this one uses images in the content of the posts, images which at some point are used to create a thumb for the homepage. In most cases, the thumb's dimensions are not dynamic but are static throughout the website in order to better fit the template. This however creates a major problem when we try to automatically resize and crop our images in the desired dimensions.

He starts with an example of the normal kind of cropping based on a given height and width. He points out an issue with "smart cropping" and resizing the image with the cropping is done. Instead, he's made use of Imagick in his library to produce a better cropped image based on the parts of the image with the most entropy.

0 comments voice your opinion now!
crop image entropy busy resize smart tutorial

Link: http://codegeekz.com/cropping-images-entrop/

SitePoint PHP Blog:
PHP and Neo4j Introduction to Graph Databases
January 13, 2014 @ 12:18:52

On the SitePoint PHP blog today they've posted a new tutorial by Mehul Jain about combining PHP and Neo4J, a popular graph database tool as an alternative to the typical table-driven database structure. This is the first part of a series and only explains some of the basics behind the technology. The actual PHP implementation comes next.

For a long time, data has been typically stored in tabular form so as to increase the indexing and readability. Nowadays, the trends are changing as Graph databases are quickly gaining popularity. In fact, it would not be wrong to call them "the future of DBMS". New to the world of graphs and databases? Don't worry, by the end of this introductory article you will have sound theoretical knowledge about the topic - just enough to easily glide through the rest of the series - actual implementation.

He starts with the basics - introducing the ideas behind graph databases and some of the most basic concepts behind them. He continues, looking at common uses for them including dealing with connected data and how it lets you "move through" the data rather than jumping from record to record. He includes some real world examples if this kind of data ranging from social networks to network management.

0 comments voice your opinion now!
graph databases introduction neo4j tutorial

Link: http://www.sitepoint.com/php-neo4j-introduction-graph-databases/

PHPClasses.org:
Using Composer to Install JavaScript, CSS & Images Under the Web Document Directory
January 07, 2014 @ 12:36:07

On the PHPClasses.org site today there's a new post showing how to install more than just PHP packages with Composer including things like Javascript, CSS and image files.

By default Composer installs all package files under the vendor directory. If you want to install asset files in the Web document root directory, you need to resort to another solution. This Asset Manager package is a plugin that extends Composer to install any package files outside the vendor directory. Additionally, it can also read the user names and passwords from a configuration file, so you do not have to enter them every time Composer retrieves packages from repositories that may require authentication, like PHP Classes and JS Classes.

Using an asset manager plugin for Composer, he shows how to include an "extra" section into your "composer.json" for the other files. There's also an example of how to implement a custom installation action that, in this case, was used to implement the "extras" functionality. The post finishes up with a look at handling authentication in the Composer requests, using the same tool to parse a "config" section with Basic HTTP authentication information.

0 comments voice your opinion now!
composer package install javascript css image assets http authentication

Link: http://www.phpclasses.org/blog/package/8429/post/1-Using-Composer-to-Install-JavaScript-CSS-and-Images-Under-the-Web-Document-Directory.html

Mikko Koppanen:
Working on images asynchronously
December 16, 2013 @ 10:45:35

Mikko Koppanen has a new post to his site today about working with images asynchronously - the "offline" processing of things like user uploaded images using a queuing system.

To get my quota on buzzwords for the day we are going to look at using ZeroMQ and Imagick to create a simple asynchronous image processing system. Why asynchronous? First of all, separating the image handling from a interactive PHP scripts allows us to scale the image processing separately from the web heads. [...] Secondly, separating the image processing from a web script can provide more responsive experience to the user. This doesn't necessarily mean faster, but let's say in a multiple image upload scenario this method allows the user to do something else on the site while we process the images in the background.

He also includes a "barebones" example of how the system would work. The first Worker script makes the connection to the queue system and sends the data off for handling. The second script does most of the actual work, pulling in the image and using Imagick to create a thumbnail image. Finally he includes an example of the use of the workers in combination to send the image data for processing.

0 comments voice your opinion now!
image asynchronous processing zeromq thumbnail imagick

Link: http://valokuva.org/working-on-images-asynchronously/

Kevin Schroeder:
How much memory does Magento use?
December 10, 2013 @ 10:42:23

Kevin Schroeder was asked recently (as a part of a training class) about the amount of memory Magento actually uses during its execution. Magento is a widely-used e-commerce platform built in PHP.

Now, I know what you're supposed to set it at, but I've never measured actual usage. So I gave some bullcrap answer about how it really depends on a bunch of things and that I really shouldn't give a precise answer. But the individual persisted and I was forced to put my tail between my legs and admit that I didn't know. So I promised that I would take a look and here are my results.

He briefly mentions how he tested the memory usage of the code overall by adding an event to several spots in the application and using memory_get_usage. Using the sample Magento data he worked his way through the site and tracked the events/memory usage on the various page of the site including:

  • Main category page
  • Category page with images
  • Simple product page
  • Add to Cart

Each of these has a graph showing the memory usage at each stage. Additionally, he's graphed them all together to compare the overall memory consumption.He finishes off the post with a few summary items and conclusions from his results.

0 comments voice your opinion now!
magento memory usage consumption graph

Link: http://www.eschrade.com/page/how-much-memory-does-magento-use/

SitePoint PHP Blog:
Imagick vs GD
November 28, 2013 @ 18:16:34

In a new post to the SitePoint PHP blog Jacek Barecki has written up a comparison of two of the most widely used PHP image manipulation libraries - Imagick and GD.

If you want to create a thumbnail, apply a filter to an image or transform it in any other way, you will have to employ an image processing library in your PHP application. It means that you will probably choose GD or ImageMagick. But which one supports a wider range of image formats? Maybe one of them is slower than the other? What other criteria should be taken under consideration when choosing the right library?

He compares them on a few different aspects:

  • Availability
  • Supported file types
  • Functionality
  • Performance
  • Coding style
  • Popularity

He also provides three alternatives to using GD or Imagick, most involving outside services or software.

0 comments voice your opinion now!
imagick gd image manipulation library tutorial

Link: http://www.sitepoint.com/imagick-vs-gd/

Gonzalo Ayuso:
Using the event dispatcher in a Silex application
October 14, 2013 @ 13:03:26

Gonzalo Ayuso has a new post today showing you how to use the Symfony event dispatcher in a Silex-based application. His example involves a simple image processing example.

Symfony has one component called The Event Dispatcher. This component is one implementation of Mediator pattern and it's widely used in modern frameworks, such as Symfony. Silex, as a part of Symfony, also uses this component and we can easily use it in our projects.

His example creates a Silex endpoint that creates an image with a given string. He notes that handling it all at once and then unlinking at the end of the request is one way to handle it. The other is to use the event dispatcher to add an event lister (as a closure) to happen "on terminate" to unlink the path it's been given.

0 comments voice your opinion now!
event dispatcher symfony2 silex image generate

Link: http://gonzalo123.com/2013/10/14/using-the-event-dispatcher-in-a-silex-application/

SitePoint PHP Blog:
Responsive Images Using Picturefill and PHP
October 10, 2013 @ 10:08:11

On the SitePoint PHP blog there's a new post from Lukas White showing you how to use the Picturefill plugin (Javascript) along with PHP to make responsive images.

One of the key challenges with responsive web design, and a subject of much discussion in recent years, is how to deal with images. Setting a max-width on image elements enables designers to allow their size to adapt to the page dimensions, but in itself that approach can lead to far bigger images being downloaded than are required. [...] You can use a similar approach [to "source sets" of images] straight away and in a cross-browser compatible manner by using Javascript; one such method is the Picturefill plugin. In essence, Picturefill allows you to specify different src attributes for an image, each image file corresponding to a different media query. Thus

The tutorial helps you create an application, powered by the Slim framework and the ImageMagick extension, for the basic structure. He then grabs the Picturefill library and drops them into place. Some sample code is also included showing how to create the HTML structure for the images and the Javascript to handle the switching.

0 comments voice your opinion now!
responsive image picturefill tutorial resolution source set

Link: http://www.sitepoint.com/responsive-images-using-picturefill-php/

Kevin Schroeder:
More - The file system is slow
September 30, 2013 @ 10:44:29

As a follow-up to his previous article about the (minimal) overhead from logging, Kevin Schroeder has this new post focusing on the common belief that writing to the file system is the slowest method.

I had a conversation the other day by a person I respect (I respect any PHP developer who knows how to use strace) about the cost of file IO. My assertion has been, and has been for a long time, that file IO is not the boogeyman that it is claimed to be. So I decided to test a cross between those two posts.

His test was to write one million log records to two different sources - the normal physical file system, a RAM drive - one run with a file handle that's left open and the other with a new handle each time. He shows how he made the RAM drive and the PHP he used for the test (running in a VM). He graphs out the results with some interesting results...but you'll have to read the post for that.

0 comments voice your opinion now!
file system slow write log overhead benchmark ramdisk graph

Link: http://www.eschrade.com/page/more-on-the-file-system-is-slow/


Community Events





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


series install release update api opinion zendserver library interview podcast deployment package laravel unittest tips language framework symfony community introduction

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