News Feed
Jobs Feed
Sections




News Archive
feed this:

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

LeaseWebLabs.com:
Lessons learned implementing AES in PHP using Mcrypt
February 28, 2014 @ 09:37:45

The LeaseWebLabs.com site has a new post talking about some of their difficulties (and lessons learned) when implementing AES in PHP with mcrypt for a recent project.

The Advanced Encryption Standard (AES) is the successor of triple DES. When you need a standardized, secure, high performance symmetric cipher it seems like a good choice. Wi-Fi network traffic is encrypted with AES for instance. Also when you want to securely store data in a database or on disk you could choose AES. Many SSDs store data internally using AES encryption. PHP supports AES through "mcrypt". On Debian based systems (like Ubuntu and Mint) you can install it using "sudo apt-get install php5-mcrypt".

With no direct support for AES in mcrypt, they decided on Rijndael-128 instead and include some code examples of getting its key and block size. They also include an example of the dynamic typing PHP does when converting a string to an integer and the "key padding" PHP automatically does if the key length it too short. A few other problems they discovered during implementation are mentioned as well including null padding on strings and PHP's ignoring of a wrong size initialization vector (no padding, just an error).

0 comments voice your opinion now!
leaseweblabs mcrypt implement aes rijndael

Link: http://www.leaseweblabs.com/2014/02/aes-php-mcrypt-key-padding/

MaltBlue.com:
Are TableGateways Worth it in Zend Framework 2?
November 27, 2013 @ 11:34:28

On his MaltBlue.com blog Matthew Setter shares his opinion on TableGateways in Zend Framework v2 and wonders if they're "worth it" (as they're not the easiest thing to implement).

Are TableGateways too hard to implement in Zend Framework 2? Are they too hard to justify the effort? That's what I was asked recently during a Twitter conversation. For me, they're not. For me, they're well worth the effort. So I've written this post to show why they're not, and how they bring great flexibility, when implemented correctly. In [this post] I'll set out why they can be a good solution, as well as why not.

He starts from the origins of PHP scripts, back when they were "a collection of files" and not structured under much of a framework. Complexity added the need for this structure, though, including things like design patterns for common tasks. The TableGateway was one of these. He talks briefly about implementing them in Zend Framework v2 (with some gist examples) and some questions to ask helping you determine if they're "too much" for you app.

0 comments voice your opinion now!
tablegateway designpattern zendframework2 implement difficulty

Link: http://www.maltblue.com/patterns/why-tablegateways

PHPMaster.com:
Integrating Open Authentication using Opauth
March 11, 2013 @ 09:07:52

On PHPMaster.com there's a new tutorial showing you how to implement OAuth authentication in your application using the Opauth Php library. This library lets you connect to any of a number of OAuth service providers and authenticate.

Open Authentication has evolved as a standard for third-party authentication in recent years and allows us to securely authenticate our application's users through a standard interface. Twitter and Facebook has been the standouts among dozens of authentication service providers. [...] In this article we'll explore how we can effectively use Opauth to standardize our authentication strategies. I'll be using CodeIgniter here, but even if you're not familiar with CodeIgniter, I suggest you continue reading since it will be similar for other frameworks as well. Once you understand the necessary details for integration, adapting to any framework is super simple.

He talks some about the Opauth library and shows the full authentication flow that your script will follow when using it. Code is included showing how to include and integrate the Opauth library including setup and configuration of the object and the controller/view code to implement the login form.

0 comments voice your opinion now!
opauth oauth library tutorial implement authenttication


PHPMaster.com:
Implementing PSR-3 with log4php
January 15, 2013 @ 12:53:17

With the PSR-3 logging interface recently accepted by the PHP-FIG, Jamie Munro has written up a post for PHPMaster.com that shows how to implement the interface with log4php, the Apache logging tool.

With the recent passage of PSR-3, a standard for a common interface for logging libraries, it seems appropriate to discuss the implementation with my favorite logging library. log4php is an open source Apache project that is a very versatile logging framework. Through log4php's configuration files, logging has a variety of output locations, so it's possible to send specific log levels to different output locations.

He includes the Composer requirements for the interface and shares the code for a wrapper class that implements the Logger interface and defines methods for each of the logging levels (alert, notice, debug, etc). Also in the post is an example XML configuration for log4php and how to load it into your class instance.

0 comments voice your opinion now!
implement psr3 logger interface log4php apache tutorial


Josh Adell:
Interfaces and Traits A Powerful Combo
September 28, 2012 @ 08:51:16

Josh Adell has a new post today looking at the "powerful combination" of using traits and interfaces in PHP applications. He shows how, despite traits not implementing the interface directly, they can be used to make other classes adhere to them simply by "using" them.

If you're not using interfaces in PHP, you are missing out on a powerful object-oriented programming feature. An interface defines how to interact with a class. By defining an interface and then implementing it, you can guarantee a "contract" for consumers of a class. Interfaces can be used across unrelated classes. And they become even more useful when combined with the new traits feature in PHP 5.4.

