danIT Posted January 26, 2009 Posted January 26, 2009 I work with Moodle quite a bit both at work and as a personal interest but Im not a programmer. What I want to be able to do is build some admin tools to aid the use of Moodle to admins who either can be trusted with direct DB access or dont have the skills to create some decent queries to pull out the relevant details. So really Im looking to introduce myslf to PHP programming while hooking into a (mysql) database while specifically looking into Moodle dev. Does anyone have any pointers for me, using PHP libraries and existing PHP functions, calling those functions or adapting them, using API's what ever they are?
mattmoo Posted January 26, 2009 Posted January 26, 2009 Hey Dan, google is obviosuly your friend here but i would also say grab yourself a good book or two (an ebook would be great, pm me for a good source of information) and just give it a go. There is plenty of ebooks focused on moodle development and PHP really isnt a difficult langauge to learn its just getting used to OOP that takes a little getting used to. I always use forums / blogs as good sources of information and finding a good PHP forum that has a lot of active members will be a great help Matt
lightinthedark Posted January 26, 2009 Posted January 26, 2009 (edited) My advice: Have a small and simple task that you need to do and figure out how to do it, then move on to something a bit bigger, etc, etc. Starting off with writing stuff to slot into the Moodle framework might be a bit much for a first jaunt, so just try making a simple page with a form that you can process and pull data from a db with. Nothing fancy, just enough that you can get your feet wet while holding it all in your head. PHP: Hypertext Preprocessor is your friend. The documentation and examples there are excellent. Hello :-Dave P.S. I have a couple of files of php that I uses as a simple programming test for applicants to a job assisting my php dev job that I could send over to you if you want. includes basically what I just said there and scope for more if you want to extend it. PM me for more them. Edited January 26, 2009 by lightinthedark
dhicks Posted January 27, 2009 Posted January 27, 2009 Does anyone have any pointers for me Sure - 0x3A28213A, 0x6339392C, 0x7363682E... using PHP libraries and existing PHP functions, calling those functions or adapting them, using API's what ever they are? Moodle might not be the best place to start, some of the code is pretty hairy. You'll also find that no SQL database access is done directly (or, at least, that's the intention...), there's an abstracted API of some kind (ADOdb, I think, but maybe they had their own bits in there, too). Get a couple of smaller one-page bits written before you go wading into Moodle, just so you get the hang of things. -- David Hicks
tmcd35 Posted January 27, 2009 Posted January 27, 2009 Does anyone have any pointers for me Sure - 0x3A28213A, 0x6339392C, 0x7363682E... -- David Hicks Have you no shame? You should be shot a dawn for that one!
kmount Posted January 27, 2009 Posted January 27, 2009 [badly timed humour] Doesn't this thread title remind you of "I wanna a hippy and I wanna get stoned now!" [/badly timed humour] I love how PHP: Manual Quick Reference works for near on everything. I agree entirely with what everyone's said and can fully vouch for the "find a problem, and develop a solution" idea that David suggested as I recently used it to figure out arrays in bash and then perl, and finally php. (Was writing a simple rsync back up script). Good luck!
witch Posted February 8, 2009 Posted February 8, 2009 Tutorial & reference information can be found here PHP: Hypertext Preprocessor wITch partner
deanc Posted February 8, 2009 Posted February 8, 2009 [ame=http://www.amazon.co.uk/PHP-MySQL-Development-Developers-Library/dp/0672329166/ref=sr_1_1?ie=UTF8&s=books&qid=1234127453&sr=8-1]PHP and MySQL Web Development (Developer's Library): Luke Welling, Laura Thomson: Amazon.co.uk: Books[/ame] this is the updated version of the core text book when i learnt PHP and MYSQL at uni, it was one of the few books at the time that taught OO PHP from the start rather than getting to the last chapter and saying oh by the way you can do it this way as well.
Friez Posted February 13, 2009 Posted February 13, 2009 (edited) My advice: Get a nice clean LAMP (Linux, Apache, MySQL, PHP) or WAMP (Guess) setup and start typing: index.php echo "HELLO"; ?> World Step one is to learn about breaking in/out of PHP and regular HTML as highlighted above. Then visit PHP: Hypertext Preprocessor and start doing stuff. General programming things to learn (before you even touch database stuff) should be as follows: Variables ( Storing data for use later ) and Types ( There IS a difference between an Integer, Float and Strings, but PHP makes it quite transparent. Arrays (Lots of variables stored in 'one variable' as a sort of list) Operators (Bitwise, Logical and Mathematical e.g. comparing variables or adding things) Loops: for, while, foreach Functions ( Segments of code that can be re-called over and over ). For what it's worth, I'm SOLID at PHP but I never ever picked up a book on it but you should learn to walk before you can run Doing is more important than reading because the MORE you do it, the more you learn, much faster than reading books (php.net is the ultimate reference for the language, better than any book IMO). So sit down and start coding. Below is a little tutorial PHP I wrote for a colleague, you can work on that to learn some basic programming stuff if you need direction. It has a few things wrong with it, and has tasks to do. It's worth reading the code over to get a feel for it, it's not too hectic, but does have a few gotchas. users.csv bob,geoff,david,jane,jill,peter,adrian,robert,sarah,brian,lucy index.php // TASK! figure out why the PHP program doesnt work! function get_file($filename) { // TASK! // what if the file didn't exist? // could we check if it did first? // think about the function at // [url]http://us3.php.net/manual/en/function.file-exists.php[/url] // if the file doesn't exist, kick up an error message $filehandle = fopen($filename,"r"); // opens the file for reading $filecontents = ""; // empty text // use a while loop to keep grabbing data from the file while(!feof($filehandle) ) // feof() checks to see if we're at the end of the file, what do you think the ! operator is for? { $filecontents .= fgets($filehandle); // gets a line from the file. What do you think .= does in regards to strings? } fclose($filehandle); // close the file return $filecontents; // return to the calling function the text we have loaded } function read_csv($filename) { $csvdata = get_file($filename); // call the above function to get the CSV data $data_array = split(",", $csvdata); // split the data up using , as a delimiter return $data_array; } // TASK!! // using temporary variables and loops // try sorting the data into alphabetical order // try following a bubble sort algorithm to do this // [url]http://en.wikipedia.org/wiki/Bubble_sort[/url] // below has been started for you // try to finish it off // this function may help you: // [url]http://us3.php.net/manual/en/function.strcmp.php[/url] // comment this function describing what each bit does // so you understand how the sort works. // DO NOT use PHP's in-built sorting functions to do this! // this will teach you the process of structuring data and moving it around. function BubbleSort( &$items ) { $temp = ""; $size = count( $items ); for( $i = 0; $i < $size-1; $i++ ) { for( $j = 0; $j < $size - 1 - $i; $j++ ) { // if( ... ) // { // ... // } } } } // ADVANCED!! // in BubbleSort( &$items ) // any idea what the & is used for? // think about the data, and the fact that we don't // return any values in BubbleSort // how do you think the memory is being accessed? // the following may give you an idea: // // [url]http://en.wikipedia.org/wiki/Pointer[/url] // [url]http://en.wikipedia.org/wiki/Reference_%28C%2B%2B%29[/url] ////////////// PROGRAM STARTS HERE!! /////////////////// $data = read_csv("users.doc"); // get the data from the CSV file // count() returns the number of elements in an array // any ideas what this loop does? for($i=0;$i{ echo $data[$i] . " "; } // output the sorted data echo "Sorted Data"; BubbleSort($data); for($i=0;$i{ echo $data[$i] . " "; } // Super-Advanced!!! // implement a quicksort algorithm in order to // speed up processing time! // // what are the up-sides and down-sides of both algorithms? ?> Let us know how you get on and if you need any tips Edited February 13, 2009 by Friez
TornUp Posted April 20, 2009 Posted April 20, 2009 once again, i plug my good friend(who i don't know, but he sounds like a really nice bloke!) PHP Video Tutorials - Like to watch the video instead of reading the book? yes, he offers paid videos, but i learnt the majority of my stuff from his free videos(the old ones i prefer over the new!) have a look, its free, and if your anything like me, video tutorials are for learning, written tutorials are for CnP'ing hehe.
Sandman Posted April 22, 2009 Posted April 22, 2009 I'd recommend learning HTML before moving to PHP. My advice is go online and find some tutorials or a good book with tutorials. I'm self taught in every language I can write.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now