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

DevShed:
Building Dynamic Web Pages with Polymorphism in PHP 5
Mar 28, 2007 @ 18:15:35

DevShed continues their look at using polymorphism in an application with the latest part of the series - "Building Dynamic Web Pages with Polymorphism in PHP 5".

In short, Polymorphism is a feature exposed by certain objects that belong to the same family, which eventually can behave differently, even when they're using identical methods. Or more clearly, an object can be considered polymorphic when it's capable of performing different actions by utilizing the same method.

This time they focus on web page development that uses this object-oriented practice. The create a WebPageElement that you can ID and class attributes on and use it to create HTML widgets and extend them to create Div and Link element.

tagged: php5 polymorphism dynamic pages html elements php5 polymorphism dynamic pages html elements

Link:

DevShed:
Building Dynamic Web Pages with Polymorphism in PHP 5
Mar 28, 2007 @ 18:15:35

DevShed continues their look at using polymorphism in an application with the latest part of the series - "Building Dynamic Web Pages with Polymorphism in PHP 5".

In short, Polymorphism is a feature exposed by certain objects that belong to the same family, which eventually can behave differently, even when they're using identical methods. Or more clearly, an object can be considered polymorphic when it's capable of performing different actions by utilizing the same method.

This time they focus on web page development that uses this object-oriented practice. The create a WebPageElement that you can ID and class attributes on and use it to create HTML widgets and extend them to create Div and Link element.

tagged: php5 polymorphism dynamic pages html elements php5 polymorphism dynamic pages html elements

Link:

DevShed:
Using HTTP Compression in PHP - Make Your Web Pages Load Faster
Apr 10, 2006 @ 15:26:56

One of the holy grails of web development is to have your pages lost the fastest way possible. People spend hours optimizing images and condensing the amount of data they actually send over the wire to reach this goal. There are, however, other ways to achieve some of the same results, HTTP compression being one of them. For those that aren't familiar with the topic, DevShed has this new article to bright you up to speed.

This article, the first of three parts, shows you how to make PHP pages load faster by showing you how to compress dynamic PHP pages. Techniques covered include using PHP's built-in "gzencode()" function, along with output buffering control functions.

Since PHP offers a powerful built-in library for handling HTTP compressed data, over this series I'll explain the basics of working with HTTP-compressed PHP pages. I'll illustrate, with several code samples, different methods for compressing dynamic PHP pages.

They start with the basics, writing up a simple script to compress the output from a simple PHP file, one that displays records from a "users" database. With that foundation laid, they move on to the heavy stuff - using more than just simple output buffering to speed up those pages. Their new example makes use of the gzip functions in PHP to compress the data even further. A gzip header is passed off to the browser and it pulls it all neatly compressed over to open on the client-side.

tagged: compression http pages load faster gzip output buffering compression http pages load faster gzip output buffering

Link:

DevShed:
Using HTTP Compression in PHP - Make Your Web Pages Load Faster
Apr 10, 2006 @ 15:26:56

One of the holy grails of web development is to have your pages lost the fastest way possible. People spend hours optimizing images and condensing the amount of data they actually send over the wire to reach this goal. There are, however, other ways to achieve some of the same results, HTTP compression being one of them. For those that aren't familiar with the topic, DevShed has this new article to bright you up to speed.

This article, the first of three parts, shows you how to make PHP pages load faster by showing you how to compress dynamic PHP pages. Techniques covered include using PHP's built-in "gzencode()" function, along with output buffering control functions.

Since PHP offers a powerful built-in library for handling HTTP compressed data, over this series I'll explain the basics of working with HTTP-compressed PHP pages. I'll illustrate, with several code samples, different methods for compressing dynamic PHP pages.

They start with the basics, writing up a simple script to compress the output from a simple PHP file, one that displays records from a "users" database. With that foundation laid, they move on to the heavy stuff - using more than just simple output buffering to speed up those pages. Their new example makes use of the gzip functions in PHP to compress the data even further. A gzip header is passed off to the browser and it pulls it all neatly compressed over to open on the client-side.

tagged: compression http pages load faster gzip output buffering compression http pages load faster gzip output buffering

Link:

DevShed:
Private Pages with PHP and Text Files
Feb 27, 2006 @ 09:16:15

DevShed has this new tutorial posted today concerning the use of text file authentication to create "private pages" in your site.

You run a website that is simple enough it doesn't require a database. But your site features certain pages to which you'd like to limit access. Most of the time, that implies using a database to store passwords and usernames. There is an easier way, however. It's less secure, but it involves a lot less coding.

They step you through the process - creating the form, making the PHP page for it to submit to, checking the password (including a bit on encryption), and validating the user's entry against it.

tagged: private pages text file authentication nd5 encryption private pages text file authentication nd5 encryption

Link:

DevShed:
Private Pages with PHP and Text Files
Feb 27, 2006 @ 09:16:15

DevShed has this new tutorial posted today concerning the use of text file authentication to create "private pages" in your site.

You run a website that is simple enough it doesn't require a database. But your site features certain pages to which you'd like to limit access. Most of the time, that implies using a database to store passwords and usernames. There is an easier way, however. It's less secure, but it involves a lot less coding.

They step you through the process - creating the form, making the PHP page for it to submit to, checking the password (including a bit on encryption), and validating the user's entry against it.

tagged: private pages text file authentication nd5 encryption private pages text file authentication nd5 encryption

Link:

Richard Miller's Blog:
UPHPU meeting on custom 404 pages
Feb 22, 2006 @ 06:49:49

From Richard Miller's blog today, there's a new post with content from the Utah PHP Users Group meeting that's just passed (Feb. 2006) on the topic of custom 404 pages.

When you try to visit a web page that doesn't exist, the server usually returns a 404 error message - "Page Not Found". At the Utah PHP Users group meeting last Thursday, Mac Newbold presented on custom 404 pages. Custom 404 pages can help maintain your website branding, help you fix broken links, and help your users find something useful when they don't find what they're looking for.

Custom 404 pages are even more powerful when you combine them with PHP. I certainly didn't expect the flood of ideas that Mac presented for using custom 404 pages.

Among the suggestions of things to do with the error pages are things like: sending an email when someone gets a 404, search the site for something similar, use it as a redirect for old to new URLs, and more.

tagged: user group utah meeting february 2006 custom 404 pages user group utah meeting february 2006 custom 404 pages

Link:

Richard Miller's Blog:
UPHPU meeting on custom 404 pages
Feb 22, 2006 @ 06:49:49

From Richard Miller's blog today, there's a new post with content from the Utah PHP Users Group meeting that's just passed (Feb. 2006) on the topic of custom 404 pages.

When you try to visit a web page that doesn't exist, the server usually returns a 404 error message - "Page Not Found". At the Utah PHP Users group meeting last Thursday, Mac Newbold presented on custom 404 pages. Custom 404 pages can help maintain your website branding, help you fix broken links, and help your users find something useful when they don't find what they're looking for.

Custom 404 pages are even more powerful when you combine them with PHP. I certainly didn't expect the flood of ideas that Mac presented for using custom 404 pages.

Among the suggestions of things to do with the error pages are things like: sending an email when someone gets a 404, search the site for something similar, use it as a redirect for old to new URLs, and more.

tagged: user group utah meeting february 2006 custom 404 pages user group utah meeting february 2006 custom 404 pages

Link:

Nexen.net:
How to Avoid Expired Pages
Nov 16, 2005 @ 06:20:56

In this new post on Nexen.net (French), they talk about the latest article from Chris Shiflett in PHP Magazine, a solution to the "Page has Expired" messages.

Chris Shiflett's article this month is the "Article of the Month" on PHP Maagzine. It covers how to avoid the "Page has Expired" messages. These are the pages that aren't in the browsers cache anymore because the data it was passing back and forth has timed out. Thus there is a warning when the user tries to go back in the site, resulting in the familiar prompt.

You can check out his latest edition of the "Guru Speak" in this month's sample article - "How To Avoid Page Has Expired Warnings"...

tagged: expired pages magazine article expired pages magazine article

Link: