Testing Javascript: Get started with Jasmine

Javascript has come a long way since its humble beginnings of making things underlined when a cursor passes over them. The "modern" website uses a whole bunch of libraries and tools to provide both snappy UX and connectivity-tolerant usage, allowing both mobile and desktop users far more usability than ever before. Such a new dependency on sites to elevate Javascript to a first-class citizen in the application comes with a proportional need to test that everything works in all the browsers the audience is using. Tools like Jasmine have played a big part in Javascript’s maturation, allowing software to be written with greater certainty. This article will introduce unit testing, show you how to set up Jasmine, and cover how automation with Karma can streamline your work.

How to use Magento 2's new in-built A/B testing tool

One of the best-kept secrets of Magento 2 is that it is the first version of Magento that offers ‘out of the box' ability to do A/B testing - no need for plugins, or custom development. If you are using Magento 2 Enterprise edition, it's ready for you. There is scarcely a mention of this in the official user guide, so here’s our tutorial for A/B testing with Magento 2.

Magento 2 tutorial: how to install with Composer

Welcome to our Magento 2 pocket guide for Composer. This guide will introduce you to Composer and demonstrate its applications with Magento 2 with a little bit of Git thrown in. By the end of this guide you will have a solid understanding of how to install Magento 2 via Composer, know what Composer can offer for other projects, and see how it can be used as a base to work with Git that mimics other modern PHP frameworks.

How to build an extension for PHPSPEC

I recently launched a new extension for PhpSpec, something that was a lot of fun, but also made me realise that building an extension allows you to learn so much more about the tool you are building for and about design philosophies. I want to share my experiences to offer a reference point for other engineers thinking about building an extension for their tool of choice.

Extending Magento with patches

When working with Magento, the need to extend and alter core functionality is something that comes up frequently. Fortunately Magento provides a fairly robust rewrite system to facilitate this, so creating a class that extends a core Magento object, and making Magento load your class in place of the original, is trivial. There are plenty of resources for rewriting core Magento functionality, so I’m not going to dwell on that mechanism here.

Manage project dependencies with Bower and Composer

As developers, most of us rely on third-party libraries as part of our web applications. PHP developers manage their dependencies with Composer, but how can you manage your client-side dependencies? Most projects start with one core JavaScript library (e.g. jQuery) and one or two plugins, but over time the application grows, and the list of JavaScript libraries grows as well. In this situation, Bower can help you, and in this article you will see how to integrate it into your own project.

Let RabbitMQ do the work in your Symfony2 application

Many of the high-performance websites we create nowadays must sometimes perform tasks that take a relatively large amount of time, such as sending an user an email after registration, creating a thumbnail from an avatar, or processing a large XML or CSV import file. Some of these tasks require a lot of memory, others just take time to complete. It would be great to avoid a delay for the user who just registered and needs us to send him an email or to have a nice, scalable architecture to parse big files efficiently.

Profiling with XHGUI

Profiling is a technique for observing the performance of an application, ideal for showing up bottlenecks or particularly intensive use of resources. Profiling gets inside your application and gives information about the performance of the various parts of code that are used during a request, so as well as being able to identify which requests may have problems, we can also identify where in each request any performance issues actually lie. We have a choice of tools for PHP but in this article we'll focus on an excellent tool called XHGui. XHGui is a tool built upon XHProf, the profiling tool released by Facebook, but adding better storage of metrics and a much nicer interface for retrieving information from it, to the extent that it feels like a new tool in it's own right!

SSH tips and tricks

We often have to work with remote servers in our jobs as developers. For simple projects you might chose FTP (or SFTP), which is fine for copying files, but for more complex applications which require more complex deployment processes, you will need something more powerful. There are many ways to access remote systems but SSH is probably one of the most widely used; deeper knowledge of it may simplify a developer's tasks and allow them direct access to a remote operating system in a fast and secure way. This post shows how to use SSH: not only to connect to a remote server, it shows how to use SSH in secure way and how to use it to automate tasks, and includes tips for all kinds of users. Developers may learn how to access remote databases behind a firewall, administrators will be interested in mosh (mobile shell) or the parallel execution of tasks, and even project managers may want to use an SSH proxy to bypass limitations of guest wifi during meetings. We'll start out with some tips for tackling the unexpected.

