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

SitePoint PHP Blog:
Installing PHP Extensions on Nitrous.io
March 03, 2014 @ 11:45:22

On the SitePoint PHP blog Bruno Skvorc has posted a new tutorial showing you how to get PHP extensions installed on Nitrous.io, an online environment combining an IDE and PaaS hosting.

Inspired by a comment on my previous article, I realized Nitrous was still a bit too complicated to customize properly. In this tutorial, we'll glide through installing cURL and Phalcon on a Nitrous.io PHP box.

He continues on from his previous article and shows how to detect cURL support and how to build it from the PHP source into an extension. He helps you get the source for the older PHP version Nitrous.io has installed and the commands you'll need to build the extension. With it installed and enabled in the php.ini, he also installs the Phalcon extension.

0 comments voice your opinion now!
nitrousio tutorial install extension curl phalcon compile

Link: http://www.sitepoint.com/installing-php-extensions-nitrous-io

SitePoint PHP Blog:
Using Google Translate API with PHP
October 31, 2013 @ 13:14:11

On the SitePoint PHP blog Jacek Barecki has a new tutorial showing you how to use the Google Translate API to handle the translation of dynamic input that may have come from other sources (including users).

If your site serves visitors from different countries, you may already have translated all its static content into several languages. But what to do with the content posted daily by the users in comments, opinions and ratings? As this may be as valuable a part of your site as the static content, you should think of finding a way to translate it into other languages. One service that can help is, of course, Google Translate.

He walks you through the process of setting up a Google API account (with screenshots) and how to turn on the Translate API specifically. The Translate API is not a free service, unfortunately, so you'll need to set up some billing information to use it. He then points you to where you can find your API key and shows a sample API call to get the currently supported languages. With that working, he shows you how to make an actual translation call, passing in the text and desired language on the URL and sending it to the API via curl. He also talks some about handling errors based on HTTP response code and the message returned.

0 comments voice your opinion now!
google translate api tutorial curl

Link: http://www.sitepoint.com/using-google-translate-api-php/

Phil Sturgeon:
CurlFile and the Facebook SDK in PHP 5.5
August 30, 2013 @ 11:19:04

Phil Sturgeon has a new post to his site today looking at a new feature that's included with PHP 5.5, Curlfile, and how he uses it with calls to the Facebook API (and a fix to make it cooperate).

One of the features implemented in PHP 5.5 was CurlFile, a nice addition to the Curl extension to allow you to specify specific arguments as a file for upload. In previous versions (pre-PHP 5.5) the syntax looked like this: [@/foo/bar.jpg]. A little digging around lead me to try this syntax: [new CURLFile('/foo/bar.jpg','image/jpeg')]. Sadly while Curl was happy with this, the Facebook PHP SDK (v3.2.2) was not. It turns out the SDK will turn ANY value you send it in that params array into a string.

To get around the issue, he worked up his own fix to the Facebook PHP SDK and submitted a patch to get it introduced into the tool. He also includes a reminder to filter incoming user data for things containing the "@" too to prevent unwanted file transfers.

0 comments voice your opinion now!
curlfile curl file upload facebook sdk patch json

Link: http://philsturgeon.co.uk/blog/2013/08/curlfile-and-the-facebook-sdk-in-php-55

DesignShack.com:
How to Build a Dynamic Imgur Upload App Using jQuery & PHP
August 30, 2013 @ 09:51:03

On DesignShack.com Jake Rocheleau has a tutorial showing you how to create an image uploader that pushes the image over to the Imgr service.

In this tutorial I want to demonstrate how we can remotely mirror an image found elsewhere online and auto-upload to Imgur. It's possible to create a form handling user-uploaded images as well. But I wanted to keep the demo clean without needing to move user content onto the server. This process is very simple once you understand how APIs work.

He provides all of the code and guidance you'll need to get the system working. It uses a simple HTML layout, some jQuery for submitting the image data back to the the server and a PHP script to call the Imgr API. It uses curl to make the call, so you'll need that extension installed to use the example. You can check out the live demo or just download the source to get started quickly.

0 comments voice your opinion now!
imgr upload jquery tutorial javascript api curl

Link: http://designshack.net/articles/javascript/how-to-build-a-dynamic-imgur-upload-app-using-jquery-php/

PHPMaster.com:
Using cURL for Remote Requests
August 08, 2013 @ 09:09:13

PHPMaster.com has posted a tutorial showing you how to use the cURL functionality that can be built into PHP. Note that not all PHP installations will have this extension installed, but most will these days. You can find out by making a phpinfo page.

If you're a Linux user then you've probably used cURL. It's a powerful tool used from posting mails to downloading the latest My Little Pony subtitles. In this article I'll explain how to use the cURL extension in PHP. The extension offers us the functionality as the console utility in the comfortable world of PHP. I'll discuss sending GET and POST requests, handling login cookies, and FTP functionality.

He walks thorough the basic flow of a request and how to set options on the cURL handle to modify its behavior. Several more "real world" examples are also included:

  • Retrieve a Web Page
  • Log in to a Website (via POST data, not HTTP Auth)
  • Working with FTP
  • Sending Multiple Requests