He illustrates with a package shipping example and uses an "Addressable" Interface to define the structure for both a Company and Users class. He includes code showing how to implement it in a more traditional "implements" way in a class, but also shows an interesting way to achieve the same thing with traits. Having a trait that follows the interface makes it easy to have a class adhere to the interface just by including the trait (or "using" it).

0 comments voice your opinion now!
interface trait tutorial implement use structure


PHPBuilder.com:
Implementing User Defined Interfaces in PHP 5
August 16, 2012 @ 08:35:53

On PHPBuilder.com today there's a new tutorial that talks about creating interfaces in PHP and how to use them to effectively structure your application.

Starting with PHP 5 the object model was rewritten to add features and bring PHP in line with languages such as Java and Visual Basic .NET. In this article I'll discuss interfaces, which is among the most important features in PHP 5. Other important features include abstract and final classes, methods and additional magic methods. You will learn how to define your own interfaces and how to work with them using different object model mechanisms.

The introduce you to some of the basic concepts behind using interfaces and how to create a basic one - a simple definition of a string class with one method, "getString". They then show how to extend a different example (a RandomNumber interface) and add on an additional method. He also shows how to extend multiple interfaces and integrate functionality from multiple sources, overloading and overrides.

0 comments voice your opinion now!
user defined interface php5 tutorial extend implement


PHPMaster.com:
Reusing Implementation - a Walk-through of Inheritance, Composition, and Delegation
July 16, 2012 @ 11:42:54

On PHPMaster.com today there's a new tutorial posted that wants to provide a guide to walk you through a trio of ideas to help with code/idea reuse in your applications - inheritance, composition and delegation.

The popular belief is that reusing implementation, thus producing DRYer code, boils down to exploiting the benefits that Inheritance provides, right? Well, I wish it was that easy! [...] If you don't know what path to travel when it comes to reusing implementation, in this article I'll be doing a humble walk-through on the Inheritance/Composition/Delegation trio in an attempt to showcase, side by side, some of their most appealing virtues and clunky drawbacks.

He starts off with a look at Inheritance, showing with a small code sample showing the creation of an interface and a resulting PDO adapter class implementing it. He also shows the concept of composition, following the ideas of the Adapter pattern. In his Delegation example he shows how to implement the creation of the connection object as a part of the class' creation.

0 comments voice your opinion now!
inheritance delegation composition reuse implement tutorial


Sameer Borate's Blog:
Building a simple Parser and Lexer in PHP
November 17, 2011 @ 11:57:59

In a new post to his blog Sameer Borate shows how to create a lexer and parser in PHP to work directly with the tokens of a PHP script.

After looking around for a while [for a good resource on compilers] I settled for Terence Parr's Language Implementation Patterns. This is exactly what I needed - bit sized patterns on compiler and parser design with working code. The book provides a recipe style approach, gradually moving from simple to complex compiler/parser design issues. As I primarily work with PHP, I thought of porting some code to PHP to see how it works.

He shows examples using his custom tool to show a basic lexer output for a list and a complete listing of the code involved. Ultimately, though, he finds that PHP isn't overly suited to the task - anything more than his simple example could be more trouble than it's worth.

0 comments voice your opinion now!
lexer parser tutorial language implement token


SitePoint PHP Blog:
Sophisticated Object Iterators in PHP
May 05, 2011 @ 12:54:59

Following up on their earlier simple object iterators post, the SitePoint PHP blog is back with a look at more sophisticated iterators you can use to work with database record objects.

In my previous post, Simple Object Iterators in PHP, we discovered how to iterate over array items defined within an object using a foreach loop. However, what if you need to iterate over items which are not stored in an array, e.g. records from a database or lines of text read from a file?

He shows how to create a script that pulls in the users from a database object (PDO, in this case) and implements the Countable and Iterator interfaces. These interfaces give it some special methods that can give counts of the results and help you iterate through the results - current, rewind, next and valid.

0 comments voice your opinion now!
object iterator spl database result pdo countable implement


Jeremy Brown's Blog:
3 Tenets for Implementing a REST API
March 18, 2011 @ 09:17:05

Jeremy Brown, after working tirelessly on a REST API based around the Zend Framework (and a few other technologies), has come up with his three tenets for implementing a REST API to hopefully help you along the straight and narrow path that he forged himself.

In the course of performing my duties at my day job I recently came across the need for our data to be accessible via an API. After researching the various types available, I settled on developing a REST API. The selection process wasn't the interesting part of this exercise though. Actually implementing a REST API is what was.

His advice ranges from the general to very specific, sharing tips on how to most effectively create the service's API:

  • REST is a set of principles (and not a specification)
  • Do not use custom media types
  • Represent the headers in the response payload
0 comments voice your opinion now!
tenet rest api implement zendframework



Community Events











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


podcast opinion install unittest hack hhvm application composer symfony2 database facebook framework language component package security support performance release introduction

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