News Feed
Sections




News Archive
feed this:

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

Lorna Mitchell's Blog:
Building A RESTful PHP Server Routing the Request
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.

0 comments voice your opinion now!
restful server tutorial request routing controller get post action


PHPBuilder.com:
Building RESTful APIs with the Slim Microframework
October 06, 2011 @ 10:12:07

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.

1 comment voice your opinion now!
tutorial restful rest api slim microframework put get post


Web Developer Juice:
PHP Magic Functions Best Part of Object Oriented PHP - Part 2
May 19, 2011 @ 10:14:27

Web Developer Juice has posted the second part of their series looking at some of the "magic functions" that PHP has to offer - special functions that do automagic things in your scripts and classes. Part one can be found here.

In my previous post ( PHP Magic Functions ), I discussed about __construct, __destruct, __call and __callStatic. Lets explore a few more magic functions...

In this latest part of the series they look at three functions:

  • __set/__get
  • __invoke
1 comment voice your opinion now!
magic function method oop get set invoke


Ole Markus' Blog:
High load websites A lock on Memcachedget
December 27, 2010 @ 12:34:14

Ole Markus has a new post to his blog looking at a technique for working with memcached and fetching data out of the store using a binary semaphore for better performance.

A typical document takes but a few hundred milliseconds to generate when a single request for the document enters the backend. The problem is that this is a highload website. In its current form, the backend serves hundreds of pages per second. This pretty much guarantees that the backend will concurrently receive cache miss on multiple languages and at the same time also receive cache miss on the pre-translated document.

Given that he wants the translated version to be the one that's always shared, a problem can come up when the cache request is "missed" and the document starts generating from multiple places. His fix for the situation is that only the first miss generates and all others see a lock on it and wait for it to be removed before successfully fetching the result. He provides code in a "LockedMemcached" class to help make it all more useful.

0 comments voice your opinion now!
lock memcache get set high load website varnish


php|architect:
Never Use $_GET Again
July 09, 2010 @ 09:15:48

In this new post to the php|architect blog Matt Butcher offers a security tip for all PHP developers out there - never use $_GET again.

You don't need to use $_GET or $_POST anymore. In fact, you probably shouldn't use $_GET and $_POST anymore. Since PHP 5.2, there is a new and better way to safely retrieve user-submitted data. [...] Rather than accessing the $_GET and $_POST superglobals directly, you can make use of PHP functions like filter_input() and filter_input_array().

He gives a code example of it in use and talks about the two things these functions do to help keep you safe - validate the data for correct match on criteria and sanitizing the value to ensure the return value is only what's requested. You can find more about these filter functions in the Filters section of the PHP manual.

1 comment voice your opinion now!
filter superglobal get security


Jani Hartikainen's Blog:
The three types of programmers
August 13, 2009 @ 14:48:08

In this recent post from Jani Hartikainen he looks at the three different categories he sees developers fitting into - "smart-and-get-things-done", smart and "just a" programmer.

The other day I was thinking of programmer types. In a way, I think there are three kinds of programmers when looking at a high level [...] So how do you determine if a programmer goes into one of these categories?

The "just a programmer" is the developer that writes code because it's a better job with little passion. The "smart programmer" are talented developers but they miss the big picture things. The "smart and get things done programmer" can be the most ideal of the three - they're the ones with the vision and passion to really make great applications.

0 comments voice your opinion now!
types programmers smart justa get done


Ian Selby's Blog:
Making RESTful Requests in PHP
May 15, 2009 @ 07:57:19

In a new post to his blog Ian Selby looks at working with REST requests in PHP. He includes some of the basics of REST too, for those not completely familiar with the term.

APIs have become a very commonplace part of many popular web sites and services...especially REST APIs. I've already discussed how you can roll your own REST API for your PHP apps, but I've also received countless requests to go over how to actually make RESTful requests. That's exactly what we'll take a look at in this article

His tool of choice is the curl extension, making it simple to create a class wrapper with methods like executePost, executeGet, setAuth and, of course, execute. He outlines the class and gives the code blocks that fit inside each of the major functions. In the end you'll have a class that can make GET, POST, PUT and DELETE requests and be able to correctly parse the response.

0 comments voice your opinion now!
delete post put get tutorial request rest


SmartyCode.com:
Enable your Zend Framework App with Conditional GET! (Make it green)
March 26, 2009 @ 14:25:59

On the SmartyCode.com site there's a quick new post about making your Zend Framework site a bit more "green" with a conditional GET feature.

In this article I'll show you a simple approach to enable your Zend Framework application saving lots of precious bandwidth, and thus, making it more end-users friendly, and save on bandwidth costs. This technique involves HTTP conditional GET. This is basically a feature of the HTTP protocol. By sending correct HTTP headers with your application, you enable browsers of your end users to cache pages of your site.

A plugin for the front controller (with a dispatchLoopShutdown method inside) is used to handle the requests and cache their content correctly. They have the cache set at 7200 seconds (2 hours) for a time to live, but its easy to tweak it based on your application. TO use the plugin call the registerPlugin function on the controller object and add it as the very last thing that runs.

0 comments voice your opinion now!
conditional get cache timetolive zendframework dispatchloopshutdown


AskAboutPHP.com:
Codeigniter Mixing segment-based URL with querystrings
March 10, 2009 @ 11:10:54

The Ask About PHP blog has a tutorial offering CodeIgniter users an alternative to the "no normal GET variables allowed" restriction the framework puts on its URLs - a hack to add those GET values back in as a configuration item.

Codeigniter does allow you to turn on the querystring capability, but that would mean you have to use a pure querystring approach, foregoing the segment-based approached. So, is it possible to mix segments and querystring?

Because of how the segmenting URLs are handled, the order of the parameters is very important as they're passed directly into the controller that way. By bypassing this structure and grabbing the GET variables out of a constant in one of the configuration files in one of two ways - mixing them globally and mixing them locally.

0 comments voice your opinion now!
codeigniter framework query string get variable order


SitePoint PHP Blog:
On $_GET and $_POST
February 05, 2009 @ 11:14:33

On the SitePoint PHP Blog today Troels Knak-Nielsen takes a deeper look at two of the superglobals a lot of PHP developers take for granted - $_GET and $_POST.

When a PHP script is invoked by a web server, it is as the result of a HTTP request. A HTTP request has a target URI and that URI consists of different parts. One of these parts is the query. As the PHP process starts up, the query gets parsed into an associative array. And for some reason, somebody decided on the unfortunate $_GET, because it's what you use for GET requests - right? Wrong!

He points out that all HTTP requests, regardless if they're GET or POST will have that GET information (not necessarily in $_GET, though). He also mentions another commonly used (and sometimes abused) superglobal - $_FILES. His biggest gripe, though, is that the naming of the variables confuses the developer as to the true content of the HTTP request.

And I won't even comment on the nastiness of $_REQUEST.
6 comments voice your opinion now!
get files request superglobal http request content confuse



Community Events





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


introduction update interview symfony release series opinion deployment library language zendserver api laravel community install tips list podcast package framework

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