Rob AllenView header and body with curl (24.5.2016, 12:13 UTC)

I recently discovered the -i switch to curl! I have no idea why I didn't know about this before…

Curl is one of those tools that every developer should know. It's universal and tends to be available everywhere.

When developing APIs, I prefer to use curl to view the output of a request like this:

$ curl -v -H "Accept: application/json"
*   Trying
* Connected to ( port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate:
* Server certificate: Gandi Standard SSL CA 2
* Server certificate: USERTrust RSA Certification Authority
* Server certificate: AddTrust External CA Root
> GET / HTTP/1.1
> Host:
> User-Agent: curl/7.43.0
> Accept: application/json
< HTTP/1.1 200 OK
< Date: Sun, 15 May 2016 11:05:27 GMT
< Server: Apache
< X-Powered-By: PHP/5.6.4
< Access-Control-Allow-Origin: *
< Content-Length: 363
< Content-Type: application/json; charset=utf8
* Connection #0 to host left intact

-v is for verbose and so you get told all the information you could possibly want. However, usually, I only want to know the response's headers and body.

Enter the -i switch!

$ curl -i -H "Accept: application/json"
HTTP/1.1 200 OK
Date: Sun, 15 May 2016 11:10:24 GMT
Server: Apache
X-Powered-By: PHP/5.6.4
Access-Control-Allow-Origin: *
Content-Length: 363
Content-Type: application/json; charset=utf8


Much better!

-i is for include and from the man page:

Include the HTTP-header in the output. The HTTP-header includes things like server-name, date ofthe document, HTTP-version and more…

This is exactly what I want without the information that I don't!

PHP ClassesInstalling a Database Schema from a JSON format (24.5.2016, 04:37 UTC)
By Samuel Adeshina
Installing a database schema is an important setup task that most PHP applications need to do.

The Scripd package can generate the necessary SQL to install all types of database structures that you may need from the database itself, tables, fields, indexes, stored procedures, views, etc., all from a database independent format based on JSON.

Read this article to learn how to use the Scripd package to generate database independent SQL to install your database schema.
Voices of the ElePHPantInterview with Beau Simensen (24.5.2016, 04:01 UTC) Link
PHP ClassesNotable PHP package: PHP PDF to Text (23.5.2016, 19:35 UTC)
By Manuel Lemos
Many Web applications need to deal with PDF documents and their contents for instance to search for particular text.

However, the PDF format is not easy to analyse and it contains complex structures and often compressed binary data.

The PHP PDF to Text package not only is able to parse the PDF format in pure PHP, but it can also decompress any document objects and extract their page position, making it easy to search PDF documents using only with PHP code, thus without resorting to external programs, special extensions or Web service APIs.

Read this article to learn more details about how this notable PHP package works.
PHP ClassesDetecting Malicious Users behind Anonymous Proxies using IP2Proxy (23.5.2016, 05:03 UTC)
By Elma Dilaver Gheith
Proxy servers are used by many users to bypass Web site restrictions. Sometimes malicious users are hiding behind proxies to commit fraud because a third party anonymous server is hiding their real location.

Fortunately it is possible to detect when users are behind proxies by looking up their IP address using IP2Proxy databases of known proxies.

Read this article to learn how to use IP2Proxy database to detect when users are behind proxies, so you can take the necessary measures to avoid that those users may cause some kind of harm.
Ben Ramsey7 Tips for php[tek] (22.5.2016, 00:00 UTC)

This week, I’m attending php[tek]. This is my seventh php[tek], and the first I’ve attended not as a speaker. It’s one of my favorite conferences, and I didn’t want to miss its first year in a new city: St. Louis. As we gear up for the eleventh php[tek] conference, I thought I’d list my seven tips for getting the most out of your php[tek] experience.

  1. Hang out in the evenings, after the conference sessions.

    php[tek] is known for hosting events in the evening, from video games and board games to hackathons. Make sure you you stick around and take part. One of the best features of PHP is its community, and taking part in the events following the day’s conference sessions is a great way to build relationships in this community.

  2. After the conference events, follow folks to the bar.

    Do you have to be a drinker? Nope. There’s much more to a bar than drinking. In Chicago (Rosemont), php[tek] had Shoeless Joe’s, a nearby sports bar, where attendees would congregate each evening following the conference activities. In St. Louis, I don’t know what that place will be, but I’m certain there will be one. This is where relationship-building continues. There’s so much that can come from these relationships—friendships, business opportunities, mentors, and more!

  3. Take advantage of the “hallway track,” and don’t forget the regular sessions.

    There is a high level of value gained by conversing with other conference attendees in the hallways between (and during) sessions at conferences. This “hallway track” has been touted as one of the most important reasons for attending a conference. The hallway allows you to build relationships and gain better understanding and insight into the technologies and tools you use on a daily basis. It’s an invaluable offering of any conference, but don’t forget about the value gained by attending the sessions. A healthy balance of both will help you have an awesome conference experience.

  4. Attend the morning keynote sessions.

    The morning keynote sessions set the tone for the conference, and this year’s keynotes are no different. While it’s tempting to stay up into the wee hours of the morning—building relationships at the St. Lou

Truncated by Planet PHP, read more at the original (another 11791 bytes)

Anthony FerraraAll About Middleware (20.5.2016, 21:30 UTC)
Last week, a proposal to standardize middleware for PSR-7 was introduced to the PHP-FIG. The general concept of middleware is not a new one, and has been in use in the PHP world for many years. Several people have raised significant concerns with the proposal, which have gone completely unheeded by the author. Let me go through the most major of these concerns, as well as show what a better proposal might look like.

*Note: All code that will be used in this post is real-world code found in the wild (and linked to) with one exception (X-Powered-By).

Read more »
SitePoint PHPLocalizing Dates, Currency, and Numbers with Php-Intl (20.5.2016, 16:00 UTC)

The first part of this series was an introduction of the PHP Intl extension and of how to localize your application's messages. In this part, we're going to learn about localizing numbers, dates, calendars, and similar complex data. Let's get started!

Globe stock illustration

Localizing Decimals

This may sound odd, but one of my main concerns when formatting numbers is working with decimal points, as they differ from place to place. Check Wikipedia for more details about different decimal mark variations.


The PHP Intl extension has a NumberFormatter which deals with number localization:

$numberFormatter = new NumberFormatter( 'de_DE', NumberFormatter::DECIMAL );
var_dump( $numberFormatter->format(123456789) );

$numberFormatter = new NumberFormatter( 'en_US', NumberFormatter::DECIMAL );
var_dump( $numberFormatter->format(123456789) );

$numberFormatter = new NumberFormatter( 'ar', NumberFormatter::DECIMAL );
var_dump( $numberFormatter->format(123456789) );

$numberFormatter = new NumberFormatter( 'bn', NumberFormatter::DECIMAL );
var_dump( $numberFormatter->format(123456789) );

string(11) "123.456.789"
string(11) "123,456,789"
string(22) "١٢٣٬٤٥٦٬٧٨٩"
string(30) "১২,৩৪,৫৬,৭৮৯"

The first parameter is the locale code, and the second is the formatting style. In this case, we're formatting decimals.

Continue reading %Localizing Dates, Currency, and Numbers with Php-Intl%

Nomad PHPHere be Dragons: What It’s Really Liketo Slay a Monolith (20.5.2016, 04:01 UTC)

August 2016 - US
Presented By

Kayla Daniels
August 18, 2016
20:00 CDT

The post Here be Dragons: What It’s Really Like
to Slay a Monolith
appeared first on Nomad PHP.

Evert Potsabre/xml and repeating elements (19.5.2016, 22:00 UTC)

We recently got a support ticket with a simple sabre/xml question. Because it’s a nice demonstration for sabre/xml, I thought it would make for a short and sweet blog post.

eddy8 asks (paraphrased): how do I repeat the same xml element name, to create a structure such as this:

<?xml version="1.0"?>

The code he started off with was this:


$service = new Sabre\Xml\Service();
$xmlstr = $service->write('books', [
    'book' =>  'php',
    'book1' =>  'c++',
    'book2' =>  'c#',

But this generates this xml:

<?xml version="1.0"?>

And you can’t use the same key in PHP arrays more than once. There are three possible solutions to this.

The first is to change how the elements are specified. Instead of a simple key value, you can use a structure such as this:


$service = new Sabre\Xml\Service();
$xmlstr = $service->write('books', [
    ['name' => 'book', 'value' => 'php'],
    ['name' => 'book', 'value' => 'c++'],
    ['name' => 'book', 'value' => 'c#'],
echo $xmlstr;

In most cases this is probably what you want. A second option is to use a callback, the callback will automatically be called with the XMLWriter object:


$service = new Sabre\Xml\Service();
$xmlstr = $service->write('books', function(Sabre\Xml\Writer $writer) {

Truncated by Planet PHP, read more at the original (another 4396 bytes)

LinksRSS 0.92   RDF 1.
Atom Feed   100% Popoon
PHP5 powered   PEAR
ButtonsPlanet PHP   Planet PHP
Planet PHP