PHP test doubles patterns with prophecy

Test doubles are a way of replacing all classes in our tests other than the one we are testing. They give us control on direct and indirect outputs that would have been generated by those classes. Understanding the role of the test double helps us to write better tests, and thus better code. If we manage to isolate the "collaborators" (the other objects involved in our test) using doubles and test our objects in isolation, then we have achieved modularity: our code is decoupled and the communication between objects is documented by our tests. When writing unit tests we are focusing on describing one unit of behaviour at a time, and how objects communicate in order to achieve that behaviour. We instantiate the object under test, call a method of the object and observe if the outcome is as expected.

Functionally testing your application using MINK

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 Design) 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.

New relic for PHP: web application performance monitoring

The performance of a web application plays a critical role in how an application is perceived by its users. It is important to measure it, identify the causes if it changes and react swiftly to any unexpected changes. This article describes an industry leading tool, New Relic, and how it can be used to monitor and improve your site performance.

Manipulating HTTP with Charles Proxy

Charles Proxy is exactly what its name implies; a proxy. This proxy is special however, as it is specifically aimed at giving functionality that developers will need. It allows you to view, change and replay the traffic that passes through, and can handle SSL. Charles isn't free, but at $50 (at the time of writing) for a license, it reaps returns from day one. This article will show you how to start using Charles and covers techniques that will help you work with your web and mobile applications; basically anything that works over HTTP.

MYSQL alternatives to MYSQL

Have you been using MySQL for your web applications since your first foray into website development? Perhaps you now run, or are thinking about running, your own server and you will set up MySQL because that is what you have always used. Did you know there are alternatives? A NoSQL database is one of them, and it has its use cases, but that will need some consideration, and almost certainly some rewriting of your application, to take advantage of. Instead, let me talk to you about some databases that speak your applications language, namely MySQL's client server protocol.

Behaviour driven development in PHP with Behat

Outside-in Development is an agile development methodology that places the intention and goals of the stakeholders at the centre of the process. This is achieved by having human-readable user stories and scenarios being invoked as scripts that feed back on the progress, continuously leading the development towards the stakeholders’ goal. Developers will start from this executable specification, and write the high level controllers that will provide the functionality. They then go into what they need to provide that functionality by specifying how their library class should work. By the time all classes’ specifications are met, all scenarios will also be fulfilled and the cycle is complete.

How to create user stories

Gathering requirements for software development is a vital communication process. There are multiple parties involved and a project relies on customers, users, domain experts, and many others, each with their own view of how the system should function. We will look at how user stories can help us to gather the information we need for a successful project.

Doing the heavy lifting: Gearman and Magento

With most web applications, there comes a time where there is a need to perform either CPU or I/O intensive work based on user actions. Whether processing uploaded files, or performing system-wide database updates, developers are increasingly turning to Gearman as a simple way to hand off the heavy lifting to another server to be performed asynchronously.

Database version control

Version control for source code is used by most development teams today. It gives you a history of all the changes you made, you can use it to share your code with others and you can work on an experimental feature without polluting the stable product. These are just some of the reasons why version control software is considered indispensable today.

Unit testing databases with zend framework

Testing the database layer is a fundamental step during application development. It allows us to ensure that all data operations behave properly, without data loss or corruption. In this article, we are going to describe a simple way to test the database layer of our applications, using PHPUnit database classes, Zend Framework extensions and some custom reusable code to facilitate the process for all the domain models. This article will walk you through, step by step, for each of the tasks needed to achieve this.

Using MongoDB in PHP applications

After recently attending the MongoUK conference in London, it is clear that MongoDB is fast finding application amongst cutting-edge web developers. As a relatively new concept for persistence, NoSQL (Not Only SQL) and more specifically document-oriented databases, such as MongoDB, are starting to enter the web applications landscape. Its strength lies in speed and ability to cope with dynamic data, making its goals align closely with requirements of many websites around today.

