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

Amine Matmati:
Testing PDF content with PHP and Behat
Jul 31, 2015 @ 13:49:52

In this post to his site Amine Matmati shows you how to use Behat (with a bit of additional PHP) to test the contents of a rendered PDF file.

If you have a PDF generation functionality in your app, and since most of the libraries out there build the PDF content in an internal structure before outputting it to the file system (FPDF, TCPDF). A good way to write a test for it is to test the output just before the rendering process.

Recently however, and due to this process being a total pain in the ass, people switched to using tools like wkhtmltopdf or some of its PHP wrappers (phpwkhtmltopdf, snappy) that let you build your pages in html/css and use a browser engine to render the PDF for you, and while this technique is a lot more developer friendly, you loose control over the building process.

He shows how to get all of the required software installed including the smalot/pdfparser library used to read in the contents of the PDF file. He initializes a Behat test directory and writes a simple test, checking for a string of some "Lorem ipsum" text in the document's title and that it contains only one page. Some additional methods have to be created to integrate the PDF parsing and string location/page counting and code is included for each. When all the pieces are put in place, executing the test passes for both checks. You can find the code for the tutorial in this repository that also includes two sample PDFs to work with.

tagged: integration test behat contents string pages tutorial

Link: http://matmati.net/testing-pdf-with-behat-and-php

Lorna Mitchell:
What Goes in Source Control?
Apr 30, 2013 @ 10:31:26

As developers, one of the best things you can do for a project is to use version control (or "source control") for your code. Lorna Mitchell suggest using it on a wider scale, though. She sees it as a great place for all sorts of other things around a project too.

Short answer: everything! However we need some good directory structures and source control configuration to make that a really practical answer, so this article is a quick outline of my usual advice for a good source control structure for a standard web project. The examples are for a PHP project but I'm sure you could apply this to your own language of choice, also.

These "other things" she suggests that should end up in source control including things like:

  • The actual "web root" of your application
  • Library code
  • Build scripts
  • Configuration files
  • Database patches
  • Tests (unit, functional, integration, etc)
tagged: source version control suggestion contents

Link: http://www.lornajane.net/posts/2013/what-goes-in-source-control

Robert Basic's Blog:
Zend Framework full page cache tips
Feb 13, 2012 @ 11:45:10

If you're looking at using the full-page caching that the Zend Framework has to offer, you should read about Robert Basic's experiences with it before implementing it in your application.

When I started rewriting this blog, I knew from start that I want to use Zend Framework's full page caching, as, I think, that's the best cache for this purpose. Not much going on on the front end, much more reads than writes, no ajax or any other "dynamic" content. While implementing the cache, I ran into two issues.

His issues revolved around the feature not creating valid cache files due to a duplicate "startSession" call in his code and having the Google Analytics code included in the template (with different keys every time). You can find out more about this functionality in the Zend Framework manual.

tagged: zednframework fullpagecache problem page contents

Link:

Christian Stocker's Blog:
Upload Progress Meter extension 0.9.2 released
Jan 22, 2009 @ 09:36:38

Christian Stocker has released the latest version of the uploadprogress extension to the PECL repository (0.9.2). The package allows the code to track the progress of an upload automatically.

