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

Zend Framework Blog:
Handling OPTIONS and HEAD Requests with Expressive
Mar 29, 2017 @ 15:39:46

The Zend Framework blog has continued its series of posts focusing on the use of the Zend Expressive framework with a new tutorial covering handling OPTIONS and HEAD requests in an Expressive-based API.

In v1 releases of Expressive, if you did not define routes that included the OPTIONS or HEAD HTTP request methods, routing would result in 404 Not Found statuses, even if a specified route matched the given URI. RFC 7231, however, states that both of these request methods SHOULD work for a given resource URI, so long as it exists on the server. This left users in a bit of a bind.

[...] In the case of a HEAD request, the specification indicates that the resulting response should be identical to that of a GET request to the same URI, only with no body content. This would mean having the same response headers. In the case of an OPTIONS request, typically you would respond with a 200 OK response status, and at least an Allow header indicating what HTTP request methods the resource allows. Sounds like these could be automated, doesn't it? In Expressive 2, we did!

The tutorial then shows you the code you'll need to add to your Expressive v2 application for handling each kind of request. It involves some custom middleware using the route handling on the HEAD request type for one and the other for OPTIONS. The HEAD requests return an empty response while the OPTIONS requests return the data from a manually defined array (no automatic generation from routes or anything).

tagged: zendframework zendexpressive options head request handling

Link: https://framework.zend.com/blog/2017-03-28-expressive-options-head.html

PHPMaster.com:
Understanding Recursion
Jun 06, 2013 @ 14:32:41

On PHPMaster.com today there's a new tutorial posted that talks about something that can be a more difficult concept for budding developers to grasp - recursion.

In one of my previous articles I wrote about iterators and how you can use them. Today I’d like to look at the fraternal twin of iteration: recursion. A recursive function is one that calls itself, either directly or in a cycle of function calls. Recursion can also refer to a method of problem solving that first solves a smaller version of the problem and then uses that result plus some other computation to formulate an answer to the original problem.

He starts with an example - one function showing how to calculate a factorial using just looping and the other by having the function call itself. He talks some about the different types of recursion (direct/indirect) and gives a more practical example, a "find in array" function for one with nested subarrays. He also briefly mentions "head" and "tail" recursion, the difference being if it waits for a return value or not. He also offers some general advice when it comes to using recursion and how you have to watch for optimization issues.

tagged: recursion tutorial introduction head tail direct indirect

Link: http://phpmaster.com/understanding-recursion

Michael Caplan's Blog:
Don't Forget to Flush
Jan 08, 2009 @ 18:09:15

In this recent post to his blog Michael Caplan looks at a feature of PHP that's sometimes forgotten when pushing out larger chunks of data - flushing.

As a recluse who prefers hiding behind servers rather than dancing around your web browser’s canvas, I was intrigued with their server side recommendations - however sparse they may be. In particular, flushing generated head content early to speed up overall page delivery and rending time was a technique new to me.

Michael looks at what "flushing generated head content" means and includes a scenario - pulling the top palettes from the COLOURlovers site - and some performance stats on page load time and response time directly from the server (complete with graphs).

tagged: flush chunk compress head content load time statistics response

Link:

Tobias Schlitt's Blog:
Sending HEAD requests with ext/curl
Jun 27, 2008 @ 13:48:02

In a new post, Tobias Schlitt looks at how to send HEAD requests right along with the rest of your payload with the ext/curl extension for PHP.

I recently wanted to perform a HEAD request to a file, after which I wanted to perform some more advanced HTTP interaction, so CURL was also the tool of choice here.

He started with the (slow?) command line to get the parameters right before moving into PHP. After picking out the right ones ("curl -I -X HEAD http://localhost/admin/") he transfers them into a series of curl_setopt calls that specifies a HEAD request type and no content to send (with CURLOPT_NOBODY).

tagged: head request curl extension tutorial curlsetopt curlopt

Link:

David Coallier's Blog:
Namespaces has PHP 5.3 (Or the other way around)
Oct 01, 2007 @ 15:21:00

David Coallier has some happy news for PHP developers all over - namespaces have officially been committed to to HEAD branch:

This means that the next PHP version (5.3) will have namespaces. The patch by Greg Beaver to allow multiple namespaces has not been applied yet but I sure do expect it to be applied to 5_3 and HEAD soon.

More technical details can be found via the patch details and some basic articles on how to use them in your code.

tagged: namespace php5 head branch patch commit tutorial namespace php5 head branch patch commit tutorial

Link:

David Coallier's Blog:
Namespaces has PHP 5.3 (Or the other way around)
Oct 01, 2007 @ 15:21:00

David Coallier has some happy news for PHP developers all over - namespaces have officially been committed to to HEAD branch:

This means that the next PHP version (5.3) will have namespaces. The patch by Greg Beaver to allow multiple namespaces has not been applied yet but I sure do expect it to be applied to 5_3 and HEAD soon.

More technical details can be found via the patch details and some basic articles on how to use them in your code.

tagged: namespace php5 head branch patch commit tutorial namespace php5 head branch patch commit tutorial

Link:

Zend Developer Zone:
Zend Weekly Summaries Issue #322
Jan 29, 2007 @ 18:27:00

The latest weekly summary for the PHP mailing lists has been posted over on the Zend Developer Zone. This week, discussions included:

  • Sandboxed semaphores
  • Focus on *printf [continued]
  • PHP 5.2.1 RC2 and PHP 4.4.5 RC1
  • It's all in the HEAD
Descriptions of each of the headings are provided, including code and a "short version" for those on the run.

Be sure to check back each week for a new summary.

tagged: zend weekly summary semaphore fileinfo relrease fastcgi head openssl zend weekly summary semaphore fileinfo relrease fastcgi head openssl

Link:

Zend Developer Zone:
Zend Weekly Summaries Issue #322
Jan 29, 2007 @ 18:27:00

The latest weekly summary for the PHP mailing lists has been posted over on the Zend Developer Zone. This week, discussions included:

  • Sandboxed semaphores
  • Focus on *printf [continued]
  • PHP 5.2.1 RC2 and PHP 4.4.5 RC1
  • It's all in the HEAD
Descriptions of each of the headings are provided, including code and a "short version" for those on the run.

Be sure to check back each week for a new summary.

tagged: zend weekly summary semaphore fileinfo relrease fastcgi head openssl zend weekly summary semaphore fileinfo relrease fastcgi head openssl

Link:


Trending Topics: