I wanted to add another library of classes to a Zend Framework project and autoload them, I created a folder called application/vendors/ to hold vendor libraries in seperate folders of their own. For example, using some CURL classes from Sem Labs, these classes would live in the application/vendors/semlabs/ folder.
Call user function for magic method PHP
Put a bit of work into upgrading the blog and might as well make a quick post now. Heres a trick to test if a class variable exists, isset or has a particular value dynamically. Call the magic method __get() for the variable name which you can generate on the fly.
Rolling out an API for your cakePHP app Part 3: Handling Errors
The last posts in this series covered the a basic architecture of an API in cakePHP, the limitations of that basic architecture and a possible solution using an API component and some external API classes. The last part is the handling of API specific errors. The goals for the error handling system:
Rolling out an API for your cakePHP app Part ++1: The Solution
In the previous post I covered creating a basic API using cakePHP and what limitations are imposed if you want to extend the API over the course of several versions. This post is going to cover the architecture of a possible solution, I don't claim its the best solution out there and feedback is welcomed.
Rolling out an API for your cakePHP app Part 1: The Problems
Recently I've put a lot of work into an API solution for a cakePHP app which addresses some of the architectural issues of creating an API in a cakePHP project. To start with I threw together a nice simple API as a proof of concept and to showcase the ease at which an API can be created quickly using the RequestHandler component. While that solution was fine and incredibly quick to whip up, there are some issues when it comes time to extend the API, the biggest of which is versioning.
Rolling out an API for your cakePHP app Part 1: The Problems
Recently I've put a lot of work into an API solution for a cakePHP app which addresses some of the architectural issues of creating an API in a cakePHP project. To start with I threw together a nice simple API as a proof of concept and to showcase the ease at which an API can be created quickly using the RequestHandler component. While that solution was fine and incredibly quick to whip up, there are some issues when it comes time to extend the API, the biggest of which is versioning.
5 XSS Exploits You Should Know About
Following on from my HTTP Splitting post, this post rounds up 5 common cross site scripting (xss) attacks and how to prevent them.
CakePHP Paginate Multiple Data Sets on One Page
Wanted: a simple method to paginate multiple sets of data separately on a single page using the cakePHP paginator helper/object.
Multiple File Uploads CakePHP jQuery
Creating a basic form where you can add file inputs for file uploads dynamically using jQuery for the client side and cakePHP for the server side.
Translate a nested heirarchical array into another heirarchical array
Yes, that does sound like a pointless title. Let me explain the situation, we have a self referential model, Pages, which has child pages and a parent page. Because I'm using CakePHP for this project I have added the Tree Behaviour to the model also which is really handy, but you don't need that behaviour (mptt structure) in order for this to work.
Nested Ternary Statement PHP
Moving complex php if statements into ternary statement syntax is not always recommended, but I think it can look quite neat and easily readable.
Validate Unicode/UTF-8 Form Input (Language Specific Characters)
Validating language specific characters in user input can be a bit of a pain, especially if you are using regular expressions to filter user submitted data.
PHP Error Handling Class
Error handling is obviously fairly important so I have finally invested time into a custom error handling class for PHP 4 and above. It is a fairly small and simple class (only about 150 lines), I'm quite happy with it so far, of course you can download the class below and try it out for your self.
PHP Voting System to Increase your Inbound Links
Having some sort of web 2 point ohish interactive component on your website is a great way to generate buzz, get users coming back to the site and even generate inbound links. One such component I have seen work well is a voting system, made so much more popular by community driven sites such as digg, reddit etc.
Restict Logins by IP Address
Today I had to write into an admin area on one of our sites a restriction so that only people at certain IP addresses could log in.
Displaying File Permissions with PHP
For whatever reason you may need to display file permissions for one of your websites. I have thrown together a very basic script which will recursively (yay recursion) navigate your filesystem and save the folder/filenames and their respective file permissions into an associative array. The script then displays the array very basically.
How to Create a Robust Splash Page
Sending a user to a 'splash' page the first time they visit your site seems like a pretty simple task, but its not. At first glance I thought it would easily work a bit like this:
Simple Recursive PHP Tree Menu Example
Recursion. It can be a bit to get your head around at first but it can often create a lightweight, robust and elegant solution.