The main new function since 0.9.1 is uploadprogress_get_contents($id), which allows you to analyse the content of an uploading file during the upload and do appropriate measure (for example warn the user, that he doesn't upload a supported video format). You have to enable this feature in php.ini to make it work. This feature was provided by Ben Ramsey, so you have to poke him, if something's wrong with it.

A simple example of it in action is also included (in the /examples subdirectory off of the PECL page) showing how to upload a file, get the progress and - most importantly - how to get useful error messages out of it.

tagged: upload progress pecl extension example contents analyze

Link:

Cory Borrow's Blog:
Creating thumbs from textfiles with PHP and GD
Jan 16, 2008 @ 12:50:00

Cory Borrow has posted a tutorial he's created to show how to harness the power of PHP and GD to create thumbnail images out of the contents of a text file.

Today, I'll give a little info on how to achieve the process of creating a thumbnail using PHP, GD and the text from a text file. It is really pretty simple, so lets get started.

The trick behind the translation is in reading in the contents of the (plain) text file and pushing it into a string value of a newly created GD-generated image. He includes the code to make using it in your own app simple (a cut and paste version) - his method FileToThumb.

tagged: thumbnail image gd tutorial text file contents thumbnail image gd tutorial text file contents

Link:

Cory Borrow's Blog:
Creating thumbs from textfiles with PHP and GD
Jan 16, 2008 @ 12:50:00

Cory Borrow has posted a tutorial he's created to show how to harness the power of PHP and GD to create thumbnail images out of the contents of a text file.

Today, I'll give a little info on how to achieve the process of creating a thumbnail using PHP, GD and the text from a text file. It is really pretty simple, so lets get started.

The trick behind the translation is in reading in the contents of the (plain) text file and pushing it into a string value of a newly created GD-generated image. He includes the code to make using it in your own app simple (a cut and paste version) - his method FileToThumb.

tagged: thumbnail image gd tutorial text file contents thumbnail image gd tutorial text file contents

Link:

Wez Furlong's Blog:
HTTP POST from PHP, without cURL
Nov 15, 2006 @ 10:09:00

In an effort to get streams more out in the, er, mainstream, Wez Furlong has posted an example of some code for a common operation many use cURL for - posting to a remote script - but with streams.

Every time I search for the code snippet that allows you to do an HTTP POST request, I don't find it in the manual and resort to reading the source. So, here's an example of how to send a POST request with straight up PHP, no cURL.

The example uses stream_context_create, fopen, stream_get_contents and an Exception to send off the message from an inputted array to the remote server. Smaller things, like the Content-length header on the request, are automatically handled by the wrapper functionality. You can check out this page for more information on the wrapper functionality.

tagged: http post without curl stream context contents exception http post without curl stream context contents exception

Link:

Wez Furlong's Blog:
HTTP POST from PHP, without cURL
Nov 15, 2006 @ 10:09:00

In an effort to get streams more out in the, er, mainstream, Wez Furlong has posted an example of some code for a common operation many use cURL for - posting to a remote script - but with streams.

Every time I search for the code snippet that allows you to do an HTTP POST request, I don't find it in the manual and resort to reading the source. So, here's an example of how to send a POST request with straight up PHP, no cURL.

The example uses stream_context_create, fopen, stream_get_contents and an Exception to send off the message from an inputted array to the remote server. Smaller things, like the Content-length header on the request, are automatically handled by the wrapper functionality. You can check out this page for more information on the wrapper functionality.

tagged: http post without curl stream context contents exception http post without curl stream context contents exception

Link:

Zend Developer Zone:
Davey Shafik and Ben Ramsey on the Zend Certification Exam Study Guide
Oct 09, 2006 @ 14:56:00

On the Zend Developer Zone today, there's an interview with the co-authors of the recently released book from php|architect, the Zend Certification Study Guide.

The new Zend Certification Study Guide is out and the initial reviews look good. Since this was a topic of interest to me (mainly because I’ve yet to take the test) I decided to dig a little deeper. I fired up my recorder and called Davey Shafik and Ben Ramsey, the authors of the new guide, to talk to them. Here to give you a little of the back story is our conversation.

They talk about:

  • the release of the book
  • some of the contents of the chapters (including the sample chapter on security)
  • Davey's experience with the exam/Ben's use of his PHP4 certification in his work
  • and the practice tests that php|architect is offering to get developers prepared.

tagged: interview zend certification php5 study guide author contents experience interview zend certification php5 study guide author contents experience

Link:

Zend Developer Zone:
Davey Shafik and Ben Ramsey on the Zend Certification Exam Study Guide
Oct 09, 2006 @ 14:56:00

On the Zend Developer Zone today, there's an interview with the co-authors of the recently released book from php|architect, the Zend Certification Study Guide.

The new Zend Certification Study Guide is out and the initial reviews look good. Since this was a topic of interest to me (mainly because I’ve yet to take the test) I decided to dig a little deeper. I fired up my recorder and called Davey Shafik and Ben Ramsey, the authors of the new guide, to talk to them. Here to give you a little of the back story is our conversation.

They talk about:

  • the release of the book
  • some of the contents of the chapters (including the sample chapter on security)
  • Davey's experience with the exam/Ben's use of his PHP4 certification in his work
  • and the practice tests that php|architect is offering to get developers prepared.

tagged: interview zend certification php5 study guide author contents experience interview zend certification php5 study guide author contents experience

Link: