Dev Shed Articles

Syndicate content
Dev Shed - RSS Feeds
Updated: 37 min 56 sec ago

The Iterator, Countable and ArrayAccess SPL Interfaces

Thu, 2010-03-11 14:00
In this first part of a short series, I'm going to introduce you to using the Iterator, Countable and ArrayAccess interfaces that come with the Standard PHP Library. You'll see how to implement some of the methods declared by the Iterator interface within a class that manipulates MySQL result sets via an intuitive API.
- For many PHP developers eager to apply the object-oriented paradigm in a more thorough and consistent manner, the release of PHP 5 brought a number of handy features that allowed them to achieve this goal in a truly painless fashion. This isnt breaking news, of course, but the inclusion of member ...

Implementing the Data Mapper Design Pattern in PHP 5

Wed, 2010-03-10 14:00
In this first part of a five-part series, I introduce you to implementing the Data Mapper design pattern in PHP 5. This pattern attempts to solve the issue of the strong coupling that often exists between the domain objects present in an application and the underlying persistence mechanism. This benefit comes at a cost, since data mappers add a new layer of complexity. Living with this minor trade-off is quite worthwhile, though, as you'll see.
- Since the web is in constant evolution and merges a variety of technologies and languages, developing web applications (specially mid-sized and large-scale ones) has become a challenging process. Indeed, applications require extensive planning, modeling and testing, before reaching a stable depl...

Defining an Abstract Class with Restrictive Constructors in PHP 5

Tue, 2010-03-09 14:00
In this second part of a four-part series, I rebuild the example application developed in the previous tutorial. As you'll recall, it used a protected constructor to prevent the instantiation of the base array iterator class. In this case, a better result will be achieved by declaring the iterator abstract; still, the example demonstrates a simple utilization of a restrictive constructor in a concrete situation.
- Unquestionably, the introduction of a more robust object model in PHP 5 has provided developers with additional features that allow them to build efficient and thorough object-oriented applications without the need to appeal to the ugly programming hacks used frequently in the bad old days of PHP ...

The Reflection API: Working with Reflected Methods

Mon, 2010-03-08 14:00
This third part of a seven-part series explores the methods of the PHP Reflection API. You will learn how to take advantage of their functionality to retrieve useful information about the methods defined by a reflected class.
- One of today's most powerful approaches for retrieving information about the internal structure of classes and interfaces in PHP 5 is via the language's native reflection API. What's more, not only does this API comes packaged with a huge variety of methods that let developers perform all sorts of ...

Using Restrictive Constructors in PHP 5

Thu, 2010-03-04 14:00
What exactly is a restrictive constructor, and why would you want to use one? If you're a PHP programmer who uses such design patterns as Singleton and Factory, this series of articles on restrictive constructors will give you another tool to use in your applications.
- As you'll probably know, with the release of PHP 5 quite some time ago, the language was provided with the ability to specify the visibility of properties and methods in classes, something that had already been implemented in more mature programming languages such as Java and C++. In a pretty str...

Getting Information on a Reflected Class with the Reflection API

Wed, 2010-03-03 14:00
In this second part of a series, I explore some handy methods of the PHP Reflection API. They allow you to retrieve miscellaneous information about a class, including its name and containing file, as well as its starting and ending lines.
- Overlooked by many developers, the Reflection API that comes with PHP 5 is a powerful reverse-engineering extension of the language that permits developers to analyze, inspect and retrieve valuable information about selected classes and interfaces by means of a set of convenient methods. So, if y...

Introducing the Reflection API in PHP 5

Tue, 2010-03-02 14:00
In this first part of a series, we'll begin exploring some of the methods included with the Reflection API bundled with PHP 5. The interface allows developers to collect relevant information about a reflected class, including its name, its declared constants and properties, in a extremely straightforward way.
- Even though PHP is intrinsically a weakly-typed language, as it doesnt internally impose any constraints on the types of values that can be held by a given variable (with the exception of type hinting and type casting), its introspective capabilities are quite impressive indeed. Native old functio...

Swift Mailer's Batchsend Method and Other Features

Mon, 2010-03-01 14:00
Welcome to the final part of a ten-part series that shows you how to use the Swift Mailer library to build email applications. This final part of the series will explain how to use the batchsend() method, and how to specify the Return-path MIME header within emails.
- Frankly speaking, building a full-featured email application with PHP has always been a challenging task, even for seasoned developers. The process often demands that developers deal directly with the internals of both the SMTP and POP3 protocols, and it's worse if the application must provide su...

Embedding Attachments into Email Messages with Swift Mailer

Thu, 2010-02-25 14:00
In this ninth part of a ten-part series, you'll learn how to use a couple of methods provided by Swift Mailer to directly embed attachments into email messages. These can be very helpful when sending newsletters that contain numerous images, which you dont want to be filtered and discarded by popular web-based email systems such as Hotmail and Yahoo.
- Among the huge variety of email libraries written in PHP 5, there's one that stands out from the rest due to its well-structured programming interface, strict use of the object-oriented paradigm, and (if all of these features aren't good enough for you), its incredibly flat learning curve. Of cours...

Dynamically Attaching Files with Swift Mailer

Wed, 2010-02-24 14:00
In this eighth part of a ten-part series on the Swift Mailer email library, you'll learn how to attach files that have been dynamically generated to an email message. In addition, you'll see how to use Swift Mailer's setFileName() method to modify the name of an attachment before it's sent, which speaks for itself about this library's flexibility.
- In case you havent heard about it yet, Swift Mailer is a comprehensive library written in PHP 5 and freely available at http://swiftmailer.org. It allows you to develop email applications very quickly and with minor effort, through a cohesive and highly intuitive programming interface. So, if your...