Adding Static Blocks in Magento

Static blocks are blocks of content which are created and modified through the Magento Admin. Their main purpose is to act as a dynamic piece of content which can be placed on one or multiple pages, highly customisable and allows clients to modify the content through the admin area. They’re ideal for sections of you site where you need to display a piece of content which is likely to change throughout the course of the site’s lifetime and the piece of content doesn’t require its own page like About Us or Terms and Conditions pages...

Designing a Magento custom module – a technical overview

The purpose of summary is to deliver a good reference guide to keep with you when developing custom modules with eCommerce solution Magento. It details some of the key sections of how to build a custom Magento module, some of the concepts, assumptions and key points that that you are likely to encounter on a regular basis when building eCommerce installations with this software. While Magento does not currently have a great reputation for documentation, there are some good resources available, including the Magento Wiki and php|architect’s Guide to Programming Magento...

Web services for PHP developers

In this world of sharing data, increasing numbers of sites and applications are making information available over web services. Whether we are building a service as a feature of our own development, or pulling in the information published by others, we will need to understand the different service types and how to work with them in PHP. This article aims to give you the tools to do just that.

Tips for working with datetime in PHP

Recently we published a post about tips for dates and times in PHP, today I thought I'd follow on from Michael and add some more tips. In PHP 5.2 there is an object oriented approach to working with dates and times - the DateTime class! In the newer PHP 5.3 versions even more excellent functionality was added. This is a short post to introduce this functionality with a focus on the methods available in PHP 5.2 showing some simple examples of how we can more easily manipulate and display dates without needing to work with timestamps.

Scaling web applications with HMVC

The last decade has been witness to the second iteration of web design and development. Web sites have transformed into web applications and rarely are new projects commissioned that do not involve some element of interactivity. The increasing complexity of the software being developed for the internet fuelled a requirement for structured and considered application design.

PHPLOC: PHP lines of code

With the growing use of continuous integration and static analysis tools hooked into those processes, there is a particular analysis tool that is very useful but rarely mentioned: phploc, the PHP Lines of Code tool. This has been a feature of PHPUnit for some time but has been released as a separate project in the phpunit pear channel. The nature of PHPUnit means that many of these statistics can be collected while the tests are running, which is why it was added to that tool in the first instance.

Transforming XML with PHP and XSL

If you want to transform XML from one format to another, and especially if either the input or output XML is complicated or the transformation itself is difficult or awkward to express, then XSL may be a good choice. XSL is the eXtensible Stylesheet Language; a family of three W3C recommendations to do with the transformation and presentation of XML documents. This article will walk through some examples of how XSL and PHP can be used to achieve these types of XML tranformations.

Profiling with XHPROF

If there's something we developers are really bad at, it's guessing. We think we know which parts of our application are slow, and spend a lot of time optimising those, but in reality the bottlenecks are often somewhere else. The only sane thing to do is measuring, with the help of some profiling tools.

Using PHP_code_sniffer

PHP Code Sniffer (PHPCS) is a package for syntax checking, available from PEAR. It can check code against defined rules covering anything from whitespace through doc comments to variable naming conventions and beyond. In this article we'll look at getting started with PHPCS, using it to syntax check our files, and go further to look at how the rules are create and the standards defined.

Graphs in the database: SQL meets social network

Graphs are ubiquitous. Social or P2P networks, thesauri, route planning systems, recommendation systems, collaborative filtering, even the World Wide Web itself is ultimately a graph! Given their importance, it's surely worth spending some time in studying some algorithms and models to represent and work with them effectively. In this short article, we're going to see how we can store a graph in a DBMS.

Getting started with Memcached

Memcache is a tool which can cache objects in memory – and is often used for speeding up dynamic web applications. PHP has a built-in module for working with memcache, and its a simple and convenient way of introducing caching to your application. PHP has a PECL module for talking to memcached – look up how to install for your system, but be aware that it isn't bundled. It's a good module to include on your system however, quite a few apps will take advantage of it where available.

Pages