Updates from June, 2012 Toggle Comment Threads | Keyboard Shortcuts

  • danielsaidi 12:49 pm on June 20, 2012 Permalink | Reply
    Tags: , implementation, ,   

    Wigbi 2.0 – It’s still alive 

    Wigbi logo

    Yes, I am still working on a new version of Wigbi. By working, I really have to specify it as “sitting down with the code one evening or so every three months”…but it’s fine. I like where it is heading and just play around with it whenever I find the time.

    In Wigbi 2.0, focus will be on specifying what features it has in interfaces, then for the first version only create the most basic implementations to make it work. This way, Wigbi 2.0 will be way more flexible than 1.x ever was. Releasing updates and new implementations will be trivial.

    For instance, Wigbi 1.x features JavaScript and CSS bundling that is based on a single script file. To bundle, you just call the script with all the files you want to bundle and the script file will read and concatenate all files and behave like it is a script file that contains everything.

    However, this is not a good approach, since the world of the web is constantly evolving. Replacing this script file will require changing the application’s code, since all the pages that use it must be rewritten.

    This is why I in Wigbi 2.0 base everything on a really minimalistic bootstrapper, that wires up everything for you and makes it really easy for you to switch out which implementation you want to use for the various interfaces that exist in the Wigbi framework.

    This approach also makes it really trivial for anyone to just create new implementations. This way, if a better alternative for a certain interface comes along, just create a new Wigbi implementation that wraps it, add it to Wigbi and finally switch out the old implementation in the bootstrapper.

    You can find the source code for Wigbi 2.0 here. It is far from done, but maybe it will be…soon…in a year or so :P If you want to help out, let me know.

  • danielsaidi 9:34 pm on September 15, 2011 Permalink | Reply
    Tags: PHPUnit,   

    Getting PEAR and PHPUnit to work with MAMP 

    When I recently decided to start re-developing Wigbi 2.0 from scratch (will take some time…but as a two kid father, spare-time is…uuuhm) I decided to replace SimpleTest with PHPUnit and PHPCover.

    So, tonight was the night, when I decided to take the first step – getting familiar with PEAR.

    I found this great tutorial that describes how to get it all up and running:


    However, since I managed to screw up my PEAR configurations when playing around with it a month ago, the tutorial did not work.

    Turns out that PEAR was missing from where I wanted it to be installed and that multiple PEAR installations were scattered all over the file system. Also, the configuration file was setup to one of these locations, which made the installer believe that I had the latest release installed.

    Turns out that:

    Finally, I could follow the tutorial at the top of this post.

    To grab PHPUnit was a breeze after the invalid PEAR settings were fixed. The tutorial is sufficient, just follow it.

    You also need to grab PHPCover, which is described at https://github.com/sebastianbergmann/phpunit/

    Now, you have to set the include paths in /etc/php.ini. Mine looks like this:

    • include_path=”.:/php/includes:/usr/lib/php:/usr/lib/php/pear

    BUT but but, since I use MAMP, this is NOT the file that is used. You need to modify the ini file in MAMP’s conf area, and add the paths there as well!

    Now, PHPUnit will work, but I am yet to be convinced. Seems to me that SimpleTest is easier to setup and flexible enough to cover all test cases I need, including mocking…plus that I can ship the testing framework with the development bundle. Any thoughts regarding this?

  • danielsaidi 10:30 pm on June 13, 2011 Permalink | Reply
    Tags: Wigbi 1.2.0   

    Wigbi 1.2.0 is out 

    After even more nightly hacking, Wigbi 1.2.0 is finally out as well. Check it out at http://www.wigbi.com

    I will try to write some short blog posts about the various improvements, as well as create updated video tutorials,but I believe that baby #2 (ETA today) will delay this a little.

    Release notes

    The Wigbi AJAX pipeline is really convenient, but could expose the system to bad stuff, since any class method can be executed. Therefore, this new version features improved AJAX security, which as a bonus also causes size reduction to the data that is passed between the client and the server. Safer and faster…well, a bit at least.

    I have also fixed two invalid DOM selectors in the TinyMceExtender JavaScript code. The ones in the old version had an incorrect space in them, which caused textareas to not be converted into WYSIWYG editors. This is all taken care of now, so the extender should work even with the new version of Tiny MCE.

    For more details, check the release notes in the download bundle.

  • danielsaidi 6:59 pm on May 20, 2011 Permalink | Reply
    Tags: , CMS,   

    Wigbi 1.1.2. f**c-up! 

    In Wigbi 1.1.2, I added a new .htaccess file that did not contain the magic quotes line, since that line made Wigbi crash if the PHP installation did not support magic quotes. However, I managed to remove the line in the incorrect file, which made all Wigbi AJAX pipeline operations fail. Great scott!

    I have added a hotfix (love the name) which is available as Wigib 1.1.3 at github and wigbi.com – get it if you managed to download the crappy 1.1.2 version.

    And while I am at it, I can as well talk a bit what will be included in the upcoming Wigbi 1.2. You see,  the Wigbi AJAX pipeline is really convenient, but can expose the system to bad stuff, since any class method can be executed as long as Wigbi is aware of the class. I will therefore add a new configuration file parameter In Wigbi 1.2.0. It is named ajaxClasses and is a comma-separated list with the names of all the classes that can be used with the Wigbi AJAX pipeline. Every data plugin can be used without adding its class name here, as well as Wigbi, but all other classes must be added here before you can go AJAX on them.

    Finally, after today’s demo, I have decided to develop another start package called Wigbi CMS, which will feature a (basic) CMS framework. It will be released with Wigbi 1.3.0…which will be out…uhm, soon.

  • danielsaidi 8:11 pm on March 18, 2011 Permalink | Reply
    Tags: , , Wigbi 1.1.1   

    Wigbi 1.1.0 + Wigbi 1.1.1 + new video 

    So, yesterday evening, I finished putting together Wigbi 1.1.0, which is a better wrap-up than the 1.0.3 release…and today, I decided to release a quick hotfix – Wigbi 1.1.1.

    Wigbi 1.1.1 takes care of an .htaccess rewrite bug that caused the MVC engine to ignore any defined query strings. Two big thumbs up to Fredrik Bonander who helped me out with the regexp bug handling!

    Wigbi 1.1.1 comes with an already configured MVC template set that features a basic, but fully functional MVC routing .htaccess file, a controller handler that receives all registered routes in the .htaccess file, as well as a default Home controller, a target Index view as well as a simple master page.

    This setup will probably help you get started a lot quicker than if you were to start off from a clean slate. I also uploaded a new video tutorial that demonstrates how to download Wigbi and get it up and running. If you decide to give Wigbi a try, let me know what you think.

    Download Wigbi and watch the video tutorial here.

    • gibson 7:58 pm on May 5, 2011 Permalink | Reply

      Hi Daniel!

      Just to let you know, when Wigbi is run on an installations of PHP in CGI mode, the following error is generated: Invalid command ‘php_flag’, perhaps misspelled or defined by a module not included in the server configuration. ‘php_flag’ is fine in PHP as a module, however.

      My solution was to remove the magic_quotes_gpc line in wigbi/.htaccess, though I’m not positive this is the best approach for everyone (i.e. magic quotes are disabled by default in PHP 3.x.x, enabled in 4.x.x and deprecated in 5.3.0).

      Perhaps it would be worth your time to add checks for the current PHP installation’s mode (i.e. CGI vs module) and possibly it’s version.

      I don’t know how best to approach this, but hope this information is helpful.

      Thanks for a great framework!

      • danielsaidi 8:17 pm on May 5, 2011 Permalink | Reply

        Hi gibson!

        Thank you so much for that information. I added the magic_quotes_gpc line to the wigbi/.htaccess after experiencing strange problems at certain servers. While I never had any problems at home nor with my hosting, some people reported that Wigbi messed up strings that were posted through the Wigbi AJAX pipeline. New lines turned into \n etc.

        Then, one day, the problem started occuring at my live sites as well. After some investigating (I will not take credit for the solution – a friend of mine found it :) I noticed that my hosting company had enabled magic quotes in a recent update. After disabling magic quotes in the Wigbi .htaccess file, everything went back to normal.

        So, the line is only there to ensure that Wigbi will not mess up things IF magic quotes are enabled (which they seldom are). However, if that means that Wigbi will not work with some PHP installations, then maybe a better way is to include an optional .htaccess file that can replace the original one IF Wigbi is used on a server where magic quotes are enabled. That’s perhaps better?

        Once again, thank you for pointing out this problem and great to hear that you are enjoying Wigbi.

        • gibson 10:16 pm on May 5, 2011 Permalink

          Glad I could help you out. :)

          I don’t know enough about .htaccess files to begin with, so I wouldn’t know of a way to detect certain environment elements to make all this happen in one .htaccess file. However, providing alternate .htaccess files seems like a great idea.

        • danielsaidi 11:19 pm on May 8, 2011 Permalink

          I have now released Wigbi 1.1.2, which contains a separate .htaccess file for the magic quotes (should they never be needed) as well as some updated instructions. Thanks once again! :)

  • danielsaidi 12:53 am on March 17, 2011 Permalink | Reply
    Tags: MasterPage, , Wigbi 1.1.0   

    Wigbi 1.1.0 is out! 

    1.1.0? Yes, I take a biig leap and upgrade the version to 1.1.0. In this release, I have added an MVC template that features a controller, one view and a master page. Hopefully, this setup will help you get started a bit quicker than the old index-wigbi.php page. You do not have to use the templates, but they are there if you want to.

    So, instead of the index-wigbi.php page, Wigbi now comes with a brand new file called REMOVE_THE_FILENAME.htaccess. Just remove the file name (yes, just like the file name told you) to make it into an .htaccess file. This is the file that will be responsible for the MVC routing.

    Also…the MasterPage class has changed quiite a bit compared to Wigbi 1.0.3. Since the View class can be used to push data to views, variable handling in the master page class is no more. Furthermore, the file path must now be set separately and not when calling build. Finally, all the content area related methods are now removed to openContentArea, closeContentArea and getContent.

    So, now, it is a lot easier to start Wigbi in 1.1.0. No starting / stopping must be added to the master page, or any page at all. It is all happening in the controller start point. Good stuff!

    I will update the start page video so that it shows the most current setup. Until then, you can download Wigbi 1.1.0 here.


  • danielsaidi 9:05 am on February 2, 2011 Permalink | Reply
    Tags: Flash, Gears, , , , Plupload, ,   

    Trying out Plupload 

    In Wigbi, I previously had a really handy UI plugin called FileUploadForm, which could upload any number of files with AJAX. All you needed to do was to add such a form to the page to have it handle the entire file upload process automatically. However,as I yesterday sat down to migrate the old plugin so that it would work together with the new Wigbi version, I thought “hey, three years have passed – there MUST be an even easier way to upload files”.

    Believe it or not…there was.

    The people behind Tiny MCE have created a really nice file upload component called Plupload. It supports several ”runtimes” – from jQuery-based file upload in HTML4/5 to Flash, Silverlight, Gears etc. and is insanely easy to configure. You can tell Plupload which runtimes you’d prefer to use, which file types to support etc. The users can then upload files either with a regular “select file(s)” dialog or by dragging files from an Explorer/Finder window.

    To make Plupload work flawlessly with Wigbi, I moved the upload.php file to the ~/wigbi/pages/ folder and added some extra functionality, like starting/stopping Wigbi and being able to adjust the target folder with a query string variable. All in all, adding Plupload to my Wigbi-based site took 10 minutes and worked perfect.

    Due to this, I will not create a new version of the old FileUploadForm plugin. I will rather add an upload.php dummy page to the ~/wigbi/pages/ folder, that describes how to adjust the upload file that is included with Plupload.


  • danielsaidi 1:12 am on November 24, 2010 Permalink | Reply

    PHP – The horrible magic quotes 

    A little more than a year ago, I had some problems when AJAX:ing data to a PHP page. In order to be able to unpack the data, I had to use the stripslashes method, which did not seem all that intuitive. However, since it worked, I let it remain without any further considerations.

    Then, about a month ago, I published a new web site that I had developed for a friend. For that page, when I posted HTML content via AJAX, all line feeds turned into u000a strings. The problem only occured on his domain, and not on mine, and looks like this:

    Magic quotes in action - all line breaks are turned into u000a

    Magic quotes in action - all line breaks are turned into u000a

    So then, yesterday, the problem finally appeared at my domain as well. I did not understand this at all, until I chatted with a friend of mine, who just brainstormed and came up with the solution.

    Magic quotes

    Okey, the purpose of this feature was to protect pages from injections, but it did not work all that well, so the feature is now deprecated. What it does is that is wraps everything in neat little escape slashes, which is why I had to use stripslashes.

    However, if magic quotes are disabled, stripping the slashes will instead destroy the escaped line break.

    So, I now disable magic quotes for all pages, using this in an .htaccess file:

       php_flag magic_quotes_gpc off

    Thanks Mattias – it works like a charm!

  • danielsaidi 10:49 pm on October 5, 2010 Permalink | Reply

    Really simple PHP Controller class 

    I have written a reaaaally simple Controller class to my hobby project, Wigbi. Even though it is SO basic, it will help immensely when developing MVC-based PHP web applications.

    The class has three properties – name(…), action(…) and viewData(…) – and one single method – addView(…). I will try it out in a couple of projects and see if it is good enough.

    Here is the code:

     * Wigbi.PHP.Controller class file.
     * Wigbi is free software. You can redistribute it and/or modify it
     * under the terms of the GNU General Public License as published by
     * the Free Software Foundation, either version 3 of the License, or
     * (at your option) any later version.
     * Wigbi is distributed in the hope that it will be useful, but WITH
     * NO WARRANTY; without even the implied warranty of MERCHANTABILITY
     * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
     * License for more details.
     * You should have received a copy of the GNU General Public License
     * along with Wigbi. If not, see <http://www.gnu.org/licenses/>.
     * The Wigbi.PHP.Controller class.
     * This class represents a general controller that can be used in an
     * MVC-based application. The class is static, since only one single
     * controller can exist during a request.
     * This class is really basic as of now, since it is being tried out
     * in various applications.
     * The control is automatically initialized with query variables, as
     * such:
     * <ul>
     *     <li>Controller::name() - by default $_GET["controller"]</li>
     *     <li>Controller::action() - by default $_GET["action"]</li>
     * </ul>
     * If this pattern is not used, the controller class can be manually
     * initialized with the init method, which overrides the name/action
     * properties.
     * To add a view to the page, which can be done in the controller as
     * well as in any view, just use the Controller::addView(...) method.
     * To expose view specific data to the view, simply provide the data
     * to the view with the second parameter.
     * Use the Controller::viewData(...) property to work with view data.
     * If the property is accessed without any parameters it will return
     * the view specific data, if such data has been set. Otherwise, the
     * property can be used as an ordinary get/set property.
     * For the class to be available in the controller file, remember to
     * include the wigbi/wigbi.php include file at the very first line.
     * @author      Daniel Saidi <daniel.saidi@gmail.com>
     * @copyright   Copyright © 2010, Daniel Saidi
     * @link        http://www.wigbi.com
     * @package     Wigbi
     * @subpackage  PHP
     * @version     0.5
     * static
    class Controller
     * @ignore
     private static $_currentViewData;
     private static $_action = "";
     private static $_name = "";
     private static $_viewData = array();
      * Get/set the name of the current action.
      * @access    public
      * @param    string    $value    Optional set value.
      * @return   string              The name of the current action.
     public function action($value = "")
        if(func_num_args() != 0)
           Controller::$_action = func_get_arg(0);
        if (Controller::$_action)
           return Controller::$_action;
        if (!array_key_exists("action", $_GET))
           return "";
        return $_GET["action"];
      * Get/set the name of the controller.
      * @access    public
      * @param     string    $value    Optional set value.
      * @return    string              The name of the controller.
     public function name($value = "")
        if(func_num_args() != 0)
           Controller::$_name = func_get_arg(0);
        if (Controller::$_name)
           return Controller::$_name;
        if (!array_key_exists("controller", $_GET))
           return "";
        return $_GET["controller"];
      * Get/set view data.
      * @access    public
      * @param        string    $key        Optional key value, otherwise current, view specific data.
      * @param        string    $value    Optional set value.
      * @return    string                     The view data value.
     public function viewData($key = "", $value = "")
        if (func_num_args() == 0)
           return Controller::$_currentViewData;
        if (func_num_args() == 2)
           Controller::$_viewData[$key] = $value;
        return array_key_exists($key, Controller::$_viewData)
           ? Controller::$_viewData[$key]
           : null;
      * Add a view to the page.
      * If ~/ is used in the view path, Wigbi will auto-parse it to the
      * application root path.
      * @access    public
      * @static
      * @param    string    $viewPath    The path to the view file.
      * @param    string    $viewData    Optional view data; default null.
     public static function addView($viewPath, $viewData = null)
        Controller::$_currentViewData = $viewData;
        $viewPath = str_replace("~/", Wigbi::serverRoot(), $viewPath);
        require $viewPath;
        Controller::$_currentViewData = null;

    The Controller class will be available in Wigbi 1.0.

    Oh, and in the application root, I place an .htaccess file with the following content:

    Options -Indexes
    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([a-zA-Z0-9_\-]+)/?$                   controllers/$1Controller.php?controller=$1                        [NC]
    RewriteRule ^([a-zA-Z0-9_\-]+)/([a-zA-Z0-9_\-]+)$   controllers/$1Controller.php?controller=$1&action=$2    [NC]
  • danielsaidi 8:15 am on August 21, 2010 Permalink | Reply
    Tags: Aptana Studio 2, Intellisense,   

    PHP intellisense with Aptana Studio 2 

    I just re-installed Snow Leopard on my MacBook, and after installing Aptana Studio 2, I cannot seem to get PHP intellisense to work. Has anyone had the same issue and solved it?

Compose new post
Next post/Next comment
Previous post/Previous comment
Show/Hide comments
Go to top
Go to login
Show/Hide help
shift + esc

Get every new post delivered to your Inbox.