Tips for module development?

Started by zero0097, September 29, 2013, 10:56:33 PM

zero0097

Hello guys, I want to know what tips can you give me for developing modules, I mean how do you debug your module? how you can see the values of the variables at certain times, or be sure the information you're returning is the good one, etc? How can I output something to the screen when developing? because print, echo, doesn't work. Also, what developing tools do you use?

Thanks! :D

tallship

Bradley D. Thornton - Manager Network Services, NorthTech Computer   TEL: +1.310.388.9469 (US) | +44.203.318.2755 (UK) | +61.390.088.072 (AU) | +41.43.508.05.10 (CH)
Registered Linux User #190795 - "Ask Bill why the string in [MS-DOS] function 9 is terminated by a dollar sign. Ask him, because he can't answer. Only I know that." - Dr. Gary Kildall.

zero0097

Thanks It's very helpful but it's just like the sample modules in the wiki. I was thinking in something to debug a module, is there any tool to view variable values? automated tests?

For example, how can I output the content of the $request object? Or in a module, how can view the available methods in the $this object? (module). If I'm using an API from another site, how can I print the returned values to verify they are correct? I mean just viewing them for debugging purposes?

Thanks

zero0097

Well I didn't notice that I just need to stop the script with exit() after using a print function, so in that way I can print variable values to see them...

But this only work in Controllers, not in the actual module.

I want to know because I'm using in $options a "loadable" component, but is not working, it only displays a text box, instead of a "select" drop list with the returned array....

I have something like this:

protected $options = array(
    'option1' =>array (
        'name'=> 'User role',
        'value' => false,
        'type'=> 'loadable',
        'default'=>"getRoles" // method that returns an array
    ),

    /*
        ... (more options here)
    */
);

/*
    ... and more stuff here
*/

public function getRoles() {
    return array(
        array(1, 'User'),
        array(2, 'Admin'),
        array(3, 'Example'),
    );
}


Well, my method consults an API, and returns an array with same structure than the above example, but it doesn't work, I was asking for output variable values to see the structure and content of the array, because I was thinking that was the problem, but now I see that the returned array is Ok, but hostbill only renders an Input Text Box, instead of a "select" with the returned array, what do you think is the problem?

Thanks in advance! ;D

tallship

Not trying to blow you off or anything, but you might want to shoot a message on over to Maxim, who runs Vasicka Software.

He has a pretty intimate understanding of module development for HostBill and also has a repo HERE.

Notwithstanding any input from others here, good luck and do let us know where the issue was okay?

Kindest regards,
Bradley D. Thornton - Manager Network Services, NorthTech Computer   TEL: +1.310.388.9469 (US) | +44.203.318.2755 (UK) | +61.390.088.072 (AU) | +41.43.508.05.10 (CH)
Registered Linux User #190795 - "Ask Bill why the string in [MS-DOS] function 9 is terminated by a dollar sign. Ask him, because he can't answer. Only I know that." - Dr. Gary Kildall.

zero0097

Thanks sure I'll write him! as far I can see HostBill development documentation it's very lacking (in my opinion)......

I solved the issue was just a mistake when selecting the app to provisioning that product and click on "Get Values from server" my connection method was wrong, and can't connect, I just fixed that and it worked, the weird thing is that I thought it was fixed earlier :S my bad, Thanks for your help tallship  ;D.