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

Sameer Borate:
Creating Twitter Apps in PHP
September 29, 2014 @ 09:28:42

Sameer Borate has a post today showing how you can create a simple Twitter application in PHP making use of their REST API and the twitter-api-php library.

In this post we will look into accessing Twitter REST API in PHP. This can be useful if you need to post Tweets from your PHP application or anaylze, search Tweets. In the following examples we will use the twitter-api-php PHP wrapper for Twitter v1.1 API. Although there are a few wrappers around, this one I like for its simplicity.

He helps you get the library installed (via Composer) and create an application on the Twitter side at apps.twitter.com. Sample code is included showing how to connect to the API with your credentials, including handling the OAuth authorization piece. From there he shows two examples of action to make on the API: posting a new tweet and searching for new tweets based on a query string.

0 comments voice your opinion now!
twitter application tutorial introduction library oauth search post tweet

Link: http://www.codediesel.com/social/creating-twitter-apps-in-php/

Sameer Borate:
Data cleaning in PHP applications
September 22, 2014 @ 09:41:56

Sameer Borate has a new post today showing the use of a "cleaner" library to help sanitize the data input to your application. In this tutorial he introduces you to Mr Clean, an "extendible PHP Data Cleaner".

Scrubbers or data cleaners are an important part of the data transformation process. Whenever you are involved in some data import or export process, data scrubbers can help you clean and standardize your data elements before storing. There are many libraries that help in sanitizing and cleaning data. One such I recently found is mr-clean; it is a extendible PHP Data Cleaner that you can use in your PHP applications to clean heterogeneous data before storing it in your database or other persistent storage like CSV files.

He walks you through the installation (via Composer) and the creation of an instance of the main "cleaner" object. He then provides a few examples of some data scrubbing features it offers:

  • Basic scrubbing (trim, stripping HTML tags, etc)
  • Booleans
  • Filtering HTML
  • Stripping CSS attributes
  • Nullify
  • Null if repeated
  • Strip Phone Number
  • Pre/Post scrubbing handling

He finishes up the post with a look at creating a custom scrubber class, an "only numeric" handler that replaces any character that's not a number in a string with an empty string (removing it).

0 comments voice your opinion now!
data cleaning mrclean library introduction tutorial

Link: http://www.codediesel.com/data/data-cleaning-in-php-applications/

SitePoint PHP Blog:
Ardent Laravel Models on Steroids
September 19, 2014 @ 11:54:34

In Ardent, an enhancement to the model system in the Laravel framework that allows for easy configuration of validation rules.

One of the (few) things I don't like about Laravel is that you cannot move the validation code from your controller to your models easily. When I write software I like to apply the "fat models, skinny controllers" principle. So, for me, writing the validation code in the controller is not a good thing. To solve this, I'd like to introduce Ardent, a great package for Laravel 4. To be more precise, Ardent presents itself as "Self-validating smart models for Laravel Framework 4's Eloquent ORM." In other words: exactly what we need!

He introduces the library as a part of a test application, a To-Do list that includes user and task handling. He starts with the creation of the base Laravel migrations to build the tables and the code for the two necessary models. He then shows how to install Ardent and put it to use in the controller code, adding validation rules and messages for each property on failure. He also shows how to use the model auto-hydration and hooks to make working with the models even easier. He finishes off the post showing how to set up relations "the Ardent way" using a slightly different format as the usual Laravel handling.

0 comments voice your opinion now!
laravel model ardent library tutorial introduction

Link: http://www.sitepoint.com/ardent-laravel-models-steroids/

SitePoint PHP Blog:
APIfy Your Legacy App with Toro
August 19, 2014 @ 12:09:39

The SitePoint PHP blog has a new post that wants to help you API-ify your legacy application with ToroPHP, a router that's "designed for minimalists" to make routing and handling RESTful requests easier.

For the Google Summer of Code 2014, I was selected for a project to create a REST API for ATutor. ATutor has hundreds of thousands of lines of code, yet is written in core PHP. Introducing a PHP router class for the API was necessary, but we needed something unintrusive.

