Blesta 3.0: Developer Docs

June 8, 2012
Cody

With a private alpha release due out soon, we’re gearing up to help developers take full advantage of the 3.0 platform. Our goal is to make it as easy as possible to build really advanced plugins, widgets, gateways, and modules. To facilitate that we’ve written some detailed interfaces and libraries, as well as put together a pretty in-depth developer manual. And while the v3 source is almost entirely open, I figured what the heck, how about some source code documentation? So I created Doctorate.

Doctorate is a simple plugin for minPHP that documents source code using Reflection. Being able to read the source documentation without actually having to open the source code is a huge advantage. But because the Blesta API is just a simple access wrapper for the Models it’s a huge time saver for us. It would take months to document every API request (there are hundreds and hundreds), but Doctorate does it automatically.

Here is a sneak peak of the source code documentation from Doctorate…

Doctorate - Source Code Documentor

Here is a sneak peak at the developer manual…

So when can you expect to get your hands on the developer manual and source documentation? If you’ve made it onto our developer list you can take advantage of these resources as soon as alpha is released. When 3.0 goes into beta we’ll make the documentation public.


Blesta 3.0: Payment Handling

June 1, 2012
Paul

We’ve talked about payments before, but this week I wanted to go a little more in depth. The way payments are handled and applied by a billing system is important, things need to be accounted for.

Some popular billing systems do really strange things, like..

  1. Create a new invoice when someone attempts to pay multiple open invoices for the sum of those invoices, and when that invoice is paid mark the others as paid.
  2. Allow staff to mark an invoice as paid without recording a transaction.

Simply put, this leads to an accounting nightmare. If an invoice is marked paid, surely there should be a history of how and when that invoice was paid, right? Absolutely! Blesta handles this well in v3, but that’s not a new feature!.. We’ve been accounting for everything since the beginning.

Good billing software will let you pay a single invoice with multiple payments, and pay multiple invoices with a single payment. It should keep track of how much of which payments were applied to which invoices.

In this screenshot you can see that 2 payments were made to a single invoice, and the invoice still isn’t paid in full yet. (Click image to see full size)

It all comes down to this: We want to do things right, and we spend the extra time to do it right when others don’t. It’s this way with everything we do. We engage every feature with purpose and forethought. It’s about creating great software whether we sell a thousand copies or a million copies.


Related Tags:

Blesta 3.0: Efficiency

May 18, 2012
Cody

As lead developer, my primary focus has been on designing an efficient system. Since our primary data store (where we make the most reads/writes) is the database, naturally this is where the smallest change can have the biggest impact. I’ve already discussed a number of changes we’ve made to the database system including switching to InnoDB and the use of PDO. The last is the use of unbuffered queries.

Buffered Queries

Buffered queries fetch (e.g. buffer) all records into memory from the database server and automatically close the cursor, allowing other queries to be executed. You might take this for granted. For example, you may have something like:

<?php
// What looks like 'nested' queries...
$statment = mysql_query($sql);
while ($data = mysql_fetch_assoc($statment)) {
    $statment2 = mysql_query($sql2);
    while ($data2 = mysql_fetch_assoc($statment2)) {
        ...
    }
}

This might be all fine and dandy, but assume that the first query finds 1,000,000 rows. If each row contained just 1 KB of data, that’s 976 MB of memory consumed! Keep in mind that the memory is consumed at mysql_query(), so it doesn’t matter how many rows you actually fetch (using mysql_fetch_*). Moreover, the memory isn’t freed until the program terminates or you explicitly invoke mysql_free_result().

Unbuffered Queries

Unbuffered queries, on the other hand, are not buffered into memory. Each row remains on the database server until fetched. This can drastically reduce memory consumption on the web server.

The only downside is that you can’t create what look like “nested” queries (as in my example above). But that really isn’t a downside at all, because it forces you to look at better methods for fetching or querying data. Like limiting your result set and fetching all results.