That last one changes things up a bit and uses the curl_multi_init function to create the connection and allow for the multiple request streams to happen.

0 comments voice your opinion now!
curl remote request tutorial login ftp multiple

Link: http://phpmaster.com/using-curl-for-remote-requests

VG Tech:
PHP Perform Requests in Parallel
July 23, 2013 @ 10:58:11

On the VG Tech blog today Espen Hovlandsdal has a quick tutorial showing you how to run cURL requests in parallel using the curl_multi_* functions included in PHP.

Ever had to request multiple HTTP-resources in your web application? Often, you need data from one request to be able to request the second - in this case there is little you can do but wait for the first to return. However, if the requests are not dependent on each other, you can use a pretty cool trick: curl_multi_*.

He first gives a single-threat example, showing how you might loop through a set of URLs to make the request and get the response. As an alternative, he shows the "multi" version right after. It sets up a "queue" of handles to different requests and executes them until they stop returning data. He also includes an example using the Guzzle HTTP client that makes it look cleaner and wraps some additional functionality around the requests.

0 comments voice your opinion now!
request parallel curl multiple tutorial guzzle

Link: http://tech.vg.no/2013/07/23/php-perform-requests-in-parallel

Segment.io:
How to Make Async Requests in PHP
February 06, 2013 @ 09:52:49

On the Segment.io blog there's a new post by Calvin talking about making asyncronous requests in PHP and three different approaches you could use, depending on your situation.

When designing client libraries to send data to our API, one of our top priorities is to make sure that none of our code affects the performance of your core application. That is tricky when you have a single-threaded, "shared-nothing" language like PHP. [...] Ideally, we like to keep the setup process minimal and address a wide variety of use cases. As long as it runs with PHP (and possibly a common script or two), you should be ready to dive right in. We ended up experimenting with three main approaches to make requests in PHP. Here's what we learned.

Their three suggestions don't involve external dependencies (like a queue server) and can operate pretty quickly:

  • Opening a socket and closing it before waiting for a response
  • Write to a log file (a pseudo-queue)
  • Fork a curl process (through something like exec)

They each have small code examples included with them and explanations as to their plusses and minuses. For their needs, the "forked curl" solution worked out the best, but check out the other options too - you might have different needs.

0 comments voice your opinion now!
asynchronous request socket curl log queue tutorial


Smashing Magazine:
Powerful Command Line Tools For Developers
October 30, 2012 @ 10:18:56

On the Smashing Magazine site today they've posted a list of powerful CLI tools that every developer should at least know about to help make their lives easier - six of them ranging from SSH tunnels to HTTP testing.

Good tools are invaluable in figuring out where problems lie, and can also help to prevent problems from occurring in the first place, or just help you to be more efficient in general. Command line tools are particularly useful because they lend themselves well to automation and scripting, where they can be combined and reused in all sorts of different ways. Here we cover six particularly powerful and versatile tools which can help make your life a little bit easier.

The tools they mention are all things you'd install on a unix-based system:

  • Curl
  • Ngrep (network packet searching)
  • Netcat (to work with network connections)
  • Sshuttle (SSH tunneling)
  • Siege (HTTP benchmarking)
  • Mitmproxy (capturing proxy, both HTTP and HTTPS)
0 comments voice your opinion now!
commandline cli tools developer list curl ngrep netcast sshuttle siege mitmproxy


Michael Maclean:
Why one-line installers are a bad idea
September 21, 2012 @ 11:35:29

There's a feature that's usage has been showing up more and more in software projects (both open source and not) that allows you to install their system with a single line command, usually involving curl and maybe piping it to a shell. In this recent post Michael Maclean takes a look at this trend and some of the possible pitfalls of the approach.

There has been a trend in the last while for various bits of useful software to have a one-line shell command recommended as the installation method. The usual form of this is to pipe something like curl or wget to some interpreter, be it bash, php, ruby, or some such. [...] This [type of] command takes the output of curl and pipes it straight to bash. I have several issues with this.

His three main points center around the fact that you cannot inspect the code before executing it with this method, that you can't verify the source of the code and that it teaches users bad habits of trusting in "magic commands" like these.

0 comments voice your opinion now!
installer oneline opinion curl bash shell magic


Patrick van Kouteren:
CloudVPS object store beta introduction
August 28, 2012 @ 12:52:35

Patrick van Kouteren has a new tutorial posted to his site showing you how to connect your application with an OpenStack instance (specifically the CloudVPS option) via some simple CURL commands (easily translatable into PHP).

Lately I've been playing around with the CloudVPS ObjectStore, which is currently in beta phase. This blogpost shows the options of this ObjectStore in a practical way and concludes with a summary of commands you can use yourself to interact with it and some ideas. For this post, I assume you are familiar with cURL, REST and HTTP headers.

He shows how to make the requests for:

  • Authentication
  • Working with containers
  • Adding files to a container
  • Setting access permissions
0 comments voice your opinion now!
object storage curl tutorial container file authentication



Community Events





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


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

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