 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
DevShed: PHP Closures as View Helpers Lazy-Loading File Data
by Chris Cornutt January 30, 2012 @ 13:08:28
In the second part of their look at using closures in PHP as view helpers, DevShed improves upon their original code by adding some additional classes and using them in the closures.
The best way to show you how using anonymous functions can help you to develop more efficient OO applications is with some functional, hands-on examples. With this idea in mind, in the installment that preceded this one, I implemented an extendable template system. This system could spawn view objects and render the template files associated with these objects.
In this second part of the (two-part) series they include "Serializer" and "FileHandler" classes and show how to use them inside of the closures to lazy-load in data from an external file and work with it as serialized content.
voice your opinion now!
tutorial closure lazyload file serialize view helper
Lorna Mitchell's Blog: Building A RESTful PHP Server Routing the Request
by Chris Cornutt January 23, 2012 @ 11:14:11
Lorna Mitchell is back with a second installment in her "Building a RESTful PHP Server" series with this new post about handling and routing the incoming requests. (You can find the first part about working with the request here)
This is the second part of a series, showing how you might write a RESTful API using PHP. This part covers the routing, autoloading, and controller code for the service, and follows on from the first installment which showed how to parse the incoming request to get all the information you need.
She shows how to grab the controller name from the incoming request (based on her previous code), create the object for it and execute the requested action name. Also included is a sample autoloader and a basic controller - a UsersController with "getAction" and "postAction"
methods for responding to GET and POST requests.
voice your opinion now!
restful server tutorial request routing controller get post action
PHPMaster.com: A Tour of PHP.INI
by Chris Cornutt December 12, 2011 @ 10:42:45
On PHPMaster.com today Callum Hopkins has written up an introduction to the php.ini, the heart and soul of any PHP installation. With configuration options for just about everything, it can be confusing. This tutorial hits some of the highs and most commonly updated settings.
Anyone who has a server using PHP has undoubtedly heard of php.ini - it's the configuration file used to control and customize PHP's run-time behavior. It provides a simple way to configure settings. [...] In this article I'll give an overview of some important settings I believe you should be concerned with when tweaking your own php.ini file.
The tutorial's broken up into a few different topics:
- the PHP engine
- Short tags
- Output buffering
- Automatic headers and footers
- Handling errors
- Time zones
voice your opinion now!
phpini configuration tutorial file setting
DevShed: File Security and Resources with PHP
by Chris Cornutt November 23, 2011 @ 16:23:27
In the fourth part of their series looking at working with the filesystem in PHP, DevShed has posted a new tutorial focusing on security and permission handling for files/resources.
These days, security is paramount to any server installation, large or small. Most modern operating systems have embraced the concept of the separation of file rights via a user/group ownership paradigm, which, when properly configured, offers a wonderfully convenient and powerful means for securing data. In this section, you'll learn how to use PHP's built-in functionality to review and manage these permissions.
They introduce functions like:
Sample code is also included to show how to open and close a file.
voice your opinion now!
file security resource permissions function tutorial
PHPMaster.com: Sending Emails with PHP
by Chris Cornutt October 24, 2011 @ 20:08:52
In a new tutorial from PHPMaster.com Jason Pasnikowski takes a look at sending emails with PHP - an introduction to what the language offers and how it can be used to send an HTML version.
In most cases your installation of PHP will be capable of sending emails. If you are using a shared host, or if you installed PHP using a package management system like apt-get, more than likely you're all set. You'll really only need to worry about extra configuration if you're compiling PHP from source or if you're running it on Windows. In either case, there are plenty of resources available online to help you out. Because that's all beyond the scope of this article, I'll assume you're set. If not, Google will be your friend.
He starts with a simple example using the mail function but quickly moves on to sending a multi-part email with an attached zip file and HTML content. He includes the all code you'll need and explains each part in detail so you'll know exactly what's going on.
voice your opinion now!
send email tutorial html multipart zip file
Sameer Borate's Blog: Splitting large MySQL dump files
by Chris Cornutt October 03, 2011 @ 08:44:43
In a new post to his blog Sameer Borate includes a handy bit of code you can use to split up a large MySQL dump file into smaller, easier to digest chunks.
One of the frustrating things with working with MySQL is of importing large sql dump files. Either you get a 'max execution time exceeded' error from PHP or a 'Max_allowed_packet_size' from MySQL. In a recent task I needed to import a table of around a million records on a remote host, which quickly became an exercise in frustration due to various limitations on the server. SSH was of no help as changing the configuration files was restricted to the root user. My last resort was to split the huge 'INSERT' statements into smaller size files.
His script needs a little extra time to run (he sets max execute to 600 seconds) and takes the SQL file in line by line, splitting them back out to over files based on a "count" value - "dump-split-*". Depending on the size of your files, using something like this might not be an option. You might need something more like the command line "split" feature to keep it outside of PHP's memory management all together.
voice your opinion now!
mysql sql dump file split unix multiple tutorial
PHPMaster.com: File Uploads with PHP
by Chris Cornutt September 26, 2011 @ 11:42:40
SitePoint's PHPMaster.com site has a new tutorial today from Timothy Boronczky about handling file uploads in PHP. It's a pretty low-level introduction and is perfect for those new to PHP.
What do pictures in an online photo album, email attachments in a web-based mail client, and data files submitted to an online application for batch processing all have in common? They all rely on the ability to upload files across the Internet from the user's web browser. Indeed, uploading files is an important feature of many of the sites and web-based applications we use on a daily basis. In this post, I show you how to add support for file uploads to your site using PHP.
He starts with the changes you might need to make to your php.ini configuration file (for allowing uploads and setting a temporary directory) and a basic "form" tag with the necessary "enctype" setting. The sample form includes a "file" type field that submits the file data to a waiting PHP script on the backend. The script looks for the submit (in the $_FILES superglobal) and, after doing some filtering on the name and content type, moves it to a new directory.
voice your opinion now!
file upload tutorial introduction security contenttype filter
|
Community Events
Don't see your event here? Let us know!
|