Category: Development

  • Building A Scalable Queueing System With PHP

    In today’s article we are going to cover building a queueing system with PHP.  Before we begin, let’s define what a queueing system is.  The best place to start is the dictionary:

    “to line up or wait in a queue”

    Now that we have our definition, let’s define why we would want to build a queueing system.  A queueing system is an excellent tool that will allow us to take a specific process and perform the functionality “offline”, e.g. the process will line up and we will process them one at a time at a later date.  This will probably be easier to explain with an example.

    Imagine an admin area of a website that allows the administrator to send out a mass email to all of their users.  The simple process to building this functionality would be as follows:

    1. Build a form that accepts a subject and a body for the email.
    2. Retrieve the list of users from your database.
    3. Loop through the users and send each person an individual email.

    The above example works nice and fast when there are only a few hundred users.  However, imagine trying to send this email to 10,000 users.  The administrator would be waiting a long time for this process to finish.  Not only that, if they closed the browser, it probably would not finish properly.

    So, the goal of our queueing system is to remove a specific process from running “online” (in a web browser) and running it “offline” with a scheduled task. (more…)

  • Publishing an e-book on Smashwords

    I feel a little bit behind in the times on this one, but I’ll work to catch up quickly.  Over the past year or so I’ve been compiling samples and I put together a book for developing CakePHP websites.  I saught publishing on the book, but unfortunately all of the big name publishers felt that CakePHP is too small of a market.

    After being rejected, I wasn’t too sure what to do with the book.  So, I left it for a while.  Then, earlier this week through some Google searching I stumbled upon the idea of an e-book.  Previously I’ve associated e-books with “Get rich quick schemes” as you see a lot of websites selling e-books along those lines.

    I started investigating this option a bit more and I found some videos about creating e-books with Adobe Indesign and formatting them for the various readers.  This quickly started sounding like a lot of work!  Instead I searched for other solutions.  That’s when I found it: Smashwords.  This is an incredible service.  You upload your Word Document and they automatically convert it for the over 10 e-book options out there!  Not only that, they will sell it and promote it on your behalf. (more…)

  • Interesting CakePHP Bakery Components

    I enjoy researching what other people are doing in the CakePHP world and I came across several interesting components at CakePHP’s bakery website:

    Wizard Component

    http://bakery.cakephp.org/articles/jaredhoyt/2010/09/10/wizard-component-1-2-1

    This component looks pretty neat and easy-to-use.  You import the component and set a list of steps that the wizard will traverse through.  You then create views for those steps with forms that submit to themselves.  The wizard will then process the form and proceed to the next step for you persisting the data along the way.

    Breadcrumbs Component

    http://bakery.cakephp.org/articles/rees/2010/08/14/breadcrumbs

    This is a component and helper all-in-one.  Inside your controllers, you define the breadcrumbs in each function and you alter your app controller to automatically render the breadcrumbs on each page for you making it a pain-less process to add breadcrumbs to your site!

    SMS Text Message Component

    http://bakery.cakephp.org/articles/donald_jackson/2010/08/14/component-to-send-sms-text-messages

    This is a component that is written specifically for Panaceamoblie that is a helpful service to allow your website to send SMS services.  It works very similar to the EmailComponent.

  • CakePHP 2.0 Rant Retraction

    In yesterday’s article, it appears I may have misunderstood something regarding lazy loading.  I incorrectly read it as “loading the data” on-demand oppose to loading the object on-demand.  This actually looks like a great feature, especially after reading this: http://bakery.cakephp.org/articles/Frank/2010/08/10/optimizing-model-loading-with-lazymodel

    It appears associated models would automatically be loaded simply because they are related to the model you are querying, even if you are not retrieving data from it.

    Thanks for the clarification on lazy loading Jose and I’m actually quite excited to see this change after further research into the situation.  Check out these benchmarks from the above mentioned article:

    Before lazy loading

    Total Requests made: 100
    Total Time elapsed: 6.8480186462402 (seconds)
    Requests/Second: 14.603 req/sec
    Average request time: 0.068 seconds
    Standard deviation of average request time: 0.002
    Longest/shortest request: 0.078 sec/0.066 sec
    Memory usage: 9.75MB

    Post lazy loading

    Total Requests made: 100
    Total Time elapsed: 4.8957378864288 (seconds)
    Requests/Second: 20.426 req/sec
    Average request time: 0.049 seconds
    Standard deviation of average request time: 0.001
    Longest/shortest request: 0.056 sec/0.048 sec
    Memory usage: 7.25MB

    Almost 6 full requests more per second!  Just in the 100 requests made there is over 2 seconds being gained!  Excellent work community!

  • CakePHP 2.0 Rant

    I was recently visiting the CakePHP bakery and decided to read a little bit about CakePHP 2.0-dev.  I’ve rather enjoyed CakePHP as a framework since version 1.1 all the way through to version 1.3.  However, after reading some of the “features” for version 2, I have to say, I’m a little disappointed about their focus. (more…)