Feed aggregator

Phil Sturgeon: Testing and Contributing with Composer Packages

PHPDeveloper.org - Fri, 03/05/2013 - 18:47

Phil Sturgeon has posted a guide to his site about running tests and contributing back to packages that live in Composer.

While Composer has been around for a while now, many packages are still in their infancy (< 1.0) or sometimes are just not as feature filled as they could be. To be fair there is always more to be done. It can always do more, or do the same thing more efficiently. Whatever the case, pull requests are going to be a common thing for the PHP community to be doing to these packages and this needs to be done safely, with unit-testing. So, how do you run their test suite and add your own tests?

He includes a step-by-step guide to getting the environment set up to run the package's tests and how to add some of your own. He includes the commands to send the pull request back up to Github (on your own fork, of course) and how to use that same fork as your package resource until the main project is updated.

Link: http://philsturgeon.co.uk/blog/2013/05/testing-contributing-composer-packages

Sameer Borate: Efficiently Replicating RETS data to MySQL

PHPDeveloper.org - Fri, 03/05/2013 - 17:26

Sameer Borate has a new post to his site that shares how he converted a RETS database to MySQL with the help of a PHP library, PHPRETS.

A recent project of mine entailed replicating a RETS database on a local MySQL database server. The client had a new real-estate mobile search app in development and wanted to have a local copy of the RETS database for search queries instead of a remote RETS server. [...] Replicating RETS data rather than using the live version is slightly complex, however. In order to replicate the RETS data into your own local database, a series of processes are needed in order to make sure the data you have is both updated and in sync with the server.

He breaks it down into three main steps with some sample code for each:

  • Grabbing the complete database once
  • Keeping the data in sync
  • Ensuring the cron job is executed on regular intervals
Link: http://www.codediesel.com/data/efficiently-replicating-rets-data-to-mysql

Francesca Krihely: On the Developer Experience

PHPDeveloper.org - Fri, 03/05/2013 - 16:22

In a new post to her site Francesca Krihely starts looking at the developer experience - how developers relate to your service and product and what kinds of things you need to be doing to help engage them.

I had a great brainstorm a few weeks back with the members of the Developer Evangelists meetup on the topic of the User Journey, or as I'll call it now, the Developer Experience. The main problem we wanted to solve was how we convert new users into experts or awesoms users. In many ways, a Community Manager and/or Developer Evangelist is responsible for driving user adoption and making users successful, so this is a topic near and dear to all of our hearts. I walked away with three key things that help improve the developer experience: Great Product, Great Support and Empowerment.

This post talks about the first point - the "great product" - and notes that, if the product isn't useful and enjoyable to use, even developers won't bother with it. She also talks some about the need for quality documentation and how it can be seen as a sort of "marketing" to developers.

Work on making your product fit for an awesome developer experience. If you build it, they will come. Link: http://francescak.me/blog/2013/05/02/on-the-developer-experience

Community News: Packagist Latest Releases for 05.03.2013

PHPDeveloper.org - Fri, 03/05/2013 - 15:04
Recent releases from the Packagist:

Inviqa techPortal: Functionally Testing You Application Using Mink

PHPDeveloper.org - Thu, 02/05/2013 - 20:50

On the Inviqa TechPortal today there'a a new post from Konstantin Kudryashov showing you how to use Mink for functional testing (an extension of Behat) of you web application.

Automated testing is big news these days. There's hardly a PHP conference happening without a talk on testing automation or derivative methodologies. TDD (Test-Driven Development) and BDD (Behaviour Driven Development) are all around us. So why should you care about all this? [...] The more complex an application becomes, the harder it is to be sure that each new feature or bug fix won't break the system, and that decreases your overall confidence in your work as developer. That's exactly the reason why you need automated testing - to be confident that you're not breaking important parts of an application.

For his examples he uses a simple Silex-based application (found here on github) that just shows a main page and an "add article" page that returns a preview when submitted. He shows how to get Behat/Mink installed and how to bootstrap PHPUnit to allow you to execute your tests. Also included is a sample test that clicks the "Add Article" link, runs a few checks and fills in some data. The form is submitted and the "preview" page is checked for valid results.

Link: http://techportal.inviqa.com/2013/05/02/functionally-testing-your-application-using-mink

PHPMaster.com: Crop and Resize Images with ImageMagick

PHPDeveloper.org - Thu, 02/05/2013 - 19:14

PHPMaster.com has a new tutorial posted showing you how to crop and resize images with the help of the ImageMagick functionality that can be added to PHP (via this extension).

If your website allows users to upload photos, image cropping/resizing functionality certainly comes in handy. But users might not have access to image manipulation tools like Photoshop, so by providing a cropping/resizing feature you can allow users to upload photos from any device (e.g. tablets or phones) without them having to worry about the the final size. Furthermore, you can create different versions of the same image and also allow users to crop specific portions of uploaded picture. In this article I'll show you how to create an image cropping tool with the help of the ImageMagick PHP extension.

