Your opinion appreciated: a good php foundation course.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jeddiki
    Contributor
    • Jan 2009
    • 290

    Your opinion appreciated: a good php foundation course.

    Hi,

    I am looking at putting together a good quality foundation course for php that
    be be really helpful for beginners that want to get into web development.

    Many of us started learning php from a book and then just dabbling in it and creating our own sites. Others have had a more structured academic start.

    May I ask :
    1) how did you begin learning php?
    2) what do you wish you had done differently.
    3) what do you think an 8 week php foundation course
    should really contain as its core lessons?

    Personally, I would have learned a lot quicker and been a lot more productive
    over the past two years if I had followed a good course in the beginning !

    What do you think? Your thoughts and insights would be appreciated.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    I would make sure they know about the PHP Manual (and know how to use it). quite a lot of problems can be avoided, if you read what’s in there (e.g what (type of) parameters does this function expect, what are the return values, what happens in case of an error). additionally, the comments section is a treasure box.

    further they shold be introduced to code structuring (indentation, code readability) and (very important) code documentation.

    and of course: Exceptions and error handling

    Comment

    • jeddiki
      Contributor
      • Jan 2009
      • 290

      #3
      That's a great post, thanks.

      Anyone else got some thoughts on this ?

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        Anyone else got some thoughts on this ?
        how deep do you want to dive into PHP?

        it can be especially useful to cover basic OOP, because most of the advanced packages (database access (MySQLi, PDO), XML processing (SimpleXML, DOMDocument), Memcache, Exception, etc.) are made for that.

        and I recommend User Input Validation (e.g. filter functions), database security (SQL injection), type validation (typeof, instanceof, is_array(), etc.)

        Comment

        • jeddiki
          Contributor
          • Jan 2009
          • 290

          #5
          Good you mentioned that,

          I was thinking of doing an intro into OOP
          and to give a couple of simple examples as one of the last
          sections.

          The main elements would be taught as procedural php
          rather than OOP.

          Of course to teach about SimpleXML and DOMDocument
          would require an understanding of OOP as would
          the use of any classes like ZipArchive, or the mailer class: swift.

          I am thinking that these would need to go into a more advanced
          course.

          Since it is fundamentals, I am starting from ground zero

          The idea is to provide an 8 week course where participants are likely to be working full time and can only give 10 - 15 hours a week

          I have incorparated what you suggested into this of
          what I think are the fundamentals.

          I am assuming that the participants will have a reasonable knowledge of
          HTML and CSS.

          This is what I have so far.

          BTW: The headings that just say "introducti on" mean I will only
          give an overview or breif explaination but no worked examples.
          the subject will need to be more fully covered in a deeper course.

          What do you think? What should be added of takenout ?

          ( I am not sure about PEAR - maybe just an intro)
          There is also GD and image construction ??

          Start:
          Basically how PHP Works
          What the config file is (not in detail).php.ini
          Exceptions and error handling (set it to show errors)

          PHP Syntax, PHP Tags
          PHP Statements and Whitespace
          Comments
          PHP Functions - the MANUAL
          Variables: Types, Names (Identifiers
          Variable Scope, Superglobals, Constants
          Some variable testing and manipulation functions
          Single Quotes vs. Double Quotes
          Passing Variables on the URL
          Passing Variables via the Query String

          Writing a script.
          code structuring with indentation, comments

          # String Manipulation
          Formatting Strings
          Concatenation
          String Manipulation Functions

          # Flow Control
          If Conditions and if/else
          Loops while, do...while, for, break and continue

          # Arrays
          Enumerated Arrays
          Initializing Arrays, Appending to an Array
          Reading from Arrays. Looping through Arrays
          Initializing Associative Arrays Reading from Associative Arrays
          Looping through Associative Arrays
          Superglobal Arrays

          Two-dimensional Arrays
          Reading from Two-dimensional Arrays
          Looping through Two-dimensional Arrays
          Array Manipulation Functions

          # PHP and HTML Forms
          How HTML Forms Work
          Form Variables and Processing Form Input
          Form Validation and Presentation Functions

          # Code Includes
          Including Files: require and require_once
          auto_prepend_fi le and auto_append_fil e

          # User Functions
          Defining and Calling Functions
          Default Values ,Variable Scope
          By Reference vs. By Value

          # Managing Data
          Connecting to mySQL
          Creating a Table with php
          Inserting, Updating, Appending Data
          Querying a Database

          # PEAR:DB
          Advantages and Disadvantages of PEAR DB
          Why use a database abstraction layer?
          When not to use a database abstraction layer?
          Using PEAR DB

          # Authentication with PHP and SQL
          A Database-less Login Form
          Authenticating Users
          SQL injection protection
          type validation

          # Regular Expressions
          Perl-compatible Regular Expression Functions
          preg_match()
          preg_replace()
          Regular Expression Tester
          Regular Expression Syntax
          Start and End ( ^ $ )
          Number of Occurrences ( ? + * {} )
          Common Characters ( . \d \D \w \W \s \S )
          Grouping ( [] )
          Negation ( ^ )
          Subpatterns ( () )
          Alternatives ( | )
          Escape Character ( \ )
          Form Validation Functions with Regular Expressions

          # Session Control and Cookies
          Introduction to Sessions
          Introduction to Cookies

          # Sending Email with PHP
          mail() - Shortcomings of mail()
          class.SwiftMail er

          # OOP
          Introduction

          # File System Management
          Introduction

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            # Managing Data
            Connecting to mySQL
            Creating a Table with php
            Inserting, Updating, Appending Data
            Querying a Database
            most of these topics are not directly related to PHP, since most of it is pure SQL.
            but for the connection, you can of course tell the old procedural way, but since you want to introduce database abstraction layers anyway, go straight for MySQLi and/or PDO. (if you don’t talk about the old, error prone functions, the participants are not that exposed to the standard database newbie errors, though it will be a bit though to get into).

            # PEAR:DB
            no need to discuss it if you speak of database abstraction layers (in common) later. last time I used MDB2 (the successor of DB) I was plagued by compatibility warnings (it was coded for PHP 4). you should also check, whether it is actually better than the two built-in packages (MySQLi, PDO). and of course any DBAL requires some OOP knowledge.

            # OOP
            put it together with database handling, you won’t run out of sensible examples there. (e.g. apply a Singleton Pattern)

            Exceptions and error handling (set it to show errors)
            not just how to show/hide errors. make errors/exceptions a tool. good error handling is half the debugging (many people underestimate the error messages, in contrast to some other languages, PHP is quite self explanatory), thus make it not too short, especially Exception handling can save your life in a complex script (keyword: "backtrace" )

            Comment

            • jeddiki
              Contributor
              • Jan 2009
              • 290

              #7
              Thanks for your input again.

              The main thrust of what I would like to teach is how to build
              useful scripts from the start.

              For this to happen, I might even move the MySQL right up near the
              front so that newbies can get to see the power of dynamic web pages very quickly. After doing that - then I could back track and fill in details about strings, variables, arrays, loops etc.

              Yes this section will contain quite a bit of SQL but not without php.
              For instance: Creating a table can be done with phpmyadmin or other tools
              but I always prefer doing it with a script, that way I always have a pattern
              to start off with - just makes it much quicker and my tables all have a familiar look to them.

              I don't think I can expect anyone who doesn't know php to already know SQL, so I think I will have to include that.

              It is similar with regular expressions which are also used in c+, pearl etc - but I still have to put them into the php course don't I ? I can not expect people to know about how to use them.

              The main thrust is not to theorize, but to get them using code in useful ways. The easiest thing to grasp for most people seems to be standard MySQL.

              no need to discuss it if you speak of database abstraction layers (in common) later. last time I used MDB2 (the successor of DB) I was plagued by compatibility warnings (it was coded for PHP 4). you should also check, whether it is actually better than the two built-in packages (MySQLi, PDO). and of course any DBAL requires some OOP knowledge
              .

              Yes - I think this could get messy, maybe I should just give an explanation of PEAR in genearal and then highlight some of the most useful elements.
              ( which do you suggest)

              Then I should focus on one area - such as MySQLi. Good thing about this is that it can be written procedurally - so I can do a few examples, that will fit in with what has already been explained. That would be the place to explain Prepared statements.

              Then later, after introducing OOP and showing a few classes, I can also show how to use MySQLi.in OO.

              So: - towards the end
              # OOP
              Introduction
              ZipArchive class
              SimpleXML and DOMDocument

              Using MySQLi.in OO.
              The way ahead.

              Comment

              • Dormilich
                Recognized Expert Expert
                • Aug 2008
                • 8694

                #8
                The main thrust of what I would like to teach is how to build useful scripts from the start.
                hm, this is a kind of theory to itself, valid for every programming language.

                After doing that - then I could back track and fill in details about strings, variables, arrays, loops etc.
                IMO not the best way, if you don’t know the basics (e.g. the difference between double and single quoted strings) you’re about to run into parser errors or unexpected (to the newbie) output results.

                but I always prefer doing it with a script, that way I always have a pattern to start off with - just makes it much quicker and my tables all have a familiar look to them.
                the script is only a tool. and I really can’t imagine how PHP would influence the "look" (whatever this may be)—my personal opinion.

                The main thrust is not to theorize, but to get them using code in useful ways.
                you can’t program what you don’t understand. as soon as the script goes beyond copy/paste you need this "theory" very badly.

                maybe I should just give an explanation of PEAR in genearal and then highlight some of the most useful elements.
                explanation of PEAR and PECL in general—yes,
                most useful elements—as you desire

                such as MySQLi. Good thing about this is that it can be written procedurally - so I can do a few examples, that will fit in with what has already been explained.
                good idea. you can nicely jump from here to OOP.

                may I point out, that PDO has better fetching options than MySQLi?

                Comment

                • jeddiki
                  Contributor
                  • Jan 2009
                  • 290

                  #9
                  may I point out, that PDO has better fetching options than MySQLi?
                  As I had not used the PDO extension up until now, I dived into some tutorials.
                  It seems really useful for programming for multiple database types, but as I intend to stick to explaining how to get the best out of Mysql, I don't think there will be any need to go into detail about it.

                  Probably it is enough to explain what it is and that it is there for anyone who needs to access other db systems.

                  I quote from one tutorial on Devshed "the PDO extension would be rather pointless if you’re going to work with only one database server."

                  Don't know if you agree ?

                  MySQLi on the other hand will prove very useful for most people.

                  Comment

                  • Dormilich
                    Recognized Expert Expert
                    • Aug 2008
                    • 8694

                    #10
                    It seems really useful for programming for multiple database types
                    that's only a secondary feature (for me). the really usefull stuff are the methods, that allow you to fetch all results at once, so you don’t need to loop over the result set. and the use of exceptions.

                    Comment

                    • Markus
                      Recognized Expert Expert
                      • Jun 2007
                      • 6092

                      #11
                      No way would I attempt to teach OOP on a beginners course. It'd be a system-overload and very intimidating. After all, OOP is not the be all and end all of programming - something I have come to see the general PHP community believes (that is, they think "if you're not practising OOP, you're doing it wrong."). That eliminates PDO and MySQLi (although MySQLi has it's procedural counterparts).

                      What's great about PHP is that you can do things fast. You get immediate results and nothing is more exciting to a newbie than being able to learn something relatively easily and have something to show for it. So be sure to have your students doing something that gives them results.

                      Of course you'll start off with a "What is PHP?" Be sure to mention that it is an open-source project with literally 100s of developers working on it's internals. Then show them some statistics - how many workplaces require PHP developers, the average salary (local to your area - not somewhere like India), how many websites / servers are using PHP, etc. Keep them interested.

                      Next give them the "Hello, World!" example and run-through the syntax: opening PHP tag (what does it do?), the 'echo' function (is it a function or is it a language construct? What is a language construct? Show them some other examples of language constructs - print, for, select, etc.)

                      At this point you'll want to impart on them some knowledge about how programming works, or more specifically, how the brain of a programmer works. How you approach a task: specify the different results needed by the application, think about how you would accomplish those tasks if they were real-world problems (say it out-loud and then put it into a program), algorithms, etc. This is necessary because simply showing someone the syntax of a language does not show them what to do with it. Get them thinking in terms of conditionals, variables, security, etc., all of which you will show them later.

                      <writer's block>

                      I'll be back with some more suggestions later :D

                      Comment

                      • Dormilich
                        Recognized Expert Expert
                        • Aug 2008
                        • 8694

                        #12
                        No way would I attempt to teach OOP on a beginners course. It'd be a system-overload and very intimidating.
                        hm, yea. that means that the "advanced security" section is to be held later.

                        Comment

                        • Markus
                          Recognized Expert Expert
                          • Jun 2007
                          • 6092

                          #13
                          Originally posted by Dormilich
                          hm, yea. that means that the "advanced security" section is to be held later.
                          Yeah. However, the students should be told to remember this: treat all input as dangerous. Also, they should be shown the filter extension.

                          Comment

                          • Dormilich
                            Recognized Expert Expert
                            • Aug 2008
                            • 8694

                            #14
                            what do you think, should be told that there is something like OOP and advanced security mechanisms, but it can’t be covered in this course?

                            Comment

                            • jeddiki
                              Contributor
                              • Jan 2009
                              • 290

                              #15
                              Thanks Markus for that long post - very helpful.
                              What's great about PHP is that you can do things fast. You get immediate results and nothing is more exciting to a newbie than being able to learn something relatively easily and have something to show for it. So be sure to have your students doing something that gives them results.
                              That was pretty much what I was getting at when I wrote:

                              The main thrust of what I would like to teach is how to build
                              useful scripts from the start.

                              For this to happen, I might even move the MySQL right up near the
                              front so that newbies can get to see the power of dynamic web pages very quickly. After doing that - then I could back track and fill in details about strings, variables, arrays, loops etc.
                              I definitely want to mention OOP and some examples but in a fundementals course, I also think it would be overload to do too much.

                              This thread has given me a lot to think about so thanks again to D and M
                              :)

                              Does anyone else have some ideas for me ?
                              126 peopl have read the post so there must be some thoughts on this ;-)

                              Comment

                              Working...