23 comments

[ 4.6 ms ] story [ 89.8 ms ] thread
Glad this finally made it to the open source scene. I'm really excited about small, powerful tools like this in the PHP space.
You might also be interested in limonade (a sinatra-esque php framework) -- http://www.limonade-php.net/
Interesting. It's ~2500 lines of code and it's a micro-framework? :)

I like it though. Thanks for the tip!

Another nice, little PHP framework is GluePHP (http://gluephp.com).

Hello World using GluePHP:

  <?php
      require_once('glue.php');

      $urls = array(
          '/' => 'index'
      );

      class index {
          function GET() {
              echo "Hello, World!";
          }
      }

      glue::stick($urls);
  ?>
Another example with parameter matching and POST method handling:

  <?php
      require_once('glue.php');

      $urls = array(
          '/' => 'index',
          '/(?P<number>\d+)' => 'index'
      );

      class index {
          function GET($matches) {
              if (array_key_exists('number', $matches)) {
                  echo "The magic number is: " . $matches['number'];
              } else {
                  echo "You did not enter a number.";
              }
          }
          function POST() {
              echo 'The value you entered was ' . $_POST['textbox1'];
          }
      }

      glue::stick($urls);
  ?>
Wow looks like web.py for PHP. I think I've seen a similar project whilst lurking around Github the other day.
It made my introduction to PHP much easier and a hell of a lot more powerful. It just felt right to build a website this way. Easily maintainable as well. Great work!
Nice little framework, only 90 lines of code.

Just a minor complaint about the dispatcher syntax:

    Array('^\/article\/([a-zA-Z0-9_]+)\/?$', 'regex', 'ArticleHandler')
Those backslashes look clunky. Something as commonly used as a forward slash in a URI shouldn't need to be escaped. Quick fix: use something else as a delimiter, such as #, in line 45. (It should be a character that never occurs in a valid URI on the server side. # is a reasonable choice because the fragment never gets passed to the server.)
(comment deleted)
Anyone know of a good n small ORM for PHP?
Doctrine (http://doctrine-project.org/) is good, but not small.
I've used doctrine a few times, its nice that it does auto-loading by default (helps on load-times), but it does immediately quadruple the codebase of almost all my projects.
(comment deleted)
Seems quite nice and clean but i'd perhaps refactor the ToroApplication constructor. Having to pass an array within an array each time is a little messy. I can see why its done but you can achieve the same thing by using func_get_args.
I think I'm biased, but I no longer use any other framework rather than FatFree (http://fatfree.sourceforge.net/).

Let's see how I build my website

require_once 'path/to/F3.php';

F3::route('GET /','home');

function home() {

		echo 'Hello, world!';

	}
F3::run();

Nice, no? This help me start quickly, iterate rapidly and scale easily when the project gets bigger by dividing and expanding the small parts.

- You chose your own directories structure

- No .htaccess hacking needed.

- Own variables table

- Lot of useful plugins, like a lightweight ORM, Form Handler, Unit Testing, Very flexible Caching

- You decide to use OOP, MVC, procedural programming... or a combination of your choice

- Really lightweight: 50kb

This is just a lot of hoopla! It's not a framework. It's just a bunch of methods that comprise a front controller.
sometimes that's all you need, broseph
I like my framework:

index.php: <? echo 'hello, world'; ?>

It's really simple and small.. almost non-existent.