The post shows the use of the "cropimage" function to trim down an image from its original size and "thumbnailImage" to shrink down the image to make a thumbnail. Also included is the code (both the PHP and the HTML form) to handle file uploads and automatically create a thumbnail image. It outputs the image to the browser and asks the user to select the portion they want thumbnailed (with this jQuery plugin helping).

Link: http://phpmaster.com/crop-and-resize-images-with-imagemagick

MaltBlue.com: Use RouteMatch in Zend Framework 2 For Easy Routing

PHPDeveloper.org - Thu, 02/05/2013 - 18:14

In the latest to his site Matthew Setter takes a look at easy routing with RouteMatch in Zend Framework 2 applications. The RouteMatch component gives you better control over your routing and lets you define "match paths" for URL to Controller mappings.

Today using Zend Framework 2 RouteMatch, Router and Request objects, I show you an easy way to dynamically update the current route. It's almost painlessly simple. [...] Well, like most things in web application development, what starts out simply in the beginner often grows more complex over time. So too is my once simple route.

His "simple" route started getting a bit out of control when he added in some pagination to the page (and query for the path match). He wanted to figure out how to re-render data with the same filters but show the next page of data. He shows how to use the RouteMatch component to achieve just this. He creates a custom module with a "listViewToolbar" helper that lets you read the router, request and handle the parameters sent via the URL. The "invoke" method is called to render the toolbar in the page, complete with the new settings.

Link: http://www.maltblue.com/tutorial/use-zend-framework-2-routematch-for-dynamic-routing

SabreDAV acquired by fruux

Planet-PHP - Thu, 02/05/2013 - 17:58

Last week we have finished the talks to transfer ownership of the SabreDAV project to fruux.

I've been working at fruux as a lead-dev for some time now, and SabreDAV is really at the core of everything we do, so this was a logical and inevitable choice.

To me it's an important step. SabreDAV has been one of the very little things that have remained consistent in my life. This validates my work from the last 6 years a bit. In another way it feels a bit like I'm letting go something that's very important and personal.

However, I'll still be running the project so in reality the change for me personally is not that big :).

What's SabreDAV?

SabreDAV is an open-source project that I've started all the way 2007. It allows you to write WebDAV, CalDAV and CardDAV servers in PHP. These three technologies allow you to do file, calendar and addressbook syncing.

A few years ago steam really picked up, and it changed from the hobby project that it was back then, to something I could actually make a living off by doing consulting.

In 2012 I've took it one step further, and teamed up with fruux to build a commercial product around SabreDAV.

What will change?

Small stuff really. The GitHub urls have changed. The new project pages are:

A bigger change is that fruux will now be the official go-to place for commercial support. I feel this will strengthen the SabreDAV project, especially for the potential users that are into that sort of thing.

It also means that getting a new website is in the cards :). The current one has passed it's expiry date.

Does this mean SabreDAV will go closed-source?

No. I would never let this happen. SabreDAV will remain as open source as it has always been, and we also don't intend on making it crippleware.

The BSD license in place today is very liberal, and I feel that it's exactly this that has allowed many projects and businesses to adopt it. Taking that away would not only damage the project, it would also feel ethically wrong.

However, SabreDAV is primarily a library, suitable for integration into other systems. We're definitely looking into the possibility of offering a more complete package, such as a standalone server with solid management interfaces.

Thanks!

Thanks everyone for your continued support, pull requests and relying on SabreDAV for your projects :). It's the best reward, really.

If you're interested, also check out the announcement on the fruux blog

Categories: Open Source, PHP Community

Dougal Campbell: WordPress 10th Anniversary Blogging Project

PHPDeveloper.org - Thu, 02/05/2013 - 17:22

Dougal Campbell has a new post to his site with his own contribution to the "WordPress 10th Anniversary Blogging Project" - a remembrance of his history with the tool and where/when he first started using it.

The official 10th anniversary of the release of WordPress is May 27, 2013. It has been an amazing 10 years, during which WordPress evolved from a simple blogware to a very full-featured CMS (Content Management System), used to power some of the biggest and most popular web sites on the internet. All over the world, people are planning celebrations. As much as I like a good party, I thought this would also be a good time to celebrate WordPress by actually using WordPress - for blogging.

He talks some about when he got started with WordPress (2003) and what's happened since. He suggests that others follow suit and use the "#wp10" hashtag on Twitter to share their own posts.

Link: http://dougal.gunters.org/blog/2013/05/01/wordpress-10th-anniversary-blogging-project

Josh Adell: Serializing Data Like a PHP Session

PHPDeveloper.org - Thu, 02/05/2013 - 16:11