The Record component in Blesta, in conjunction with PDO, make unbuffered query support almost seamless. You really only need to be concerned about closing the cursorif you’re explicitly working with PDOStatement objects.

<?php
// Manually work with the statement...
$users = array();
$user_stmt = $this->Record->select()->from("users")->getStatement();
foreach ($user_stmt as $user) {
    $users[] = $user;
}
$user_stmt->closeCursor();
 
// Or just let the Record component to handle it all...
$users = $this->Record->select()->from("users")->fetchAll();

While the benefit of unbuffered queries may not be entirely evident on small data sets, there’s no doubting it improves efficiency. And that’s what creating an enterprise-level application is all about.


Blesta 3.0: Currencies (video)

May 4, 2012
Paul

I came into work this morning with literally no idea what the video was going to be about today. I have a list of topics, but nothing felt right and then I realized we haven’t really talked about currencies much. It’s part of a larger topic, Internationalization, and with what we’re doing with language support and the translator it only makes sense that we should discuss currencies.

Of course, a big part of currencies is multi-currency support and v2.5 has it, but it’s much improved in v3. In v2.5, multi-currency has to be explicitly enabled and everything revolves around the default currency. While v2.5 can accept payments in many currencies, clients are billed based on the exchange rate to the default currency. So, the biggest difference between v2.5 and v3 is that prices can be specified at the package level for each individual currency, effectively fixing prices. Only when a price is not available for the currency does the exchange rate come into play.

  1. Prices can be set for each currency at the package level, which overrides the exchange rate.
  2. Multi-currency doesn’t need to be enabled, just use it if you want to use it.
  3. Exchange rates can be fetched from Foxrate, Yahoo Finance, or Google Finance.
  4. Exchange rate updates can be disabled and exchange rates manually updated.
  5. New package period options Day, Week, and Year in addition to Monthly and One Time.
  6. Cancellation fees can be assessed and configured at the package level.

Interesting fact! With Day, Week, Month, and Year package period options now available, terms can range between 1 and 65535 (216 – 1) which equates to 65535 * 4 + 1, or 262,141 possible service terms available. So much for just monthly, quarterly, semi-annual, and annual huh? Do your own thing.

The video is below, as usual you can make the video full screen, and be sure to turn on your sound.


Blesta 3.0: The Translator (Update)

April 27, 2012
Paul

In January we announced the availability of a language crowdsourcing project, the Blesta Translator. The goal of the project is to facilitate the translation of Blesta into many languages, and to ship these languages with Blesta, starting with version 3.

This week we made a few additional changes live, and they are –

  1. Added Nederlands, NL (nl_nl) to the list of available languages
  2. Added a machine translation (Google) for reference
  3. Added “In Order” and “For Confirmation” translation methods
  4. Added some context to language strings including terms, filename, and type

#2 Machine Translation

The machine translation is available for all translation methods, “Random”, “In Order”, and “For Confirmation”. By default it is not displayed, but will be shown when a link is clicked. The idea is that it may be useful to see the Google translation, but that it shouldn’t be relied on, or copied without forethought.

#3 Additional Translation Methods

The goal of the translator isn’t simply to get translations, but to get good translations.

When different people translate a term identically, it has a higher weight than terms that are only translated by one person. Such terms become “confirmed”, and are trusted to be more accurate. So, the “For Confirmation” translation method displays the best possible translations by other people. One of these translations can be accepted by clicking on it. Alternatively a different translation may be entered like normal.

The “In Order” translation method is pretty self-explanatory, terms are given in alphabetical order with the goal of completing a translation. This means that some terms may be skipped initially until the translation is completed as a whole. Once the translation is completed, terms that were intentionally skipped will be presented.

The end goal is to make several translations available. A version translated wholly by a specific person, a confirmed only translation that may be missing some terms (missing terms are shown in the default language), or a complete translation consisting of confirmed only or both confirmed and unconfirmed terms. The latter are the ones we will include with Blesta by default, but all will be available for direct download in the future.

Thanks for reading! If you know another language, please sign-up and contribute

Video next week? Probably.


Top