A PrestaShop module helper to display “boxed” success and error notifications

First, a little bit of theory:

PrestaShop (PS) implements the concepts of modularity and extensibility through two different entities:

  1. modules
  2. hooks

The first ones are actually wrappers for the custom functionality you may need on your store while the latter ones are the connection points offered by the PS core.

Continue reading “A PrestaShop module helper to display “boxed” success and error notifications”

A little bit of metaprogramming with PHP

I should admit it. After writing more and more Ruby code and get into its beautiful Object Model it feels rather strange to go back to PHP.

What I miss mostly is the syntactic sugar and the less verbose syntax.

You don’t have to put dollar signs before variables names, semicolons at the end of statements and most of the times you can also omit method parentheses (i.e. when there are no ambiguities).

But beware! Omitted parentheses could lead to unexpected behaviors and bugs that could be hard to find! So you’d better indulge on this sugar only if you know what you’re doing.

Continue reading “A little bit of metaprogramming with PHP”

WordPress and OpsWorks, “Pride and Prejudice” (Part 2)

Here we are for Part 2 🙂

In my last post about WP and OpsWorks I tried to explain the general setup for the recipes that I’ve developed to automate the deploy of WP applications through OpsWorks. If you missed it here’s the link.

Today I’m gonna talk about a particular problem that I encountered while writing the recipe that currently handles the database importation.

Continue reading “WordPress and OpsWorks, “Pride and Prejudice” (Part 2)”

WordPress and OpsWorks, “Pride and Prejudice”

Disclaimer: this is not a comprensive tutorial nor a step by step guide on how to set up a WordPress site through Amazon OpsWorks.

I’m reporting only my personal experience and a few tips (borrowed form my colleagues) on how to write some recipes and how to use them to manage and deploy a WordPress website via OpsWorks.

But don’t despair, this may become the first article of a series dedicated to WordPress and OpsWorks.

Ok, let’s begin.

Continue reading “WordPress and OpsWorks, “Pride and Prejudice””

Download a CSV in PHP…use ob_clean()!

There are many blog posts, guides, code snippets and stackoverflow answers that describe how to create and download a CSV file in PHP.

Anyway none of them helped me the last time I was asked to do that in the context of the configuration panel of a PrestaShop module.

Continue reading “Download a CSV in PHP…use ob_clean()!”

It’s all about the context…or better, $this->context!

It has great power and it should always be considered.

It’s the context.

No matter what, it always influences the topic under discussion, be it a specific dissertation, a discussion with other people or a PrestaShop (PS) module.

Well in the last case I learned it the hard way.

Continue reading “It’s all about the context…or better, $this->context!”

Keep you up-to-date or…get lost! (PHP won’t forgive!)

PHP is getting some pretty nice feature on each new release.

However most of the versions provided by the hosting providers don’t perfectly align with the evolution of the language.

In this situation you should really take care on how you write your code!

One example?

Function array dereferencing or if you prefer:

foo()[0]

You like it eh 😉

Unfortunately this is available only up from version 5.4.0.

If you’re handling some projects that are hosted on servers shipping an older version of the one over mentioned 5.4.0 think twice before start doing what you like 😛

P.S: self experienced 😉