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:
How to Use PHPbrew and VirtPHP
October 06, 2014 @ 13:08:41

Phil Sturgeon has written up a new tutorial for the SitePoint PHP blog showing you how to use PHPbrew and VirtPHP to be able to work with more than one PHP version on the same system.

We've all been in the situation where we have one version installed. Maybe that version is whatever came installed on our operating system. Maybe it is a version bundled into MAMP/WAMP/XAMPP. How do you go about switching that PHP version? How do you switch to one version, then switch back again? How do you go about switching that version of PHP, but only for one single application on your computer? The Ruby and Python communities have had tools for dealing with this for years. PHP has them now too, but there was nowhere near enough fanfare.

He starts with PHPbrew and walks you through a basic install and configuration of a version of PHP 5.6.0. He shows how to add extension support and switch between the different PHP versions at will. Next comes the look at VirtPHP, a similar system that takes a little bit different approach. It creates "environments" that contain the PHP version to a bit more isolated setup. With an environment created, VirtPHP lets you install PECL extensions without changing anything globally. He ends the post with a comparison to how most developers (developing locally) handle their setup and mentions Vagrant, but notes that it may be a bit much for the solo developer.

0 comments voice your opinion now!
virtphp phpbrew tutorial multiple version install configure

Link: http://www.sitepoint.com/use-phpbrew-virtphp/

Lorna Mitchell:
Running Multiple Versions of PHP
August 20, 2014 @ 09:28:57

In the latest post to her site Lorna Mitchell has posted a helpful hint on how you can run multiple versions of PHP at once, mostly how to get the latest version without messing up your current install.

When I advise people about upgrading their PHP version, I say things like "just run your test suite with the new version" "just grab the new version and try your site with the built-in webserver". A couple of people recently have asked for more detail on how to actually achieve these things so here's a quick primer on getting new PHP without touching anything to do with your existing PHP installation.

You'll need a bit of knowledge around compiling software to get the job done, so if you're only used to aptget-ing or yum-ing you might be a little lost. She does include all the commands you'll need including the special "prefix" flag on configure telling it to put PHP in a different location than normal. She also includes a brief test to ensure that it's all up and working (using the built-in web server).

0 comments voice your opinion now!
multiple version language tutorial installation

Link: http://www.lornajane.net/posts/2014/running-multiple-versions-of-php

Loosely Coupled Podcast:
Episode 8 Do You Even Polyglot?
August 04, 2014 @ 09:05:30

The Loosely Coupled podcast has posted the eighth episode of their podcast (hosted by PHP community members Jeff Carouth and Matt Frost) asking "Do you even polyglot?"

In this episode Jeff and Matt talk about the idea of polyglotism, the benefits, practical advice about choosing which languages to learn and how to be successful while learning new languages. You should go out and find a new language and prepare to give it the time it deserves. It's best to find a mentor or someone to help you and step out of your language or paradigm comfort zone.

They mention several other topics including Clojure, the splat operator and fellow community members Joel Clermont and Igor Wiedler. You can listen to this latest episode either through the in-page audio player or by downloading the mp3 directly.

0 comments voice your opinion now!
looselycoupled podcast ep8 polyglot multiple language choice success

Link: http://looselycoupled.info/blog/2014/07/22/episode-8-do-you-even-polyglot/

Allan MacGregor:
Exploring Traits
March 17, 2014 @ 11:48:59

In his new post Allan MacGregor takes a look at a somewhat underused feature of PHP (since 5.4), traits. He talks about how they can help solve multiple inheritance issues and the power they can offer.

Languages like C++ or Python manage this problem by allowing inheritance from multiple classes, Ruby in the other hand uses Mixings to address this issue. Regardless of the technique the problem remains the same; Traits are another approach to this problem and are commonly used in the languages like Perl and Scala.

He includes an example of the standard PHP method for inheritance in classes via the normal "extends" handling. He refactors this into a setup using traits to "override" the single inheritance issues via a "Cat" trait included in the "Tiger" class providing the "roar" method inside the class context.

The best part about traits is that it makes sense from a structural point of view. [...] Traits are an incredible addition to the PHP language and we have only started to touch the surface.
0 comments voice your opinion now!
traits introduction multiple inheritance

Link: http://coderoncode.com/2014/03/17/exploring-traits.html

Andreas Gohr:
Docker PHP Farm
February 03, 2014 @ 10:05:19

