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

DZone.com:
MongoDB Driver Tips & Tricks PHP
June 04, 2014 @ 10:10:49

On DZone.com there's a new post from Chris Chang that's the third part of the series looking at using various language drivers for working with MongoDB. In this latest article he focuses in on the PHP driver, giving a brief introduction and a few handy tips.

This blog post is the third of a series where we are covering each of the major MongoDB drivers in depth. The driver we'll be covering here is the PHP driver, developed and maintained by the MongoDB, Inc. team (primarily @derickr, @bjori and @jmikola).

He includes a link to some basic examples and shares a "production-ready connect string" with some MongoLab recommended settings. The tips include topics ranging from working with index builds, the lowering of is_master_interval and configuring the connectionTimeoutMS setting for optimum connection handling.

0 comments voice your opinion now!
mongodb driver tips tricks mongolab index master interval connection timeout

Link: http://java.dzone.com/articles/mongodb-driver-tips-tricks-php

Brandon Savage:
Publishing messages to RabbitMQ with PHP
May 30, 2013 @ 10:09:49

Brandon Savage has posted the second article in his RabbitMQ+PHP series today with a look at publishing messages to the queue. (Part one is here)

Now that we understand the basics behind RabbitMQ, it's time for us to start working with it. The first step in working with RabbitMQ is to begin sending messages to the exchange so that they can be queued. In RabbitMQ parlance, the "producer" is responsible for "publishing" the messages to the exchange.

He includes the code you'll need to use the AMQP PHP extension to connect with the RabbitMQ server and select a channel. He also shows how to set up an "exchange" and "queue" and bind them to each other. Finally, there's the one line of code that uses the routing key value to push a message into the waiting service.

0 comments voice your opinion now!
rabbitmq publishing message tutorial queue exchange connection

Link: http://www.brandonsavage.net/publishing-messages-to-rabbitmq-with-php

Lorna Mitchell:
PHP and Gearman Unable to connect after upgrade
February 28, 2013 @ 12:55:48

Lorna Mitchell has shared some advice about correcting an issue with PHP and Gearman after she did an upgrade via PECL.

I upgraded PHP and related pecl modules on my development machine today, and ran into a problem with Gearman. Actually I ran into more than one! Firstly the challenge of getting the newest pecl version working with a gearman version. Then an error where my existing PHP application couldn't connect to gearman after upgrade.

Running on Ubuntu, she found this tutorial helpful in getting Gearman back into a working state and installed (version 1.1.1). The "unable to connect" error turned out to be a change in how the Gearman connection needed to be made - the addition of a port to the connection string made things work again.

0 comments voice your opinion now!
gearman connection issue pecl ubuntu port


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


Derick Rethans:
Read Preferences wth the MongoDB PHP driver
December 20, 2012 @ 13:41:24

Derick Rethans has a new post to his site detailing some of the "read" preferences that you can customize in the latest versions of the MongoClient functionality in the MongoDB PHP extension for replica sets and sharing setups.

Read Preferences are a new Replica Set and Sharding feature implemented by most MongoDB drivers that are supported by 10gen. This functionality requires MongoDB 2.2. In short, Read Preferences allow you to configure from which nodes you prefer the driver reads data from. In a Replica Set environment it is the driver that does the selection of the preferred node, and in a Sharded environment it is the mongos process that routes queries according to the defined Read Preferences.

He starts with a look at the read preference types (like "primary", "secondary" and "nearest") how the connection manager works to handle each type. He includes some code samples showing how to configure your MongoClient connections to use these various types of preferences. He also introduces the concept of "tags" for the replica set - aliases to make them a bit easier to identify when making a connection and how to define them in the connection string.

0 comments voice your opinion now!
mongodb mongoclient read preference replicaset sharding connection tutorial


Derick Rethans:
Debugging Connections with the MongoDB PHP driver
December 11, 2012 @ 10:20:13

Derick Rethans has a new post that the developers out there using MongoDB in their applications will find useful - a look at debugging your connections with the PHP driver (and what kind of information it can provide).

In a previous article I already mentioned that the 1.3 version of the MongoDB driver has improved logging functionality to aid with debugging connection issues. I've already briefly introduced MongoClient::getConnections(), but it provides a bit more information than I have already shown. The other improvement are changes to the MongoLog class.

He includes details on the information that comes back from the MongoDB "getConnections" call including the hash of the connection, the "last ping" time, connection type and a set of tags. He also shows how to enable the Mongolog logging, the levels of logging it allows and what kind of log messages you can expect it to output.

0 comments voice your opinion now!
mongodb driver connection debug mongolog


Derick Rethans:
Connection Handling with the MongoDB PHP driver
December 04, 2012 @ 10:54:15

Continuing on with his look at the newly released version of the MongoDB driver for PHP Derick Rethans has posted more detail about the advanced connection handling options this new driver version provides.

The 1.3 release series of the PHP MongoDB driver features a rewritten connection handling library. This is quite a large change and changes how the PHP driver deals with persistent connections and connection pooling.

He starts with an example of a v1.2 driver connection, how the connection is requested from a pool and how, based on the integration of a worker into the connection process, v1.3 handles the connection requests. He includes a bit about replica set connections and authentication connections, complete with PHP code examples showing them in practice.

0 comments voice your opinion now!
connection handling tutorial mongodb driver version


PHPMaster.com:
Spooky Scary PHP
October 24, 2012 @ 08:39:22

In the spirit of Halloween coming next week PHPMaster.com has posted some spooky scary PHP code in their latest post from the editor of the site, Timothy Boronczyk.

Break out the candy corn and apple cider; it's that time of year again! The rest of the world may not celebrate Halloween as hog wild as in America, but I thought it'd be fun to share some scary PHP stuff to mark the holiday. This is a fun article, sharing with you some scary (but logical) behavior found in PHP itself, and spooky (and possibly quite illogical) ways in which some have twisted PHP to do their bidding. Think of this as my treat to you, a little bit of geek "mind-candy" - because why should all the trick-or-treaters have all goodies?

The code examples include "The Haunted Array", "The Phantom Database Connection" and "An API Worthy of Dr. Frankenstein". Enjoy! (and maybe share some of your own too)

0 comments voice your opinion now!
scary example array database connection api


PHPBuilder.com:
My Automated PHP Scripts for Creating FTP Connections to a Remote Server
June 19, 2012 @ 10:41:57

PHPBuilder.com has posted a new tutorial about creating automated FTP scripts to pull down information from a remote server (using FTP streams).

In 2007 I began working on a website project for an investment company in my hometown of Cleveland, Ohio USA. The purpose of this website was to automatically download financial data of traded securities from two (2) remote Web servers. [...] Both of these PHP scripts were set up on the Web server's "crontab manager" to automatically run at a set time each business day.

Code is included showing how to connect to the remote service (via curl) with a "ftp" stream-based URL as the location. Also included is an example using a fopen call to the URL and inserting the resulting data into their tracking tables. The other script pulls the data out and adds a new record to a transactions table for the current day.

0 comments voice your opinion now!
ftp tutorial connection transaction mysql cron automation


NetTuts.com:
PHP Database Access Are You Doing It Correctly?
June 04, 2012 @ 13:33:54

In this new tutorial on NetTuts.com, they talk about one of the more fundamental connection types you can do in PHP - database connections. They want to be sure you're "doing it correctly" via PHP's PDO API.

We've covered PHP's PDO API a couple of times here on Nettuts+, but, generally, those articles focused more on the theory, and less on the application. This article will fix that! To put it plainly, if you're still using PHP's old mysql API to connect to your databases, read on!

They compare the three main methods for connecting to a MySQL database - mysql, mysqli and PDO - and how a typical mysql/mysqli codebase can be refactored to use PDO. They show examples of connections, error handling, fetching data, using prepared statements and snippets of code for CRUD (Create, Read, Update, Delete) handling.

Be sure and check out the comments - there's some great tips there too!

0 comments voice your opinion now!
mysql pdo tutorial connection refactor



Community Events





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


configure series interview language application install bugfix podcast laravel library community threedevsandamaybe api developer introduction list code wordpress symfony release

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