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:
Getting Started with FluentPDO
July 17, 2014 @ 11:08:01

The SitePoint PHP blog recently posted a new tutorial helping you get up and running with FluentPDO, a small PHP library that makes building queries easier and faster. In the tutorial Francesco Malatesta introduces you to the tool and creates a test project to show it in use.

You know the story: writing SQL queries is so boring. Especially when you don't have time to do it. If you feel like me, today we are going to see something really cool: Fluent PDO. [...] The result? No more SQL queries. Maybe this is not the first one you have seen: there are many similar projects out there and every single one has its key features. Fluent's key feature is a great JOIN Query Builder.

His test project links a "wishlist" listing with a users table based on a "user_id" field. He includes the SQL to create the two tables and helps you get the library installed (via Composer). He shows some basic select operations using the fluent interface including where clauses, order by and group by handling. He also covers some basic examples of the other CRUD operations (create, read, update, delete) before getting into one of the more advanced features: the join query builder. Finally, he wraps up the post with a brief look at the query debugger, making it a bit simpler to tell where the failures might lie.

0 comments voice your opinion now!
fluentpdo library introduction tutorial

Link: http://www.sitepoint.com/getting-started-fluentpdo/

Qandidate.com Blog:
Fault tolerant programming in PHP
July 17, 2014 @ 10:44:04

The Qandidate.com blog has a new post today looking at fault tolerant programming in PHP applications. Essentially, this means writing your code so that error conditions are handled gracefully and with as little impact as possible.

In your application, every time you call an "external" service you are vulnerable to the failure in that service. That either might be a third party API being down, your database being unresponsive or unexpected errors from the 3rd party library you are using. With many developers and companies being interested in composing applications out of microservices at the moment, guarding for failures because of broken dependencies gets even more important.

They describe a situation where data is coming from an external source (an inventory service) and a timeout or connection failure occurs. They propose a sort of "circuit breaker" to be put in place to protect the application, fail fast on error and maybe even retry until the request is successful. They also point out a library from oDesk, Phystrix, that allows for fault tolerant execution through a wrapper that traps errors and deals with them instead of just breaking. This is the first part of a series, so in part two they'll show the library in use along with the React HTTP client.

0 comments voice your opinion now!
fault tolerant application phystrix library execution failure

Link: http://labs.qandidate.com/blog/2014/07/14/fault-tolerant-programming-in-php/

SitePoint PHP Blog:
Automate PHP with Phake - Real World Examples
July 10, 2014 @ 12:51:07

The SitePoint PHP blog has posted part two of their series looking at using Phake for automation in your applications. In this second part they take some of the basics they shared in part one and apply them in some more practical examples.

In part one, we covered the basics of Phake and demonstrated ways of executing tasks with it, covering groups, dependencies, and arguments. In this part, we'll look at some sample real world applications of Phake. Note that the following examples are largely based on things that I usually do manually that need some sort of automation.

