Thin PHP Frameworks

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • 99m@myway.com

    Thin PHP Frameworks

    Can anyone recommend to me a thin PHP framework? By thin, I mean that I
    don't want a massive amount of code, dependencies, or large learning
    curve. I'm also not thrilled about introducing XSLT into the project --
    I'm not a fan of that. However, I'd like to use something that helps me
    abstract the application logic and presentation layer a little better.
    And if there's something that helps me display prettier HTML forms, or
    a seperate package, that's icing on the cake.

  • Skeets

    #2
    Re: Thin PHP Frameworks

    i developed my own system. it isn't too difficult.

    1. you have a main logic page.
    2. the logic page includes a template page or redirects to itself on
    form submission.

    Now, next, and beyond: Tracking need-to-know trends at the intersection of business and technology


    3. i have a common.in.php file where i store constants and the like.
    4. i link to a style sheet.

    in order to help out, i use Manuel Lemos' forms generation and
    validation class (phpclasses.org ). the class is awsome. it isn't
    simple to learn, but nothing powerful is.

    i also use the adodb abstraction layer to do my db work. i'm quite
    happy there, too.

    only your imagination can limit your css (presentation).

    i highly recommend visiting sitepoint.com's css forum - paul is a css
    guru. if you try and make cross browser compatibility a reality, css
    guru's are your friend. your best friend.



    i use postgresql - great db with a license much better than mysql.

    if you *really* want to go with a framework, you may want to look into
    ruby on rails. lots of java and php developers are saying it is a
    great way to develop.

    of course, you lose some capability for the simplicity, but that can
    often be made up by adding the complexity back in, where appropriate.

    good luck.

    Comment

    • Skeets

      #3
      Re: Thin PHP Frameworks

      btw, here is a link to some basic css layouts / effects that you can
      build upong:



      these were developed by paul who hangs out at the sitepoint.com forum i
      linked to earlier.

      good luck.

      Comment

      • Henk Verhoeven

        #4
        Re: Thin PHP Frameworks

        99m@myway.com wrote:[color=blue]
        > Can anyone recommend to me a thin PHP framework? By thin, I mean that I
        > don't want a massive amount of code, dependencies, or large learning
        > curve.[/color]
        horde: 17935 KB, depends on PEAR and several php extensions
        phpPeanuts: 762 KB, no dependencies, but still quite a learning curve
        [color=blue]
        > However, I'd like to use something that helps me
        > abstract the application logic and presentation layer a little better.
        > And if there's something that helps me display prettier HTML forms, or
        > a seperate package, that's icing on the cake.
        >[/color]

        Try a pattern!

        For example if myScript.php contains:

        <HTML><HEAD>
        <TITLE>My Page</TITLE>
        </HEAD>
        <BODY>
        <?php include('myBody .inc.php') ?>
        </BODY>
        </HTML>

        this will output the content coming from file 'myBody.inc.php ' on the
        location of <?php include('myBody .inc.php') ?>. Now i guess you can do
        this kind of thing too with JSP. But there is an important difference:
        the code from the included file is executed inside the function it is
        included from. In the example there is no function, but in the following
        example there is:

        in 'myScript.php':

        <?php
        require_once('M yPage.class.php ');
        $page = new MyPage();
        $page->service();
        ?>

        in 'MyPage.class.p hp':

        <?php

        class MyPage {

        function service() {
        include('MyPage .skin.php');
        }

        function printTitle() {
        print "My Page";
        }

        function printBodyPart() {
        require_once('M yBodyPart.class .php');
        $part = new MyBodyPart();
        $part->service();
        }
        }

        in 'MyPage.skin.ph p':

        <HTML><HEAD>
        <TITLE><? $this->printTitle() ?></TITLE>
        </HEAD>
        <BODY>
        <?php $this->printBodyPart( ) ?>
        </BODY>
        </HTML>

        in 'MyBodyPart.cla ss.php':

        class MyBodyPart {

        function service() {
        include('MyBody Part.skin.php') ;
        }

        function printMessage() {
        print "Hello World";
        }
        }

        in 'MyBodyPart.ski n.php':

        <B><?php $this->printMessage () ?></B>

        Becuase the skin files are included inside methods, the $this variable
        will reference the object whose method includes the skin. This way we get:
        - separation of layout and OOP code,
        - pages composed from reusable parts
        And all this without a framework, without a template engine, all you
        need is to follow a simple pattern!

        For abstracting application logic:
        Give each database table a primary key 'id', make it auto_increment.
        Made a class DbObject. Make a subclass of DbObject for each database
        table. Make one instance for each record. You can load it from the
        database with php's msql_fetch_obje ct() function. Use getter and setter
        methods. Wite a delete() method on DbObject that deletes using 'id' column.

        Write a save() method for each class. Or better, use "SHOW COLUMNS FROM
        $tableName" to write a generic function that writes a value for each
        column. If $this->id is not set it must be a new object, do insert. If
        it is set, do update.

        Write all application logic that is not specific to the user interface
        in these DbObject subclasses. The user interface should only access data
        through instances of these classes.

        Greetings,

        Henk Verhoeven,
        www.phpPeanuts.org (includes the above patterns and more).

        BTW, in investment in knowledge is the best investment you can make.
        Knowledge is more flexible then any framework can ever be and lasts
        longer too. If a framework helps you te learn how to make better
        software that makes the framework only more valuable.

        Comment

        Working...