In this new post Josh Adell looks at working with PHP sessions and how you can manually encode data to look as if it came from the normal session handling.

If you have ever popped open a PHP session file, or stored session data in a database, you may have noticed that this serialization looks very similar to the serialize function's output, but it is not the same. Recently, I needed to serialize data so that it looked like PHP session data (don't ask why; I highly suggest not doing this if it can be avoided.) It turns out, PHP has a function that encodes data in this format: session_encode.

Unfortunately, this method doesn't take arguments - it just outputs the encoded version of the current session data. So, he came up with his own encode/decode methods that use the PHP session, extract the serialized string and return it.

Link: http://blog.everymansoftware.com/2013/05/serializing-data-like-php-session.html

Community News: Packagist Latest Releases for 05.02.2013

PHPDeveloper.org - Thu, 02/05/2013 - 15:01
Recent releases from the Packagist:

Functionally Testing Your Application Using Mink

Planet-PHP - Thu, 02/05/2013 - 12:49

Automated testing is big news these days. There's hardly a PHP conference happening without a talk on testing automation or derivative methodologies. TDD (Test-Driven Development) and BDD (Behaviour Driven Development) are all around us. So why should you care about all this? Well, there are many excellent reasons to do automated testing, including assuring application quality and inspiring developer confidence in a system. If you are a business person, you're most likely to care about the quality; if you're a developer then the confidence aspect is more important. The more complex an application becomes, the harder it is to be sure that each new feature or bug fix won't break the system, and that decreases your overall confidence in your work as developer. That's exactly the reason why you need automated testing - to be confident that you're not breaking important parts of an application.

Now you're convinced that automated testing is important, but isn't unit testing enough? Unit tests are cheap, fast and small. Why might you want to expand into using a technique such as functional testing? Once again the answer is confidence. The more complicated an application becomes, the more complicated the interactions between separate parts of the application become. Just as you can't be confident your car is roadworthy by manually turning each of its wheels independently, you can't be sure that an entire application is working by testing each of its units independently. You need functional testing for complex applications - and today, that's every application.

Silex

Silex is a PHP microframework based on Symfony2 components. It has rapidly become a popular tool in the Symfony2 community thanks to its simplicity and shallow learning curve. That said, the simplicity of Silex does not mean that it is only fit for simple applications, in fact the opposite is true. Some types of application, like RIAs (Rich Internet Applications) are better built with PHP and the minimalism of Silex.

As an application becomes more complex, so it becomes more important to properly test it. Silex provides some tools for functional testing using the Symfony2 BrowserKit component. This is useful, but what if some of of the application's functionality requires real HTTP requests to be made? Those could be done using a console browser emulator like Goutte. How about if some functions depend on AJAX to behave properly? Using Selenium or even Zombie.js could be a good option in that case.

There are two problems with all the solutions mentioned here:

  1. There's simply no single best choice in terms of browser emulation. Some emulators (BrowserKit, Goutte) are extremely fast, but don't support AJAX. Others (Zombie.js, Selenium) support AJAX but are much slower. In an ideal world, you would want to use multiple emulators at the same time, choosing the best one for each specific case. That leads us to problem #2.
  2. Different browser emulators are written in different languages (PHP, JS, Java), using different libraries and provide extremely inconsistent APIs for developers to work with. That means it is difficult to switch from one emulator to another as it will require all helpers and testing tools be rewritten.

Mink

To help solve some of these problems, a library called Mink was written. It was created originally as a complementary tool for Behat, but is not tightly coupled to Behat itself and so it can also be used with any framework or tool out there. Mink is a browser emulator abstraction layer - a tool that removes the differences between the various browser emulators and provides one single API through which you can control them all. This essentially means you can switch from browser emulator to browser emulator quite seamlessly as they all use the same PHP API. This article will show you how to use Mink to functionally test an example Silex application using a couple of different browser emulators.

Setting Up

As our test application we'll use a very simple Silex blog application that is already prepared for you. The code is on github at https://github.com/everzet/silex-mink so use that as your starting point.

Set Up the Test Suite

In order to install and integrate Mink, Silex and PHPUnit, some extra entries are needed in composer.json. The new sectio

Truncated by Planet PHP, read more at the original (another 37475 bytes)

Categories: Open Source, PHP Community

Universal Database Tools - DtSQL 2.4.1 is released (FREE)

Postgresql.org - Thu, 02/05/2013 - 02:00