He includes three different task examples, each with the code to make them happen (and descriptions of what it's doing):

  • Uploading Files to Server with a Phake task
  • Seeding the Database
  • Syncing Data

You can find out more about Phake on the project's GitHub page (including grouping, aborting and describing tasks).

0 comments voice your opinion now!
phake automate library tutorial part2 practical example

Link: http://www.sitepoint.com/automate-php-phake-real-world-examples/

A
July 07, 2014 @ 16:08:46

On the SitePoint PHP blog there's a new tutorial showing you how to automate your PHP development and deployment with Phake.

As developers, we often have to do repetitive tasks such as updating the database structure, seeding the database, writing CRUD code, running tests, and uploading files to a server. Wouldn't it be great if we could automate these mundane tasks and proceed with solving the more important problems such as making our app more secure or more usable to our users? Phake, an automation tool written for PHP, can do those tasks for you.

They show you how to use Phake (not to be confused with this Phake) including getting it installed via Composer and the creation of a first Phakefile. The include examples of simple tasks, dependencies, grouping, adding descriptions and passing arguments. The command to run the tasks and the resulting output is also included.

0 comments voice your opinion now!
phake automate introduction library

Link: http://www.sitepoint.com/automate-php-phake-introduction/

Lorna Mitchell:
Logging to Stdout with Monolog
June 09, 2014 @ 09:08:10

Lorna Mitchell has a quick post today showing how you can use the popular Monolog logging library to log messages and data to stdout, the standard output stream of whatever is executing the script.

My worker scripts have really basic logging (as in, they echo when something happens, and I can see those in the supervisord logs). Which is kind of okay, but I wanted to at least add timestamps in to them, and maybe send emails when something REALLY bad happened. I'm a huge fan of Monolog so I grabbed that, but it wasn't immediately obvious which of the many and varied options I would need for this fairly simple addition. It turns out that the right thing to use is the ErrorLogHandler.

She includes a few lines of sample code that use the "ErrorLogger" to output the message. It includes the log level, a timestamp, the message itself and any additional contextual information you pass in.

0 comments voice your opinion now!
monolog stdout output example library logging

Link: http://www.lornajane.net/posts/2014/logging-to-stdout-with-monolog

SitePoint PHP Blog:
Google's BigQuery Provides Free Access to GDELT
June 03, 2014 @ 10:19:31

In this recent post to the SitePoint PHP blog Bruno Skvorc points out a recent announcement from Google that the GDELT database information is now available via their BigQuery functionality.

The Global Database of Events, Language and Tone is one of the largest datasets on the planet. It is the quantitative database of human society, relying on thousands of news sources from every corner of the globe dating back to 1979. [...] Google BigQuery, "Google's powerful cloud-based analytical database service" is, basically, the world's fastest SQL engine, and it's completely free for any and all uses of GDELT. Due to the sheer power of BigQuery, you can get results on GDELT queries in near real-time and any permutation of fields and values you can think of won't be enough to bog it down to a halt - unless you really mess things up and go against the grain.

He goes on to describe the GDELT database and what kind of information it contains. He also includes an example query and the kind of data it returns (screenshot). He also links to a PHP-based library that you can install via Composer and use API keys to access their search endpoints.

0 comments voice your opinion now!
gdelt database bigquery access library sdk api

Link: http://www.sitepoint.com/googles-bigquery-provides-free-access-gdelt/

SitePoint PHP Blog:
Using Solarium with SOLR for Search - Advanced
May 08, 2014 @ 11:56:46

The SitePoint PHP blog has finished off their series showing you how to integrate searching with SOLR (via Solarium) into your PHP application. In this last part of the series, Lukas White gets into some of the more advanced topics around searching and handling the resulting output in your views.

In the first three parts we installed and configured SOLR and Solarium and started building an example application for searching movies. We've also looked at faceted search. We're going to wrap up the series by looking at some more advanced features of SOLR, and how to use them with Solarium.

He's broken up the rest of the tutorial to talk about a few of these more advanced features like:

  • Highlighting search matches in the output of documents (depending on the type of match)
  • Using the searching for an autocomplete
  • Configuring and making the request with an array-based configuration (a more manual process)
  • Adding additional cores to the search (allowing for more flexibility on search styles and configurations)

He also points to two other resources that could be handy along your path to SOLR dominance: the SOLR reference guide and the official Solarium documentation.

0 comments voice your opinion now!
solr search solarium library tutorial series part4 advanced

Link: http://www.sitepoint.com/using-solarium-solr-search-advanced/

SitePoint PHP Blog:
Using Solarium with SOLR for Search - Setup
May 02, 2014 @ 11:49:16

The SitePoint PHP blog has posted a tutorial showing you how to use the Solarium library to search SOLR. Solarium is a PHP-based, open source tool that helps make interfacing with a SOLR search instance much easier. This post is part one of a larger series covering the combination of SOLR and Solarium.

Apache's SOLR is an enterprise-level search platform based on Apache Lucene. It provides a powerful full-text search along with advanced features such as faceted search, result highlighting and geospatial search. [...] If you're using PHP then the Solarium Project makes integration even easier, providing a level of abstraction over the underlying requests which enables you to use SOLR as if it were a native implementation running within your application. In this series, I'm going to introduce both SOLR and Solarium side-by-side.

He starts with some of the basic concepts behind what SOLR is, what kinds of things it's useful for and how to get it installed on your system (using Homebrew). He shows how to set up a sample schema including a detailed look at the different types and required fields it will need. As this is just the first part of the series, it stops there and will get into the actual PHP code for the interface in the next edition.

0 comments voice your opinion now!
solr solarium search engine tutorial interface opensource library

Link: http://www.sitepoint.com/using-solarium-solr-search-setup/

InfoTuts.com:
Create Login With Google Plus in Your Website With PHP
April 15, 2014 @ 10:20:31

On the InfoTuts.com site they've posted a tutorial showing you how to make a "Log in with Google" button for your application and make it work with a little PHP magic on the backend.

So you want to allow users to login into your website using their gmail credentials? You have seen various websites that allow their users to login in their websites using gmail, facebook, linked in, Microsoft, git hub credentials. It's time to integrate it in your website. We will cover all the login system in our posts one by one and this one is dedicated to create Google Plus login for your website with PHP using OAuth2. Google offers many APIs like Google Maps, translate API, Analytics ApI etc. Today we will use its Google Plus API so lets proceed with our tutorial.

They break the process down into about five steps:

  • Login to Google API Console. Go to APIs and you will have to turn on Google Plus API.
  • Go to APIs and Auth and then under credentials tab. Click on create new client ID as shown below.
  • Now when you will have to enter your website path and the file path (redirect URI) to get your new client ID.
  • Now you have to set Consent screen.
  • In consent screen if you have entered Google Plus page path then you will have to approve connection.

The code for the actual connection is in the last step. It uses Google's PHP client libraries to configure and make the request, fetch the access token and grab the Google+ user's data.

0 comments voice your opinion now!
googleplus login oauth2 client library tutorial

Link: http://www.infotuts.com/login-with-google-plus-in-your-website-php

SitePoint PHP Blog:
Introduction to JadePHP
April 10, 2014 @ 10:30:30

Lukas White has posted an introduction to JadePHP to the SitePoint PHP blog today. JadePHP is a port of the popular Jade templating language more often used in Javascript.

There are dozens of templating engines out there, with options such as Smarty, Twig (used in the upcoming version of Drupal) and Blade (the default for Laravel) among the best known - as well as vanilla PHP, of course. [...] One which differs quite significantly from most is Jade, an engine usually associated with Javascript applications - it's supported out-of-the-box by Express for Node.js, for example. It's Jade I'm going to look at in this article; or more specifically the PHP port JadePHP.

He starts by briefly talking about HAML, a markup language that aims to make it easier and cleaner to write well-formatted HTML documents. Jade creates the entire document this way, meaning you could use it even without any templating needs (just outputting normal HTML pages). He shows you how to get started with the code and provides a simple example of a basic HTML page without any template objects to replace.He explains the markup and what each part does before moving on and showing how to add in the dynamic content and logic. He finishes off the tutorial by answering the question "Why use Jade?" touching on some of the good and bad of the templating engine.

0 comments voice your opinion now!
jadephp templating haml markup library tutorial

Link: http://www.sitepoint.com/introduction-jadephp


Community Events





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


interview configure refactor series podcast opinion unittest code framework testing install list experience introduction community developer language laravel release threedevsandamaybe

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