In his latest post Andreas Gohr shares a platform he's developed using docker to create a multi-PHP version instance that can run locally with just a few commands.

Yesterday I tried to fix a bug a user had reported in one of my DokuWiki plugins. Apparently it only occurred on PHP 5.2. Well, the last PHP 5.2 version was released in 2011 and no modern distribution has it anymore. So how do I test this easily? After a few failed attempts with finding a virtual machine image that would give me the needed PHP version I decided to come up with my own solution. And because I was curious - I decided to build it on docker.

He's already done the hard work for you and created the "phpfarm" project that's easy to pull in and use. He includes the two commands to get it downloaded and up and working and running PHP versions 5.2 through 5.5 on ports 8052 to 8055. If you're interested in seeing his Dockerfile, check it out on Github.

0 comments voice your opinion now!
docker phpfarm version multiple container

Link: http://www.splitbrain.org/blog/2014-02/02-docker_phpfarm

Zumba Engineering Blog:
Incorporating Mongounit into Multi-datasource Models with Traits
October 31, 2013 @ 10:42:27

On the Zubma Engineering blog today Chris Saylor has written up a tutorial showing how they used traits to use multiple data sources with Mongounit, working around the single source limitations it enforces.

A while back we open sourced Mongounit, a PHPUnit extension for testing models utilizing mongodb. One key issue that we've discovered as we incorporate MongoDB into more of our data models is that extending Mongounit's TestCase class limits that unit test towards Mongo only as the datasource. Since only a portion of our data is in Mongo while the remaining is in MySQL, limiting a test case to work with one datasource or another is too limiting.

They tried two other solutions first, separating out the tests by data source and manually clear the Mongo data in the tests, but both ran into problems. Instead, they opted to use traits to provide drop-in Mongo testing support as needed. It provides a simple interface to set up and tear down the needed Mongo resources - an example of which is also provided in the post. The code for the trait can be found on Github.

0 comments voice your opinion now!
trait mongounit unittest database multiple source model

Link: http://engineering.zumba.com/2013/10/30/multiple-data-sources-phpunit-testing/

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

Chris Jones:
Using PHP and Oracle Database 12c Implicit Result Sets
July 26, 2013 @ 09:12:40

Chris Jones has a new post to his site showing you how to use Oracle 12c's implicit result sets in your code. Note: this functionality is still in development, so the naming/exact functionality might change.

The new Oracle Database 12c "Implicit Result Sets" (IRS) feature allows query results to be returned from a stored PL/SQL procedure (or a PL/SQL anonymous block) without requiring special PHP code. Support for IRS is available in PHP OCI8 2.0.0-devel extension when it is compiled and used with Oracle Database 12c. (OCI8 2.0 can be compiled and used with other versions of Oracle Database but the available feature set is reduced).

He shows a normal fetch loop that calls the oci_* functions and grabs each row with a oci_fetch_row call. He updates this to use an anonymous PL/SQL block (a string) instead that allows for more flexibility. He includes examples that fetch from one table, multiple tables and returns multiple result sets (that can be fetched one at a time) from the same single call.

0 comments voice your opinion now!
implicit result set oracle 12c tutorial multiple single sql plsql

Link: https://blogs.oracle.com/opal/entry/using_php_oci8_2_0

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

Gonzalo Ayuso:
Handling several PDO Database connections in Symfony2 through the DIC in PHP
January 08, 2013 @ 11:52:40

Gonzalo Ayuso has written up a new post about a handling method he's worked up for working with multiple PDO instances (database connections) through the Symfony2 dependency injection container using custom YML definitions and a simple "Db" class.

I'm not a big fan of ORMs, especially in PHP world when all dies at the end of each request. Plain SQL is easy to understand and very powerful. Anyway in PHP we have Doctrine. Doctrine is a amazing project, probably (with permission of Symfony2) the most advanced PHP project, but I normally prefer to work with SQL instead of Doctrine. [...] Due to my daily work I need to connect to different databases (not only one) in my applications.

He shows the normal setup using the "parameters.yml" file to define the multiple database connections but notes that this isn't the most ideal solution. Instead, he walks you through the steps to create the "databases.yml" configuration file and a simple "Db" class that acts as an interface to pull the PDO objects from the container. You can then just call the "get" method on the container to extract the fully configured PDO object, ready for use.

0 comments voice your opinion now!
pdo symfony2 connection tutorial multiple yml database



Community Events





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


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

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