Using Different Paths for Attachments with Swift Mailer

Tue, 2010-02-23 14:00
Welcome to the seventh tutorial of a series on Swift Mailer. Comprised of ten parts, this series introduces you gently to using this thorough PHP5-based email package. It complements the corresponding theory with numerous code samples that you can incorporate into your own PHP applications.
- If youre a PHP developer whos looking for an approachable guide that teaches you how to take advantage of the most relevant features provided by the powerful Swift Mailer email library (available at http://swiftmailer.org), then this group of tutorials might be the material that you really need. ...

Handling Attachments and Sending HTML Email Messages with Swift Mailer

Mon, 2010-02-22 14:00
In this sixth article of a series I discuss how to handle file attachments and sending HTML email messages with the Swift Mailer library. As you'll soon see, performing these tasks is a very straightforward process.
- If you're an experienced PHP developer, then you know that coding functions or classes that send MIME email is one of those things that you want to do only once in your lifetime. This process often requires dealing indirectly (or directly, when programming TCP sockets) with the complexities of the...

Sending Blind Carbon Copies with Swift Mailer

Thu, 2010-02-18 14:00
This fifth part of the series expands your background in the Swift Mailer library. You will learn how to use it for sending blind carbon copies of a basic email message to a predefined recipient. The process is as simple as using its setBcc() method.
- Undoubtedly, PHP programmers often need to add some kind of email-sending capability to the programs they create, either by using a proprietary library or by way of a third-party package. While using a custom library (or even a custom framework) may work well when the whole development process of...

Using Swift Mailer's Cc MIME Header

Wed, 2010-02-17 14:00
In this fourth part of a series, you will learn how easy it is to send carbon copies of an email message with the Swift Mailer library. The secret is the use of its setCc() method.
- If youre a PHP developer whos searching for a comprehensive guide that teaches you how to take advantage of the most important features provided by the popular Swift Mailer library, then youve come to the right place. Welcome to the fourth part of a series that introduces you to Swift Mailer. Ma...

Using Sendmail and Mail() with Swift Mailer

Tue, 2010-02-16 14:00
In this third part of the series, I explain how to configure Swift Mailer to work seamlessly with the “sendmail” Unix program and the “mail()” PHP function. This process is extremely straightforward, so you shouldnt have any trouble understanding how it functions.
- Among the great variety of PHP-based email libraries available nowadays, there's one that might be particularly attractive to you. It offers a flat learning curve and impressive features, which have been implemented by using a strict object-oriented approach. In this specific case, of course, I'm...

Using Different SMTP Transports with Swift Mailer

Thu, 2010-02-11 14:00
In this second part of the series, I develop a couple of examples that demonstrate how easy it is to send email messages by using different SMTP servers, thanks to the versatility provided by the Swift Mailer PHP library.
- In case you still haven't heard about it, Swift Mailer is a powerful object-oriented PHP library written by Chris Corbin and available at http://swiftmailer.org. It allows you to develop email applications in a truly effortless fashion by means of a set of comprehensive and well-structured classes...

Introducing Swift Mailer

Wed, 2010-02-10 14:00
Do you want to build a complex email program in PHP that offers more control than the language's native mail() function? You may want to consider using the Swift Mailer email library. This multi-part series will walk you through some of its most useful features.
- If youve been developing web applications with PHP for a while, then youll surely know that the language offers a couple of options that allow you to send email messages in a pretty straightforward way. Undoubtedly, the easiest thing to do is to create email scripts by means of the “mail()” native ...

Managing a Linux Wireless Access Point

Tue, 2010-02-09 14:00
In this conclusion to a five-part series on building a LInux wireless access point, you'll learn how to manage the details, such as DNS caches. This article is excerpted from chapter four of the Linux Networking Cookbook, written by Carla Schroder (O'Reilly; ISBN: 0596102488). Copyright © 2008 O'Reilly Media, Inc. All rights reserved. Used with permission from the publisher. Available from booksellers or direct from O'Reilly Media
- 4.15 Turning Off Antenna Diversity Problem Your wireless interface supports using two antennas, but youre using just one. You know that this means half of your broadcast and unicast packets are hitting a dead end, which can hurt performance. How do you send power only to one antenna? Solution...

Maintaining a Linux Wireless Access Point

Mon, 2010-02-08 14:00
In this fourth part of a five-part series on building a Linux wireless access point, you'll learn about firewalling, routing, and more. This article is excerpted from chapter four of the Linux Networking Cookbook, written by Carla Schroder (O'Reilly; ISBN: 0596102488). Copyright © 2008 O'Reilly Media, Inc. All rights reserved. Used with permission from the publisher. Available from booksellers or direct from O'Reilly Media.
- 4.11 Connecting to the Internet and Firewalling Problem Its high time to finish up with these LAN chores and bring the Internet to your LAN. Your wireless is encrypted, your LAN services are working, and your users want Internet. So youre ready to configure your WAN interface and build a nice s...

Securing a Linux Wireless Access Point

Thu, 2010-02-04 14:00
In this third part of a five-part series on building a Linux wireless access point, you'll learn several different ways to secure your servers, so you can choose the level of security that best suits your needs. This article is excerpted from chapter four of the Linux Networking Cookbook, written by Carla Schroder (O'Reilly; ISBN: 0596102488). Copyright © 2008 O'Reilly Media, Inc. All rights reserved. Used with permission from the publisher. Available from booksellers or direct from O'Reilly Media.
- 4.7 Making WPA2-Personal Almost As Good As WPA-Enterprise Problem Youre nervous about sitting there with an unsecured wireless access point, and you really want to lock it up before you do anything else. Youve made sure that all of your wireless network interfaces support WPA2, so youre ready to...