The result was the ToroPHP library. He introduces the library with some background about why it was created and some of the goals it was trying to achieve. Next he shows you how to create a simple "Hello World" endpoint that just defines the endpoint and echoes back the string. He shows how to separate out the logic from the route handling via the "urls.php" definition file. He also shows the handling of URL prefixes and mentions user authentication, making a "backbone" for the API and reuse of classes for similar objects.

0 comments voice your opinion now!
tutorial legacy application torophp library api rest

Link: http://www.sitepoint.com/apify-legacy-app-toro/

NetTuts.com:
Setting Up User Authentication in Laravel Using Confide
August 08, 2014 @ 11:05:24

NetTuts.com has posted a new tutorial recently showing how you can use Confide to set up authentication in a Laravel-based PHP application. Confide is a package specifically for Laravel that provides a lot of the usual needs for a user authentication system.

User authentication is part of almost every web application. Although it is common, a deeper look shows that it's not as simple as it may seem. Remember that validation, password recovery, and email confirmation are vital to any decent authentication form. Confide is an authentication solution for Laravel made to reduce the repetitive work involving the management of users. [...] In this tutorial, we'll start from the very beginning by creating our Laravel app using Composer and then: create a signup form with a full set of validation rules, a login form with a "forgot my password" option that will send a link for the user to redefine his password and use Laravel filters to only allow logged users can access a specific route.

The tutorial walks you through creating a simple Laravel application (obviously you can always use one you've already created) and getting Confide installed via Composer. Once you've added the provided lines to the Laravel configuration, you'll be ready to follow along with their examples. They run the migrations to set up the database and show how to view the user pages (and update their look to something a bit more friendly). The remainder of the post shows how to add in the pre-execute validation, via Laravel's filters, to ensure a user is logged in on certain routes.

0 comments voice your opinion now!
tutorial authentication laravel confide library

Link: http://code.tutsplus.com/tutorials/setting-up-user-authentication-in-laravel-using-confide--cms-21866

Reddit.com:
PHP library authors Have you considered to arrange security bug bounties?
August 06, 2014 @ 10:39:00

In this new post to Reddit.com Timoh suggests something that could definitely help improve the overall security of the PHP ecosystem - a bug bounty system, providing libraries and projects an easy way to security-related submissions for their code.

To encourage software security research on the open-source PHP libraries we use everyday, I have been brainstorming the possibilities for us, the code authors, to start to offer security bug bounties on the projects we maintain. It is a shame such a few PHP projects encourages security research by offering bug bounties, and I think it doesn't have to be this way.

He describes his ideas for the system including the ability to offer both monetary bounties and other kinds of recognition as well. Comments on the post are largely supportive, agreeing with him that it can definitely help things. He also makes the suggestion of getting frameworks with corporate backings (like Zend Framework and Symfony) to be some of the leaders and be an example to other projects and get them on board. What do you think? Add your own thoughts and suggestions about the project to the mix!

0 comments voice your opinion now!
bugbounty service project library zendframework symfony bounty recognition

Link: http://www.reddit.com/r/PHP/comments/2cpu6v/php_library_authors_have_you_considered_to/

SitePoint PHP Blog:
Using Guzzle with Twitter via Oauth
July 31, 2014 @ 10:54:01

Continuing on with his series about using the Guzzle PHP HTTP library, Miguel Ibarra Romero is back with this new post showing how to connect your PHP application, via Guzzle, to the Twitter OAuth protected service.

In a previous article, we found out about Guzzle and how it can aid us in the task of establishing communication with third party APIs over HTTP. We used it to get the output of a random number generator and for basic interaction with Github's API. [...] While interacting with Github's API we discovered that it supports basic authentication (sending plain username/password). But what if the API we want to use just offers OAUTH authentication?

He shows how to use Guzzle's own OAuth subscriber to make a basic connection to the API. He walks you through the installation of the subscriber (via Composer) and an example of its use. He explains each part of the code, giving a little background on where it fits into the OAuth request and where to put your API secret and key to make the connection work. Finally, he includes the code to handle the callback once the OAuth request is successful, grabbing the token data and adding it to the user session.

0 comments voice your opinion now!
oauth twitter guzzle http library tutorial

Link: http://www.sitepoint.com/using-guzzle-twitter-via-oauth/

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/


Community Events





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


deployment interview conference framework bugfix api community language symfony zendserver introduction voicesoftheelephpant series developer laravel podcast library list tips release

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