2

First off, pardon the noob aspect of this question. I have developed on other platforms, but it's been a while now. I was starting to build an EE2 module for one of my sites and I keep getting frustrated in needing to print_r() everything to see what data is available and if I am in the correct hook/segment.

I know a lot of you are seasoned developers of add-ons for EE and more than likely have a nice workflow you could suggest. I would like to save some time by using something I can view as I write. Currently, I just downloaded Zend Studio to see if I could accomplish what I was after.

I guess, my questions are:

  1. What is the best tool for add-on development? (I know this is opinionated, but am open to suggestions)
  2. Is it possible to create add-ons within the system folder so that a project "inherits" the code base? I installed a local instance for developing and used Bjorn's DevKit to kickstart the module. (Great help BTW)
  3. What are the best ways to review available data? Surely there is a better way than dumping the data each time.

* EDIT * For anyone interested, I saw another thread in which someone mentioned using UltraEdit. We use that here in some other areas so I downloaded the studio demo, since we just use the editor. I'm still going through it, but so far, I just started a new project, pointed the editor at my system folder, and all of the methods, classes, etc. seem to be pulled in.

It would still be nice to be able to iterate through data though.

1
  1. Well, I am biased but I use my own Channel Data library for just about everything. I just re-wrote it entirely with full CRUD support, and will save you loads of time. Not familiar with Bjorn's solution, so I can't comment either way.

  2. I would advise against this. When you upgrade EE, you will have to constantly backup specific files and ensure they aren't deleted with the update. I would recommend taking the approach I did with Channel Data. You can load the "packages" into your own add-on to reuse the code, but still keep it in the Third Party directories.

    Here is an except from the Channel Data readme.

    /**
     * Required Steps 
     *
     * 1. Load the Channel Data package into your add-on
     * 2. Load the Channel Data driver from the package
     * 3. Tell Channel Data where the auto loader should look for your files.
     **/
    
    ee()->load->add_package_path(PATH_THIRD . 'your_addon_name');
    
    // Load the driver and directories at once
    ee()->load->driver('ChannelData', array(
        'directories' => array(
            PATH_THIRD . 'your_addon_name/models'
        )
    ));
    
    // Or use the autoload() method to pass a directory path
    ee()->channeldata->autoload(PATH_THIRD . 'your_addon_name/models');
    
    // You can also pass an array of directories
    ee()->channeldata->autoload(array(
        PATH_THIRD . 'your_addon_name/models',
        PATH_THIRD . 'your_addon_name/models/channels'
    ));
    
  3. Not really any better way to do this unless you use an IDE, which I don't use. Without an IDE or something similar, var_dump or print_r are the accepted methods to dumping objects in the screen. No real way around this in my experience without using an IDE, but even then the setup can be arduous and time consuming. In 2.7 though, its much easier than it once was because you can var_dump($this) without having to view the global singleton object.

I also avoid using Third Party libraries, particularly the models. I only use First Party libraries that are documented and not going to intentionally be broken in a future update (unless documented). Native models and methods can change at anytime without notice, and Channel Data is, IMO of course, a better solution for universal models and fetching data.

Hopefully this helps some.

  • Justin, thanks for the input. I'm having a Missouri moment.(show me state) Do you have anything like a bootstrap or an example of how you are using the Channel Data/packages, folder structures, etc. or do you keep that private? – W3bGuy Jan 17 '14 at 21:49
  • Not the latest version of Channel Data. All my add-ons use the original version, but its radically different. Still useful, but not nearly as good as the re-write I just did. The only example I have at this time is a proprietary add-on I wrote for a client, which I can't exactly give out. Here is an excerpt from the code, which outlines how you can take your own models and output them as Channel Entries. gist.github.com/objectivehtml/8505185 – Justin Kimbrell Jan 19 '14 at 13:44
  • Thanks again Justin. It sounds like I just really need to better familiarize myself with the EE core methods and data used in them. – W3bGuy Jan 20 '14 at 20:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.