2011年10月31日星期一
PHPMaster.com: Localizing PHP Applications "The Right Way", Part 1
PHPMaster.com has a new tutorial sharing what they call the right way for localizing PHP applications with the help of PHP's gettext functionality.
Localizing software applications in general used to be a cumbersome and error-prone task resulting in a lot of messy code. Some developers even use different versions of code for the same application but for different locales, which makes managing the codebase practically impossible. Enter gettext, the wonderful open-source tool that will make your life easier by allowing you to concentrate on your code. Localization becomes a matter of writing separate translation files for the target language, which can easily be done by a translator using Poedit.
They help you get your environment set up - PHP and a href="http://poedit.net/">Poedit, a gettext catalog editor - for both linux- and Windows-based OSes. They walk you through the creation of a simple project and a few basic "hello world" tokens. Using the files is as easy as setting the correct locale and default domain for your application. Then output is just a basic echo away.
Henri Bergius' Blog: DNode: Make PHP And Node.Js Talk To Each Other
Henri Bergius has a new post to his blog today sharing details about a messaging protocol that can help PHP and Node.js play together nicely - DNode.
Both environments have their strong points. Node.js is very fast and flexible, but PHP has a lot more mature tools and libraries available. So in a lot of projects it is hard to choose between the two. But now you might not have to. DNode is a remote method invocation protocol originally written for Node.js, as the name probably tells. But as the protocol itself is quite simple, just sending newline-terminated JSON packets over TCP connections, implementations have started popping up in other languages. You can talk DNode in Ruby, Perl, Python, Java, and now PHP.
He includes a quick example of both sides of the messaging - a simple server on the Node.js side that looks for a DNode request and using the dnode PHP client to connect to it (and return the input number multiplied by 100). He also includes a method that allows for bidirectional communication with a service that converts from Celsius to Fahrenheit.
PEAR Blog: Newly stable packages in PEAR
The PEAR blog has a recommendation for those that might not have updated their package udage in a while - there's been major changes in many packages, but two in particular.
We've had 60 releases since July. While most are often minor improvements or bug fixes; a number of packages really stand out. Net_DNS2, and HTTP_Request2. Each of these packages represents the second edition of their respective APIs; each having been honed over time to a point of stability.
Net_DNS2 gives you the ability to communicate and resolve host names/domain names inside of a PHP application. HTTP_Request2 gives you a simple way to perform HTTP requests.
2011年10月28日星期五
Site News: Popular Posts for the Week of 10.28.2011
- SitePoint Blog: Book Release - "PHP Master: Write Cutting-Edge PHP Code"
- Community News: CakePHP 2.0 Released (with some Major Changes)
- DZone.com: PHP 5.4 Will Have a Built-in Web Server
- Adam Patterson's Blog: DIY simple staging server.
- Fabien Potencier's Blog: What is Symfony2?
- Brian Swan's Blog: Using SQL Azure to Store PHP Session Data
- Script-Tutorials.com: Creating a Smooth Curve Graphs with PHP and GD
- User Group: New York PHP (Oct 25th @ 6:30pm) - MongoDb & ZendCon
- Justin Carmony's Blog: Setting Up Nginx & PHP-FPM on Ubuntu 10.04
- CodeForest.net: Obfuscate your e-mail address with PHP, JavaScript and CSS
DZone.com: Closure Object Binding in PHP 5.4
In a new post to DZone.com Mitchell Pronschinske looks at closure object binding in PHP 5.4 applications (yes, we know PHP 5.4 isn't released yet). He explains what this is an shows some sample use cases for you to consider in your development.
For the people who read PHP's NEWS file, it's no surprise - but for all who don't here's is probably one of the biggest features of PHP 5.4: Closure Object Support is back. For me it's something I missed the most, when Closures were introduced in PHP 5.3. So I'm very happy, that's finally here (or back). I'm going to tell you about the rocky road which closure object binding support had and show you some simple use cases for it.
The functionality, based on this RFC, lets you more correctly bind closures to objects instead of having to pass the objects into the closure at create time. He includes an example from a Silex framework application and an example that refactors a helper method as a part of rendering a simple template.
XpertDeveloper.com: Abstract in PHP
On the XpertDeveloper.com site today there's a new tutorial talking about something that can not only help the structure of your application but can make things more reusable in the end - abstract classes.
For Abstact keyword we can say that, abstract is type of the class and class which we can't create a object of it. Surprised???? [...] Abstract class can be used some what like an interface in PHP. So basically we can implement class using abstract. We can't extend more than one abstract class while we can implement more than one interface.
They introduce you to the creation of an abstract class and show how to set up some abstract methods inside. These methods are required to be defined as a part of the extension in your class. One of the benefits they don't mention of abstract classes over interfaces is the ability to have methods in the abstract that are actual code, not just definitions of the structure (that's more of what interfaces are for).
Ibuildings techPortal: PHPNW11 Conference Report - Part II
On the Ibuildings techPortal Marco De Bortoli has posted the second part of his summary of this year's PHP North West conference (you can find the first part here). In this part he briefly discusses the tutorial day and the main conference, including the sessions he attended.
This was a very social event from day one, warm and funny with a horde of geeks trying to mix with "normal people" (yes, that can happen if you attend the PHPNW conference, so try not to miss it next year). The best thing about PHP conferences is knowledge-sharing; you won't leave without a hundred different thoughts and ideas of how to do things better. Once again - definitely a good time, both personally and professionally. If you weren't there, you missed out!
The sessions he specifically mentions include the "Security" talk from Arne Blankerts, "Maintainable Applications in PHP Using Components" by Stuart Herbert, "PHP Extensions, why and what?" by Derick Rethans and "Acceptance & Integration Testing Using Behat" from Ben Waine.
2011年10月27日星期四
Site News: Blast from the Past - One Year Ago in PHP
- SitePoint PHP Blog: Speed Up Your Website with PHP Buffer Flushing
- Kevin Schroeder's Blog: You want to do WHAT with PHP? GIVEAWAY
- LogicPool.com: List of PHP and MySQL Code Generators
- PHPClasses.org Blog: Throttling Background Tasks: Unusual Site Speedup Techniques: Part 2
- ProDevTips.com: Multiple File Uploads with XHR and PHP
- Pumka.net: Why MySQL timestamp is 24 seconds different from PHP
- SitePoint PHP Blog: 3 Lightweight Alternatives to phpMyAdmin
- Re-Cycled Air Blog: PHP Dark Arts: Daemonizing a Process
- Brian Swan' Blog: Determining Azure Drive Letter with PHP
- Mike Willbanks' Blog: Zend Framework Cache Backend Libmemcached + Session Cache
- NETTUTS.com: 9 Confusing Naming Conventions for Beginners
- Lukas Smith's Blog: Lets talk about JSON in Symfony2
- Jeff Moser's Blog: Notes from porting C# code to PHP
- PHPBuilder.com: Parsing XML with the DOM Extension for PHP 5
- CodeIgniter.com Blog: What's Happening Now?
PHPMaster.com: Introduction to MongoDB
PHPMaster.com has a new tutorial today for those wanting to get into the MongoDb document-driven (NoSQL) database but haven't known where to start. This tutorial walks you through some of the basics including setup and configuration of both the server and PHP client side.
There are a lot of implementations of the NoSQL concept, but one of the most famous and widely used NoSQL databases is MongoDB. I think it's one of the most interesting NoSQL databases available currently, and it's considered by many to be one of the easiest to use (which has helped it gain widespread adoption). In this article I'll introduce you to NoSQL with MongoDB. You'll learn how to install the MongoDB extension for PHP, and how to add, update, and retrieve document objects.
He starts with an introduction to MongoDB and links to their site to grab the latest version of the database. A few simple steps later (including a call to install the mongo PECL module) and your PHP install is ready to go. Code snippets are included showing how to connect to the server and insert/update/select document records.
PHPClasses.org: Using PHP-GTK to serve Web Applications to HTML 5 Browsers
On the PHPClasses.org blog today there's a new post showing how you can use PHP-GTK to generate websites, not just the more traditional desktop applications people associate it with.
es, you read it right, GTK+, the Gnome Toolkit library, normally used to create desktop applications, can now be used to serve the same applications via the Web to a browser that supports HTML 5 canvas objects. PHP-GTK is a PHP extension that uses the GTK+ library to build PHP desktop applications. So it can eventually benefit for this GTK library enhancements to build PHP-GTK based applications that can be served over the Web to HTML 5 browsers.
Manuel starts by explaining a bit about what PHP-GTK (and GTK+) is and a recent update to GTK+ that allows it to generate output to different backends - Wayland (direct graphics rendering) and Broadway (HTML5 canvas support). There's no example code to go along with the post, but there's a good description of how the output of an X Windows session could be pulled in and displayed in a browser (see this video for a cool example using GIMP and Broadway).
PHP.net: PHP 5.4 beta2 released
The PHP.net site has a new announcement about the latest version of the language in the PHP 5.4.x series - beta 2 has been released for testing.
The PHP development team is proud to announce the second beta release of PHP 5.4. PHP 5.4 includes new language features and removes several legacy (deprecated) behaviours. Windows binaries can be downloaded from the Windows QA site. [...] Please help us to identify bugs by testing new features and looking for unintended backward compatibility breaks, so we can fix the problems and fully document intended changes before PHP 5.4.0 is released. Report findings to the QA mailing list and/or the PHP bug tracker.
Remember - this is not a production release, so do not use it in your live applications (unless you really like to live dangerously, of course). You can look at the NEWS file for a complete list of changes.
2011年10月26日星期三
DZone.com: Debate - How to Interface the PHP World
In a new post to DZone.com today Mitchell Pronschinske responds to some comments that were made by Lukas Smith about working with interfaces in PHP and what he sees as an ideal "drop in" solution.
The PHP community was reacting to Lukas Smith's "Interfacing the PHP world" for most of last weekend. [...] It's a pretty major propositon to start 'interfacing the PHP' world. Catch up on the conversation and let us know what you think.
Mitchell summarizes Lukas' thoughts into three points - interfaces in separate repositories, PHP frameworks not adopting 5.3 yet and the customization of method names/naming conventions across frameworks and tools. Another response to Lukas came from Herman Radtke with Lukas following up his original post with "Why Bother?"
Symfony Blog: All symfony 1.x versions available on Github
Fabien Potencier has made an announcement on the Symfony Blog today about all the availability of previous Symfony versions on github.
symfony1 is well and alive and many developers are now using it for projects hosted on Git. But as the official symfony 1 repository is hosted on Subversion, it's not always easy to get things versioned easily. As of today, this becomes much more easier. If you are using Git and symfony1, you can now use the official symfony1 Git clone.
There are branches for each of the major 1.x releases as well as tags for some of the minor releases. You can, of course, still access the latest packages directly via the symfony website.
2011年10月25日星期二
PHPMaster.com: Sending Emails with PHP
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.
User Group: New York PHP (Oct 25th @ 6:30pm) - MongoDb & ZendCon
For those that will be in the New York City area tomorrow night (10/25), Daniel Krook has something you should consider attending - the New York PHP User Group is having a meeting with a talk on MongoDB (and a ZendCon Recap).
PHP on IBM System i consultant Alan Seiden will give us an update on what transpired at last week's ZendCon. 10gen MongoDB evangelist Steve Francia will provide an overview on using PHP with MongoDB.
You'll need to RSVP to get a spot or, if you can't make it in person, you can always watch the live stream starting at 6:30pm.
Have a user group meeting you'd like to let the community know about? Let us know!
Maarten Balliauw's Blog: Running Memcached on Windows Azure for PHP
Maarten Balliauw has a new post to his blog with a guide to running mamcached on Windows Azure for PHP, a tool targeted towards PHP on Windows users to provide them with the ability to cache outside of their application.
While Windows Azure offers a distributed caching layer under the form of the Windows Azure Caching, that components currently lacks support for non-.NET technologies. I've heard there's work being done there, but that's not very interesting if you are building your app today. This blog post will show you how to modify a Windows Azure deployment to run and use Memcached in the easiest possible manner. Note: this post focuses on PHP but can also be used to setup Memcached on Windows Azure for NodeJS, Java, Ruby, Python...
He provides a phar-based scaffolding you can use to set up the instance and describes two ways of accomplishing it - the "short way" of relying on the scaffolding or the "long way" describing what the scaffolder does behind the scenes (complete with code). For this, you can also download the source and look through it.
Lukas Smith's Blog: Why bother?
Lukas Smith has put together a recent post to his blog with some thoughts on standardization of interfaces in PHP applications to help improve code quality and interoperability.
In my previous blog post I was brainstorming the possibility of collaboration between various frameworks to define a set of common interfaces. But I kind of failed to explain why this would be useful. Herman's "rebuttal" made this omission on my part quite clear. [...] That being said the open questions left in my previous blog might still prevent this idea to take off, even if I manage to convince the general community that the above mentioned negative effects are not such a significant concern.
He talks first about some of the things he sees PHP as having done right (citing its popularity) and contrasts it to Java based on the standards they impose. He goes on to mention how interfaces, introduced early enough in the process, can help with the "best tool for the job" idea (with an example involving Symfony2, Zend Framework and Doctrine).
Hasin Hayder's Blog: Developing PHP applications in the cloud with free cloud hosting providers
Hasin Hayder has put together a list of cloud hosting providers that are already set and ready to go for PHP applications. His list highlights a few of the free ones.
I will be focusing on some of these free cloud hosting options available out there. One thing to note before you proceed - these free cloud hosting options are very good to develop and test your applications (in dev+staging environment) and it may not be wise to deploy the production version of your application with any free plan (Except Amazon AWS's free tier, its production ready).
He has four different services on his list, ranging anywhere from small to industrial strength, depending on your needs:
- Amazon's AWS
- PHPFog
- PHPCloud (from Zend)
- Heroku (traditionally Ruby, now supports PHP too)
PHPMaster.com: Understanding OAuth - Tweeting from Scratch, Part 2
On PHPMaster.com today they're posted the second part of their OAuth series showing you how to use the authentication mechanism to connect to Twitter's API. (Part one is here.
Welcome back to Understanding OAuth - Tweeting from Scratch. This is Part 2 of the two-part series and picks up right where we left off in Part 1 with your returned Access Credentials. Since obtaining the credentials is the grueling part of the process, there's not much more left to do except posting a tweet on the user's behalf. Hopefully you'll find the final steps to be a lot easier to follow and more fun to implement.
They show you how to store the credentials from Part 1 into your session for safe keeping and include a simple form you will use to send a tweet to Twitter. They choose to manually build the HTTP POST request, including the credential headers along with the payload (oauth_consumer_key, oauth_signature, oauth_token, etc).
2011年10月24日星期一
Ken Guest's Blog: A new Openstreetmap API framework for PHP
Ken Guest has a new post today talking about a PEAR package he's been developing, Services_Openstreetmap, to interact with the OpenStreetMap service to make it simpler to work with OSM data, adding new locations and working with users.
So over the last while, I've been working on a PHP package imaginatively named Services_Openstreetmap, for interacting with the openstreetmap API. I initially needed it so I could search for certain POIs and tabulate the results; it's now also capable of adding data to the openstreetmap database - nodes and other elements can be created, updated and so on. It will even access the details of the user that is being used to modify that data, which is one difference between it and the other single purpose OSM frameworks.
He's submitted it to PEAR for official inclusion. Until then, you can download the package from github. The OpenStreetMap project is a community-driven mapping tool that allows users to provide new map information or make updates in an effort to keep things more up to date.
DZone.com: PHP 5.4 Will Have a Built-in Web Server
As is mentioned in this new post to DZone.com, one of the features of the upcoming PHP 5.4 release, including things like traits and array dereferencing support, will also have an interesting new feature - a built-in simple web server.
Yet another new feature to look forward to in PHP 5.4.0 - the CLI SAPI will now provide a built-in web server which is geared toward developmental purposes. It shouldn't be used in production right now.
The PHP manual has been updated with the latest on this upcoming feature:
URI requests are served from the current working directory where PHP was started, unless the -t option is used to specify an explicit document root. [...] If a PHP file is given on the command line when the web server is started it is treated as a "router" script for the web server. The script is run at the start of each HTTP request. If this script returns FALSE, then the requested resource is returned as-is. Otherwise the script's output is returned to the browser.
The PHP 5.4.x series is still in beta as of the time of this post - you can download the beta1 on the downloads section of the PHP site (or the Windows binaries).
2011年10月21日星期五
Site News: Popular Posts for the Week of 10.21.2011
- Reddit.com: Which MVC framework has the best documentation and user community?
- Developer Drive Blog: How to Prevent a SQL Injection Attack
- DevShed: Service Layers in PHP Applications (a Series)
- NetTuts.com: The Ins and Outs of PHP Exceptions
- DeveloperDrive.com: What Web Developers Need to Know About Cross-Site Scripting
- DeveloperDrive.com: Common Mistakes to Avoid When Coding in PHP
- Site News: Popular Posts for the Week of 10.14.2011
- Smashing Magazine: Getting Started With PHP Templating
- Sameer Borate's Blog: Grabbing the referrer search engine keywords for a site
- php|architect: ZendCon 2011: Pre-cap
Brian Swan's Blog: Using SQL Azure to Store PHP Session Data
In a recent post to his blog Brian Swan takes a look at working with sessions in PHP and, specifically, how to save them to Azure along with all of their data.
In my last post, I looked at the session handling functionality that is built into the Windows Azure SDK for PHP, which uses Azure Tables or Azure Blobs for storing session data. As I wrote that post, I wondered how easy it would be to use SQL Azure to store session data, especially since using a database to store session data is a common and familiar practice when building distributed PHP applications. As I found out, using SQL Azure to store session data was relatively easy (as I'll show in this post), but I did run into a couple of small hurdles that might be worth taking note of.
He uses PHP's own session_set_save_handler to point to his custom Azure handling class with the needed methods (like write, close and destroy). He breaks it out into three simple steps, some with a bit of code attached:
- Create the database, table, and stored procedure
- Add the SqlAzureSessionHandler class to your project
- Instantiate SqlAzureSessionHandler before calling session functions as you normally would
The code for the Azure handling class can be downloaded here.
SitePoint Blog: Book Release - "PHP Master: Write Cutting-Edge PHP Code"
As is mentioned in this new post to the SitePoint blogs, a new book has been released (by SitePoint press, naturally) about "writing cutting-edge PHP code" by a few well known authors in the PHP community - Lorna Mitchell, Davey Shafik and Matthew Turland.
Savvy PHP web developers can now keep ahead of the game and ensure that their PHP code is safe, secure, and well-structured for the future with the latest release from SitePoint: "PHP Master: Write Cutting-edge Code"
by Lorna Mitchell, Davey Shafik, and Matthew Turland.
The book covers a wide range of topics (somewhat replacing SitePoint's usual "anthology" type of book) including:
- An introduction to OOP
- Working with databases
- Creating and working with APIs
- Design patterns
- Security
- Automated testing
As part of a special offer, you can pick up your print+ebook bundle for the price of just the book, about $40 USD. If you'd like a sample before purchasing, they've posted three sample chapters.
Adam Patterson's Blog: DIY simple staging server.
Adam Peterson has posted an interesting idea for those out there running an internal staging server they want to constantly keep up to date with the main line of code (without manual intervention) - a git pull web frontend combined with git post-receive hooks.
This [move from svn to git] left a bit of a gap in my process where I could no longer test on a remote server without updating it manually by S/FTP or opening terminal and manually calling a git pull. Open terminal and manually git pull it did break up the work flow a bit so using the Dingo framework I created a very simple Git helper and gave it its own URL something like git/pull.
He added a post-receive hook to his git server that calls this "git/pull" URL on the staging server and updates the code on the server. This provides an easy asynchronous way to update things on another server. Note, though, that this should never be done on a publicly accessible server - it's a pretty large security hole (or at the very least made secure somehow). He used Dingo to create his interface, but something like the Slim micro-framework could have worked just as well. You can view his code on github.
2011年10月20日星期四
Site News: Blast from the Past - One Year Ago in PHP
- Josh Holmes' Blog: Zend SimpleCloud and Azure
- Smashing Magazine: Common Security Mistakes in Web Applications
- Vance Lucas' Blog: Practical Uses for PHP 5.3 Closures
- Paul Jones' Blog: PHP Framework Benchmarks on Github
- Phil Sturgeon's Blog: CodeIgniter 2.0 is stable (enough)
- Zend Developer Zone: File uploads with Adobe Flex and Zend AMF
- PHPBuilder.com: Enforcing Coding Standards with PHP_CodeSniffer
- Site News: Popular Posts for the Week of 10.22.2010
- HowToForge.com: Installing PHP5 Debugger On OpenSUSE 11.3
- Reddit.com: Today I learned about variable variables...
- PurpleRockScissors.com: Avoiding Cache Stampedes with Pseudo-Locks
- Leszek Stachowski's Blog: php anachronic coding standards
- VoidWeb.com: PHP Clustering using Apache httpd mod_proxy
- SitePoint.com: OAuth for PHP Twitter Apps, Part 2
- Zend Developer Zone: Create APIs with FRAPI
Community News: Zend Announces phpcloud.com (development/deployment platform)
As mentioned in this post to The Register, Zend, a large player in the PHP market, has announced their own cloud-based platform for deploying PHP-based applications - phpcloud.com.
Zend has announced a cloud for building and deploying PHP apps on other clouds - but without the management hassle. The PHP specialist has announced phpcloud.com, which it said was a technology platform and a partner ecosystem based on the company's Zend Framework and Server. Details are vague, but the technology platform consists of Zend App Fabric and Zend Developer Cloud. The App Fabric uses the Zend Framework - a library of loosely coupled PHP components - with Zend's PHP stack and management and diagnostics tools.
The platform comes with features for caching, job queuing, high availability and code traces (among others). It plays especially nice with Zend's Studio development tool. The site, phpcloud.com has full details on what the platform offers and how you can get started with it quickly and easily with a free developer account.
PHPMaster.com: PHP Namespaces
One of the features that's recently been introduced into the PHP language has been a feature for keeping code not only more organized, but more modular - namespacing (PHP 5.3+). In this new tutorial from PHPMaster.com they introduce you to this handy feature and include a bit of code showing their use.
Namespaces were a long awaited feature in PHP. While many other important features were released with PHP 5, namespaces were not supported until version 5.3. This led to various techniques for emulating them which, though necessary, were messy and confusing. Although namespaces have been part of PHP for over a year now, such techniques still exist. Many developers simply don't know how to use proper namespaces in their code. In this article I will explain why namespaces are important and how you can use them in your own PHP code.
He starts off by talking about what namespaces are and how they can be used to segment up applications, especially larger ones, into more manageable chunks. Basic code is included showing how to implement a namespace, referencing items inside a namespace, the "use" keyword and the __NAMESPACE__ magic variable.
Ibuildings techPortal: PHPNW11 Conference Report
Marco Lopes has posted a wrapup of the PHP North West conference that he recently attended in Manchester. In it he talks about the tutorial sessions he attended the first day as well as the other shorter sessions later in the conference. His is the first summary of several Ibuildings employees that made it to the event.
He covers the content presented by Arne Blankerts (of ThePHP.cc) about general applications security. His session covered security on various levels, not just in the PHP code - hardware, XSS, session hijacking, captchas, database issues and clickjacking. Marco's afternoon was spent at Lorna Mitchell's web services tutorial. Sessions attended on Day 1 included the keynote from Ian Barber, Sebastian Marek and Rowan Merewood.
2011年10月19日星期三
Rob Allen's Blog: Updated tutorial for Zend Framework 2 beta 1
Rob Allen has a quick note for fans (or those just discovering) his "Getting Started with Zend Framework" tutorial - he's posted an updated version for ZF2 beta 1.
Getting started with Zend Framework 2 (beta1), creates the same application as my ZF1 tutorial, so it should be very familiar, but this time, it's in the context of Zend Framework 2. As usual, it's a PDF too.
This latest version gives you a gentle introduction to the framework and steps you through the creation of a sample music inventory system. It includes code and explanations of how set up modules, controllers, models and views and how to tie them all together. If you're new to the framework and want to get off and running quickly, I'd highly recommend his tutorial.
DeveloperDrive.com: Common Mistakes to Avoid When Coding in PHP
On the DeveloperDrive.com site today, there's a new post with a few reminders for PHP developers out there of things it's easy to forget when writing your applications - some common mistakes to avoid.
Despite the high expectations placed on them at times, developers are human. They were the last time we checked anyways. As humans, we are bound to make mistakes from time to time. And simple, common mistakes often slip past our filters the more comfortable we become with something. [...] But knowing what these common mistakes are and how to avoid them can really help speed up the development process and keep our clients smiling.
His list includes three big ones that, if forgotten, could end up being detrimental to your application (sooner or later) - poor housekeeping/organization of code, forgetting punctuation and forgetting to validate input from users.
2011年10月18日星期二
DevShed: Service Layers in PHP Applications (a Series)
DevShed has posted a series of tutorials talking about different sorts of service layers in PHP applications - seven of them to be exact:
If you're looking for an approachable guide that teaches you how to implement an easily-customizable service layer in PHP, then take a peek at this article series. In a step-by-step fashion, it walks you through the development of a sample web application, which uses a service to perform CRUD operations on a domain model composed of a few user entities.
Service layer types covered in the series are:
Smashing Magazine: Getting Started With PHP Templating
On the Smashing Magazine site today there's a new post introducing you to templating in PHP applications. They cover both the creation of a simple, custom templating library as well as using a more widely known too - Twig.
In this article, we'll cover how to separate the view of your PHP application from its other components. We'll look at why using such an architecture is useful and what tools we can use to accomplish this. [...] To fully benefit from this article, you should already know how to write and run your own PHP scripts on a Web server (i.e. using Apache).
They start with the very basics of templating, mostly pointing out how it reduces the dependency of having layout code directly in your application's logic. It makes things easier to reuse and makes for better code structure in the long run. They mention other templating engines like Smarty, PHPTAL and Twig, but focus in on the last for their code samples. They show basic templating, making reusable templates, applying filters and working with simple control structures.
PHPMaster.com: Understanding OAuth - Tweeting from Scratch, Part 1
PHPMaster.com has posted the first part of a new series they're presenting on working with OAuth in PHP, specifically using it to connect to the Twitter API. This first part of the series introduces you to the concepts of OAuth and some early code to work with user credentials.
A common complaint about OAuth is that it is very difficult to understand, but perhaps some of that confusion is because of an expectation that the abstraction provided by a third-party library will erase the need to understand the steps of an OAuth transaction - it does not. This two-part article demonstrates how OAuth v1 works by explaining the process of connecting a PHP application to the Twitter API using only a few built-in functions to post a message to a user's Twitter stream.
The process is broken up into two steps - first you'll need to set up the request credentials so your application can connect to the Twitter service (as created here) then use that connection to fetch the rest of the necessary credentials (three total: Consumer, Request and Access Credentials). Cut and pasteable code is provided.
2011年10月17日星期一
PHPMaster.com: Integrating Amazon S3 using PEAR
On PHPMaster.com today there's a new tutorial showing you how to integrate Amazon's S3 service with your application via the Services_Amazon_S3 PEAR package.
In the process of reviewing documentation for Orchestra.io, I found that it doesn't allow file uploads. Instead, it's recommended that Amazon S3 be used for file hosting. If you aren't familiar with it, S3 is an online storage web service that is part of Amazon Web Services (AWS). It provides access to fairly cheap storage through a variety of web service interfaces. This article will demonstrate how to sign up for an Amazon S3 account and use PEAR's Services_Amazon_S3 package to interact with S3 in your own application.
They walk you through the whole process - getting signed up at the AWS site, creating credentials, installing the Services_Amazon_S3 package (via the PEAR installer) and using it in some sample scripts.
NetTuts.com: The Best Way to Learn PHP
On NetTuts.com today there a new article with what they think is the best way to learn PHP in a list of thirteen different "assignments".
Learning something from scratch is almost always an arduous affair - you simply have no idea as to where to start, or not to start, to kick things off. I loathed learning about the idiosyncrasies of C++'s syntax when all I wanted to learn were some darn programming concepts. As I'm sure you can agree, this is a less than ideal situation. [...] Today, we're going to figure out the best way to learn PHP.
Among their list of "assignments" are things like:
- Disregard the Naysayers
- Read a Few, Good Books
- Create Something Simple
- Try out a Lean, Lightweight Framework
- Build Something Awesome
- Get Involved and Be Up to Date
There's also some good comments with suggestions of other frameworks to learn, things to try out and a few comments that put an emphasis on learning the language before diving directly into a framework.
php|architect: ZendCon 2011: Pre-cap
On the php|architect site today Keith Casey has posted a ZendCon pre-cap (the conference starts today in Santa Clara, CA) talking about some of what's to come during the week for attendees - five sessions he personally is interested in.
Yet again, it's that time of year. Later today we have the kick off of the seventh ZendCon (officially called the Zend PHP Conference). This year I'm hitting the event under the php|architect banner as press. It will be my job to cover the good, the bad, the news, the chaos, and generally the things that come from the conference that might change your job on a day to day basis.
From the 70ish sessions being presented over the next few days, he highlights ones dealing with scaling applications with Redis, event-driven programming, dependency injection, character sets and API security. If you have been planning on attending and getting in on some of these great sessions, there's still time - you can still pick up a ticket at the door of the Santa Clara Convention Center.
2011年10月14日星期五
Site News: Popular Posts for the Week of 10.14.2011
- Anson Cheung's Blog: 8 essential checks on securing PHP
- Symfony Blog: Symfony2 Security Audit
- WebInOne.net: Date validation for CodeIgniter 2
- Stephen Colebourne's Blog: Time-zone database down
- PHPMaster.com: Generating Invoices with Zend_Pdf
- php|architect: Why Software Fails
- Abou Kone's Blog: Set up JSON action output in CakePHP 1.3
- Christian Schaefer's Blog: Using PHP Web Scraper Goutte in a Console Task in a Silex project
- Lineke Kerckhoffs-Willems' Blog: ProTalk - Audio/Video Tutorials for PHP Developers
- Script-Tutorials.com: Autocomplete with PHP, jQuery, MySQL and XML
NetTuts.com: The Ins and Outs of PHP Exceptions
On NetTuts.com today there's a new tutorial showing you the "ins and outs" of using exceptions in PHP - throwing them, handling the result and integrating them into your error handling process.
Still returning false whenever a function in your program fails? In this article, we'll learn about PHP exceptions, and how you can use them to soup up your application's error handling.
The include some of the methods you can call on your exceptions (including getting the message, code, file, line and the results of a debug_backtrace right before it was thrown). Included is code to throw exceptions, catch them with a try/catch and using error codes as return values and extending them to fit your own needs.
Developer Drive Blog: How to Prevent a SQL Injection Attack
From the Developer Drive blog there's a recent post with some suggestions on how you can help to prevent SQL injections in your PHP application and make it that much harder for would-be attackers to do what they shouldn't.
Why do SQL injections happen so often?
The shortest answer is that SQL injections are so popular because of poor programming. Hackers know about the potential of a successful SQL injection attack and they search for vulnerabilities. Unfortunately, very often they don't have to search hard - vulnerabilities pop right in their face. [...] The good news is that fortunately, SQL injections are also relatively easy to prevent.
They list nine easy things you can do to help prevent the attacks:
- Patch your SQL server regularly
- Limit the use of dynamic queries
- Escape user input
- Store database credentials in a separate file
- Use the principle of least privilege
- Turn magic quotes off
- Disable shells
- Disable any other DB functionality you don't need
- Test your code
Reddit.com: Which MVC framework has the best documentation and user community?
On Reddit.com there's a new post that asks the question, "which framework has the best documentation and community?"
About to dive into MVC and wondering which one has the most wealth in terms of documentation/code comments as well as a decent community.
Suggestions in the comments include both old and new options including:
2011年10月13日星期四
Site News: Blast from the Past - One Year Ago in PHP
- Sebastian Bergmann's Blog: The German Edition Started Shipping!
- PHP-Code.net: Securing PHP Apps Part III - Securing PHP on the server/Securing MySQL & Apache
- UncleCode.com: Install PHPUnit Manually without Pear for a Single Project
- Lorna Mitchell' Blog: Best Practices in API Design: Audio and Slides
- Jay Allen's Blog: Adminer | The World's Smallest MySQL Admin Script
- CodeForest.net: How to crop an image using jQuery and PHP
- Zend Developer Zone: Passing the ZCE PHP 5.3 certification exam!
- UltraVisual Blog: Running PHP Eclipse with FDT / FB & Ant
- Symfony Blog: Symfony Live 2011: Paris & San Francisco
- AjaxRay.com: Setting up Database testing with Kohana UnitTest module
- Gonzalo Ayuso's Blog: Speed up PHP scripts with asynchronous database queries
- Cormac' PHP Blog: Practical example php implementation of the Observer pattern
- Iwan Luijks' Blog: Using Enchant with PHP on Windows - Part 1
- Rob Allen's Blog: A form in your layout
- ServerGrove.com: Creating console commands with Symfony2
Brian Swan's Blog: Why is PHP 5.3 on Windows faster than previous PHP versions?
In a new post to his blog Brian Swan explains why the latest versions of PHP (the 5.3.x series) are faster now on Windows than some previous versions have been. (Hint: updated technology can work wonders sometimes)
[Rasmus Lerdorf recently said at a Seattle meetup] "If you aren't running PHP 5.3 on Windows, you're lucky…because you have a 40% performance boost coming." He clarified this by saying that, with some help from Microsoft, improvements were made in PHP 5.3 that led to a 40% performance improvement of PHP on Windows. Because he didn't go into the details of why this performance boost was realized, I got questions in email the next day asking about why.
The information in a borrowed slide (from a presentation by Pierre Joye) shows what the differences between the versions are - things like the use of a more modern compiler (VC9 vs VC6), calls to the Win32 API directly and better library management.
Padraic Brady's Blog: Zend Framework 2.0: Dependency Injection (Part 2)
Padraic Brady is back today with the second part of his "Dependency Injection in Zend Framework 2.0" series. In this second post he talks about what dependency injection containers are (and aren't) and how they could lead to bad practices if they're considered as service locators.
For Part 2, we're going to dig more into what a DIC is and isn't. I've already noted one very simple DIC called Pimple which will continue as one of my reference points since it best illustrates just how simple a DIC can be. In Part 3, we'll (finally) turn our attention to some actual source code. Baby steps. Parts 1 and 2 should get you thinking so that ZF 2.0′s DIC is a lot easier to understand and critique. We don't want anyone panicking just by throwing them into the deep end.
He talks more about the Pimple DIC tool and how, despite it's similarity to a set of Factory pattern calls, it's slightly different - think of it as "a container of executable Factories". He introduces the concept of a Service Locator, an object that can find and load other objects in an intelligent way. He notes that the most ideal DIC is an "external agent" that defines the object relationships outside of the application.
He points out a feature of ZF2 that allows for injection of the DIC into a controller, allowing it to look up the resources it needs. This of course, has issues - three that he mentions specifically:
- Firstly, this isn't Dependency Injection.
- Secondly, it creates objects which are useless without the specific DIC interface it depends on.
- Thirdly, DICs are really bad Service Locators.
2011年10月12日星期三
Script-Tutorials.com: Autocomplete with PHP, jQuery, MySQL and XML
In this new tutorial from Script-Tutorials.com they show you how to combine PHP, jQuery, MySQL and XML to create an auto-complete box with drop-down suggestions.
Today I have new article for PHP. I will tell you about implementation autocomplete for your sites. Data can be located in different sources - directly in the JS code, in the database, and even in the XML file.
All of the code and markup you'll need is included - the HTML for the page containing the field, CSS to style it, the Javascript (jQuery) to make the field work and the SQL/PHP/XML for the backend. You can check out a live demo of the script in action here or download the source in a single package and get started.
ZendCasts.com: PHAR Out Autoloading
On the ZendCasts.com site there's a new screencast posted looking at autoloading in phar, the packaging tool built into PHP. This is a continuation of the series started here.
Building on the foundation from the previous screencast, he shows how to enhance it and allow it to autoload based on an autoloader defined in a "stub.php" file.
You can grab the complete source for this screencast over on github.
PHPBuilder.com: PHPBuilder.com Founder Passes Away, Leaves Indelible Legacy in FLOSS Development
Sad news today from PHPBuilder.com - Tim Perdue, the founder of the PHPBuilder.com site and contributor to the SourceForge project as one of the original developers has passed away at 37.
The PHPBuilder staff was saddened to learn that the founder of our site, Tim Perdue, passed away on September 16 , 2011, after a battle with cancer. At only 37 years of age, Tim's passing came much too soon, but his contributions to the PHP and open source communities assure him a lasting legacy.
Related posts include this tribute from his company, GForge and this article from Jake Ludington on LockerGnome. Digging through our own archives, I found this interview with him back in 2002 (an archive.org link, the original is no longer there).
2011年10月11日星期二
PHPMaster.com: Array Handling Functions
On PHPMaster.com today there's a new tutorial introducing you to the array handling features in PHP - sorting, slicing and more.
In my previous article on PHP arrays I suggested a number of things that are tables and therefore can also be expressed as arrays. In this article I'll use a pack of playing cards to explore some of the built-in array functions most often needed by PHP programmers.
To highlight some of the array-handling functions PHP offers, I'll be using some components of Buraco - a game very popular in my part of the world and quite similar to Rummy.
In the example he represents a deck of cards with an array of values like "A", "03" and "13". This array is then looped to make the full set of 52 cards and shuffled to deal a "hand". Array functions put to use include array_rand, in_array and sort.
php|architect: PHP is not a Swiss Army Knife, quit calling it that.
New on the php|architect site today, there's a post from Cal Evans with his opinion of the PHP language - "it's not a Swiss Army Knife, quit calling it that."
I've heard a lot of people compare PHP to a Swiss Army Knife. You know the ones, 5 blades, a corkscrew, a saw…and the obligatory toothpick that you will lose so you might as well take it out now and just throw it away. Why anyone would consider PHP to be like this is beyond me. [...] A Swiss Army Knife undergoes a lot of design work before it is released. It is well designed. [...] A Swiss Army Knife is polished and refined. [...] No, PHP is none of those things, it is not purposefully designed, it is not polished, and it is not bulky.
In his opinion, if PHP was any tool, it'd be more of a screwdriver - the good kind that's stood the test of time and has worked again and again, despite what was demanded. He points out that yes, you can do stupid things with PHP, but that's true of any language - quit blaming the language for your bad mistakes.
PHP is a more widely used language on the web for one very good reason, when you need to get something done, it's always there in your toolbox, ready for you to take out, abuse in new ways and then put away.
Hartmut Holzgraefe's Blog: PHPReboot Braindump
In this new post to his blog Hartmut Holzgraefe looks at a new effort that wants to be "the next PHP" while still being PHP. Confused? Take a look at PHPReboot.
PHP.reboot is a reboot of PHP, each Hollywood movie has its own reboot, why not doing the same for one of the most popular programming language. The aim is to keep the philosophy of PHP but adapt it to be more in sync with the Web of 2010.
Hartmut's post is a "braindump" of some of his thoughts about the project including responses to some of its main claims:
- less $, less ';' like in javascript
- secure by default: no eval, no magic quotes/string interpolation
- full unicode support
- a SQL compatible syntax
- URI/file literal
In his opinion, the language doesn't look much like PHP anymore and would not only be incompatible with current PHP but also wouldn't benefit from the C libraries PHP has access to.
...so why should it have the letters PHP in its name at all?
2011年10月10日星期一
Christian Schaefer's Blog: Using PHP Web Scraper Goutte in a Console Task in a Silex project
In a recent post to his blog Christian Schaefer shows how to use the Goutte tool (a web scraper) to pull information from one site and use it in another Silex-powered one. His tutorial uses a custom service provider for the integration.
Since I discovered the free Facebook App hosting by heroku I keep wanting to make something useful out of it. So I thought about a small service app. Without going into details yet about its nature there was one immediate problem to be solved. How to get hold of the data? So I thought to scrape it off some website. I know this isn't very nice but unfortunately there is no feed I can use.. And how to best scrape a website? Use Goutte!
All you'll need is two things - the goutte.phar and Silex phar files. The code for the service provider is a simple registration of namespaces. With that integrated, it's as simple as making a client object and calling it with a URL.
PHPMaster.com: Generating Invoices with Zend_Pdf
On PHPMaster.com today there's a new tutorial about using the Zend_Pdf component of the Zend Framework to generate invoices from the billing data in your application.
The PDF format is currently the most used format to exchange documents. If you provide your website users with printable versions of invoices, event tickets and other similar documents, you'll most likely want to generate them as PDFs on the fly. In this article you will see how you can use Zend_Pdf to auto-generate PDF invoices.
The concept is pretty simple - take the rows of invoice data from your system and inject them into a new PDF document. They show you how to create an invoice layout that includes that data, a header with your company name, invoice-related information and the total/amount due at the bottom. The full code is included to help you create the Zend_Pdf object, apply the text to it (based on location in the document) and working with the default font. You can download the full source from github.
php|architect: Why Software Fails
On the php|architect site today there's an opinion piece from Marco Tabini with his thoughts on why software fails - not why the project itself fails, but why the software fails to be useful.
This is a much more common problem than engineers and architects are willing to admit. Far too often I see someone in charge of writing a piece software worry about how a product works without paying so much as a passing thought to whether it actually works the way people expect it to. The truth is that we are, by and large, stuck in a reality where software somehow equates with automation.
He goes on to talk about how easy it is for us, as developers, to forge head with features and software that may not be useful to the masses. We worry more about solving a problem that may or may not actually be there. He illustrates with the example of a to-do list, providing the automation to make list tracking easier, but no guidance of how the user can make use of it effectively.
2011年10月7日星期五
Site News: Popular Posts for the Week of 10.07.2011
- Johannes Schlüter's Blog: MySQL Query Analyzer and PHP
- PHPClasses.org: Lately in PHP Episode 16 - APC in PHP, MODX CMS, Top Developers
- Evert Pot's Blog: iconv_substr vs mbstring_substr
- PHPMaster.com: Introducing Superglobals
- Reddit.com: In Web Development is it better to be a Expert or All-arounder?
- Community News: CodeWorks 2011 Early Bird Pricing Ends Today
- ZendCasts.com: Fun with Phar
- Anson Cheung's Blog: Optimize Web Site Performance by using YSlow
- Web Species Blog: We built a cloud platform for PHP. Wait...what?
- Stuart Herbert's Blog: Installing Phix on Various OSes (OSX, Debian, Ubuntu, Fedora)
Abou Kone's Blog: Set up JSON action output in CakePHP 1.3
Abou Kone has a recent post to his blog showing the CakePHP users out there how to set up JSON output for your actions in a few simple steps.
Working on setting up the Rest Plugin for CakePHP helped me realize that i wanted to set up JSON output for some of my actions. This way, if you request for example "www.yourapp.com/app/post/view/1.json" in the url, you will be returned the JSON post data. This excellent tutorial here will help you achieve it.
Changes include updates to configuration for routing, using the RequestHandler component and setting your actions to output the data correctly when the ".json" is detected on the request.
Symfony Blog: Symfony2 Security Audit
Fabien Potencier (of the Symfony framework project) has posted the results of a security audit that was performed on the framework by SektionEins.
The Symfony2 core team takes security issues very seriously; we have a dedicated procedure to report such issues, and the framework itself tries to give the developer all the features needed to secure his code easily. Thanks to our successful community donation drive, SektionEins performed a security audit on the Symfony2 code earlier this year. The audit is now over and the good news is that the Symfony2 code is pretty solid; only minor problems have been found. They have all been addressed now
Their findings included things like the Request component trusting certain headers, bad regex validation on datetimes, password encoding issues, cookie handling and exception handling issues. Links to the fixes for each are included in the post.
Anson Cheung's Blog: 8 essential checks on securing PHP
Anson Cheung has a new post sharing eight things to change on your PHP install to help make things a bit more secure (from a platform standpoint, not in the code).
Obviously, PHP+ MySQL + Apache is a popular web technology.Its components are powerful, versatile and Free. However, the default settings ship with PHP is not suitable for production sites. Here, it is a check list of settings that are intended to harden the default PHP installation.
The list of eight includes things like:
- Disable Register Global
- Posing Limit
- Hiding The Presence Of PHP
- Advanced Safe Mode setting
2011年10月6日星期四
Site News: Blast from the Past - One Year Ago in PHP
- Advanced PHP Tutorial: 7 Useful functions to tighten the security in PHP
- Adminx Web: 15 Best Ever PHP Frameworks
- Site News: Blast from the Past - One Year Ago in PHP
- Seldo.com: PHP needs to die. What will replace it?
- Nurul Ferdous' Blog: Here is my 2 cents on Doctrine (ORM)
- SitePoint PHP Blog: High-Performance String Concatenation in PHP
- ServerGrove Blog: Logging MongoDB queries using Symfony 2 and Doctrine ODM
- ServerGrove Blog: Creating indexes for your Doctrine ODM documents with Symfony 2
- Shameer's Blog: An Introduction to Smarty 3
- Project: phpGolf - Programming Challenge
- IBuildings techPortal: Understanding APC
- Benjamin Schneider's Blog: Use PHP's Tidy extension to validate your (X)HTML markup
- Michelangelo van Dam's Blog: Single User Zend_Service_Twitter
- Gonzalo Ayuso's Blog: Performance analysis using bind parameters with PDO and PHP
- Simas Toleikis's Blog: Idea for a PHP Validator
PHPMaster.com: Creating a Mobile Photo Blog, Part 1
PHPMaster.com has started up a new series of tutorials today with part one of "Creating a Mobile Photo Blog". The set of tutorials will show you how to create a simple blogging tool that will upload images as submitted via an email address.
This is the first article in a two-part series in which I will show you how to create a photo blog as part of your personal website which you can update from your phone simply by sending an email. You'll write a script to check the inbox of an email account for new messages using POP3; the script will extract the messages' subject line, body text, and attachments and update a database accordingly. You can then pull the information from the database for display on your blog, in a sidebar, or however else you see fit.
The start with some of the security considerations you'll need to keep in mind when creating a script like this depending on how open you want it to be (like filtering based on the "From" email or sending an approval message before posting). Included in the post is the SQL to create their basic tables for posts, image details and the pending items. There's also a PHP class (POP3) that makes an IMAP connection to a remote server, authenticates as your account and fetches the latest messages along with their attachments. These are pulled with a quick script and displayed via a foreach.
Part two will get into more of the integration of the images and the approval technique prior to posting the images.
CodeIgniter.com: New User Guide in Development
The CodeIgniter development team is happy to announce work that's been done on the framework's user guide to help make it even better and easier to find the information you're looking for (now based on the Sphinx documentation generation engine).
In addition to handling the tedium of generating page and document tables of contents, or maintaining internal links and references, the documentation is now easier to write, as you can simply focus on the content instead of markup and presentation. Don't forget syntax highlighting of PHP, HTML, CSS, and JavaScript in code samples. Based on ReStructured Text, it's also more human readable in a text editor than HTML is, which is likely where you spend most of your time. As an added benefit, Sphinx can output HTML, PDF, and even EPUB formats all from the same source files.
There's also been a style redesign in the latest release (here on github) on the development branch of the framework. They warn of a few "bumps" that you might come across in using it, but they're working hard to take care of those quickly. If you'd like to see the new version, check out the nightly build results.
PHPBuilder.com: Building RESTful APIs with the Slim Microframework
On PHPBuilder.com today there's a new tutorial from Jason Gilmore about building a simple RESTful API with Slim, a microframework for PHP.
Although a relatively new entrant in the PHP framework sweepstakes, I've been lately quite intrigued by Slim, a slick RESTful microframework modeled after Ruby's Sinatra, which is coincidentally by far my favorite microframework available for any programming language. In this article I'll show you just how easy it is to get started building a powerful RESTful API using this streamlined framework.
Setup of the framework is as simple as downloading the latest copy from its github repository. It can then be included and used to make the simple routes in his examples. He uses a "games" request type to show how to handle GET, POST and PUT requests through Slim's simple interface.
2011年10月5日星期三
NetTuts.com: Getting Real-Time with Pusher
On NetTuts.com today there's a new tutorial showing you how to implement the Pusher service that gives you real-time messaging for your application. Their backend for the project is written in PHP using Pusher's library.
Do you want to spice up your web applications by making them real-time - but don't want to create new infrastructures for the sole purpose of getting web sockets to work? In this article, we'll explore how to use and implement Pusher, an HTML5 WebSocket-powered real-time messaging service for your applications.
Pusher uses HTML5 WebSockets to handle the messaging, so you'll need a browser that supports it to follow along with the tutorial. The Pusher API provides and endpoint for authorization and the push and pull of messages. In the tutorial, they create a simple chat application that gives a "Who's Online" and a window with the latest messages. You can download the full source (Javascript and PHP) here or view a demo here.
Stefan Koopmanschap's Blog: About your job opening...
If you're currently looking for developers to fit the needs of your company but just can't seem to find a good fit, Stefan Koopmanschap has a good suggestion you might want to follow to be more effective in your search.
The PHP job market is booming. Lots of companies are looking for (good) developers, but these are hard to find. Lots of developers are looking for a (good) job, but these are equally hard to find. Wait, that sounds strange... but it's true.
He points out that he's seen several companies put other technologies besides their core technology in their ads (shame on them). He suggests that companies think about what tech you really work with and stick with that on the resume - don't try to pull in people with hype and buzzwords.
Ibuildings techPortal: DPC Radio: Searching with Solr - Why, When, and How
The Ibuildings techPortal ha sposted their latest episode in the DPC Radio podcast series - recordings of sessions from the Dutch PHP Conference earlier this year. This episode is a recording of a talk from Paul Matthews about "Searching with Solr".
With Google constantly pushing the customer expectations of searching, is it time to move away from our database full-text search in pursuit of a more targeted platform? Can implementing Solr offer more than an answer to a search? Implementing a search platform isn't always suitable for all applications, but in this talk we'll look at identifying the right search solution, choosing the best way to integrate it into our application and exploring all the benefits a search server can offer.
You can listen to this latest episode either through the in-page player, by downloading the mp3 or by subscribing to their feed. The slides for the presentation can be found here on SlideShare.
2011年10月4日星期二
ZendCasts.com: Fun with Phar
New today on ZendCasts.com there's a screencast tutorial about using phar archives in your applications.
Phar is a new thing that's developed on the horizon over the last few years that's essentially a PHP archive or library.
He shows how to set up a basic application (non-Zend Framework) that does a "hello world" sort of output showing a date "next week". Also included are the commands to bundle it up into a phar archive using the features already built into PHP. The build stub uses the buildFromDirectory and compression/buffering. He also points out a common problem with the default settings on many PHP installed - an INI setting that disables phar creation. Thankfully, it's easy to change via a ini_set call updating the "phar.readonly" setting.
PHPMaster.com: Documentation Makes the World Go Round
On PHPMaster.com today there's a new article emphasizing something that lots of developers forget to make a part of their process when writing code - creating useful documentation to help make your code that much clearer.
If you're writing code that will be shared with others, put yourself in their shoes. Don't let your project lose potential users, community members, and possible contributors all because of insufficient documentation.
He (Matthew Turland) suggests a few things to keep in mind as you're writing up your documentation - the content is "king" (an emphasis on good descriptions/examples/use cases), open it up to external contributions using things like wikis (or even stored in the source code repository) and a focus on technical writing skills. Even the best tools out there can suffer if there's poor or no documentation.
Web Species Blog: We built a cloud platform for PHP. Wait...what?
As mentioned on the Web Species blog in this recent post, they've developed a "Windows Azure done right" platform (Azure++, name pending) that makes deploying to an Azure platform a much simpler process, pulling from something like a remote code repository (maybe github) and deploying in less than five seconds.
Azure is just impossible to use for PHP today. This is a fact. Doesn't matter which way you look at it, it just su.. isn't particularly good. The amount of steps you need to make, the knowledge you need to have and the fact that you can only deploy from Windows host are some of the things which make it a very painful experience. I had enough of this pain.
The service helps you make quick and easy Azure deployments. Features include multiple datacenter support, your choice of PHP versions (5.2 or 5.3) and the ability to deploy in "production" or "development" environments. You can find out more about the service here.
2011年10月3日星期一
Sameer Borate's Blog: Splitting large MySQL dump files
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.
Johannes Schlüter's Blog: Symfony 2 and mysqlnd
Johannes Schlüter has a new post to his blog today about a bundle he's created for the Symfony2 framework that integrates some of the advanced statistics mysqlnd provides back to the framework's profiler tool - JSMysqlndBundle.
Symfony provides a nice feature, which is the Symfony Profilier, an extensive logging and reporting system for Symfony developers to understand what's going on. A part of it is the Doctrine query logger which lists all database queries executed by Doctrine and their execution time. This is nice but when we're using mysqlnd in our PHP build we have more information available. "So why not use that information," I thought and built a new bundle for Symfony 2 doing exactly that.
His bundle takes the "150 or so" statistics and drops them into the profiler, giving you even more insight into how your script is running. The bundle is available on github, making it simpler to fork and extend to add other features (some he suggests include caching and replication decisions using information from other mysqlnd plugins).