DtSQL is a FREE universal database query and editor tools for developers and database administrators to Query, Edit, Browse, and Manage Database objects such as tables, views, indexes, procedures, functions, triggers, contraints and sequences. It can access most databases and can be used on all major operating systems.

  1. Supported databases : Cache, DB2, Derby, Firebird, FrontBase, H2, HSQLDB, Informix, Ingres, JDatastore, MaxDB, Mckoi, Mimer, MySQL, Oracle, PointBase, PostgresSQL, Solid, SQLite, SQL Server, SQL Anywhere, Sybase (ASE).
  2. Support Operation Systems : Windows, Linux and Mac OS.
  3. Database Browser Tools : browse schemas, tables, columns, primary and foreign keys, constraints, views, indexes, triggers, stored procedures, functions, sequences, and so on.
  4. Database Tools : create, alter, view and drop database tables, views, indexes, constraints, stored procedures, functions, triggers, sequences, and so on.
  5. Database Management Tools : edit database table data including binary/BLOB and CLOB data types. Filter, sort and search query result. Insert, duplicate, update, and delete database table data. Find and replace database data, preview generated SQL. Redo or undo last table data change before update is commit.
  6. SQL Tools : tools to edit, format and execute SQL scripts.
  7. SQL Builder : help tools to build database select, insert, update, delete SQL scripts.
  8. Import Data : tools to import data from various formats such as CSV files, Excel files, and fixed-width files. Parse import data according to integer, date, time, timestamp, and boolean pattern.
  9. Export Data : tools to export database data (single table/multiple tables/query result) in various formats such as CSV files, Excel files, XML, HTML, SQL insert statements and fixed width files. Format export data according to applied integer, date, time, timestamp, and boolean pattern.

  10. FREE to use.

  11. Home: http://www.dtsql.com

Categories: PHP Community

Chris Hartjes: Testing Smells - Try/catch

PHPDeveloper.org - Wed, 01/05/2013 - 18:42

In this new post to his site Chris Hartjes gives an example of what he calls a "testing smell". This particular illustration deals with the poor handling of testing and exceptions with try/catch blocks.

As part of a project to migrate the PHP code at work from PHP 5.2 to PHP 5.4, I'm using our extensive test suite to look for instances where something that changed between the versions of PHP that we are using has caused some unexpected behaviour. In one of our code bases, I found some tests that are exhibiting a test smell through their use of a try / catch block in the test itself.

He includes a (contrived) example showing the use of an exception in a unit test to run an assertion in the "catch" for the test to pass. He points out that this particular check is being done to see if the user input is valid...and that it's a bad way to enforce it using exceptions. He also suggests that if you have an "if" situation, don't use one test with logic in it, write two tests. He mentions a disenting opinion but notes that a failing test is a failing test, regardless of what caused the failure.

Link: http://www.littlehart.net/atthekeyboard/2013/04/30/testing-smells-try-catch

php|architect: April 2013 Issue Released

PHPDeveloper.org - Wed, 01/05/2013 - 17:16

The php|architect magazine has released their latest issue - the April 2013 edition focusing on security:

The April issue is out and it's all about Security! We cover the gambit of topics including two-factor authentication, password hashing and securing file uploads. All our regular columns also appear, making this a jam-packed magazine full of PHP goodness.

Articles in this month's edition include:

  • Securing File Uploads - Chris Tankersley
  • Best Practices for Password Hashing in PHP - John Congdon
  • Security-driven Development - Beth Tucker-Long
  • When a Password Isn't Enough: Two-factor Authentication and You - Chris Stone

Check out the php|architect site for more info on picking up your own copy.

Link: http://www.phparch.com/2013/04/phparchitect-april-issue-security

Alvaro Videla: Using RabbitMQ in Unit Tests

PHPDeveloper.org - Wed, 01/05/2013 - 16:10

Alvaro Videla has a new post today showing how he used RabbitMQ in his unit testing runs with a small, quickly installed version of the server that can be removed once the tests are complete.

In this blog post I want to show you a very simple technique for using RabbitMQ in our Unit or Functional Tests. Let's say you wrote a bunch of tests for your RabbitMQ consumers and then it's time to run them. To do that you probably need to setup a RabbitMQ server just for tests with their own users and passwords, or you need to set up a whole new virtual host for your tests. [...] With a future release of RabbitMQ that we can already test on the nightlies website, we can run RabbitMQ without the need to install Erlang. We created a package that ships a stripped down version of Erlang together with the broker bits, so running RabbitMQ now is as easy as downloading a tarball, uncompressing it and starting the server.

With a combination of this more self-contained package and some listener handling through PHPUnit, they uncompress the tarball with a PHP script and start the server with the defined configuration. Then, once the tests are done, it cleans itself up and removes the entire server directory to make for a clean run the next time.

Link: http://videlalvaro.github.io/2013/04/using-rabbitmq-in-unit-tests.html

Community News: Packagist Latest Releases for 05.01.2013

PHPDeveloper.org - Wed, 01/05/2013 - 15:05
Recent releases from the Packagist:

Community News: Latest Releases from PHPClasses.org

PHPDeveloper.org - Wed, 01/05/2013 - 14:00
Syndicate content