Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
ToroPHP - A Tiny PHP Framework (toroweb.org)
29 points by kunalanand on Dec 8, 2010 | hide | past | favorite | 21 comments


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


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.


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


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.)


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!


Anyone know of a good n small ORM for PHP?


I wrote one recently. Haven't had much time to maintain it but it's about as small n good as I've seen. :)

https://github.com/jasonmoo/DumbledORM


+1 I've used this for a few projects already :)


Oh sweet. Glad to hear it beagledude. :)


Try Idiorm (for basic ORM and query-building) and Paris (a simple Active Record implementation):

http://j4mie.github.com/idiormandparis/


Pheasant is small, I'm the author so I'm biased as to whether it's good though.

http://getpheasant.com


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.


It's also worth taking a look at Slim:

http://www.slimframework.com/


Glad this finally made it to the open source scene. I'm really excited about small, powerful tools like this in the PHP space.


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.


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!


I like my framework:

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

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




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: