Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I remember seeing an article or talk or something by one of the main Symfony guys on the fact that PHP was wanting, as a community, to move away from monolithic frameworks in favour of smaller, front controller style implementations. I was actually tring to find it the other day - does anyone have a link?

It's interesting to see the growing trend in this direction for PHP.

I wrote one a little while back[1] that does even less than this :) The only goal being to provide a simple way to execute classes from the web or command line with a default autoloading implementation and a way to inject new ones[2]

Personally a lot of my current direction in PHP comes from watching what's happening the node.js community - I like the way that there are a lot of small-ish packages/modules that are pretty independent.

I've written a couple of packages for RocketSled already which you can see on my github page if you're interested.

[1] https://github.com/iaindooley/RocketSled

[2] There are some obvious improvements that could be made to the current implementation which always parses the package tree ie. caching



I don't know about the article. But the truth is that Symfony2 is built from a collection of independent components. And each component could be used independently in your app without a need to use symfony framework. Here is for example a link for a routing component: https://github.com/symfony/Routing


The Zend Framework is the same. You can use each component completely separately. I know a few people who have used the Zend Controller classes and Zend Router in their own frameworks.


Hey that's pretty interesting. I can use that instead of writing my own routing package ;)


It's an encouraging trend. One of the things I like from the Java ecosystem is that there are a couple of really nice general-purpose frameworks that can be mixed and matched with other, more specific frameworks. Like Spring + Hibernate + JSF. I never liked the idea of a big, monolithic framework pretty much forcing its way of working on me. I'm very happy to see the PHP community moving in this direction!


I like the idea of that for command line, its a wicked project. Seems a bit painful for web use though - I moved away from mapping routes to controllers automatically in favour of specifying them manually, I feel that it gives great control and leads to less magic. Not knocking your project, though! Good stuff


Actually it doesn't even do that! It does so little - that r= argument just has to be a class that is autoloadable and implements the Runnable interface.

In fact, if you want routes you'd have to build it as a package and in FACT you could just create a class like this:

    class RocketHam implements rocketsled\Runnable
 {
    public function run()
    {
        $app = new Ham();
        $app->config_from_file('settings.php');

        $app->route('/pork', function($app) {
            return "Delicious pork.";
        });

        $hello = function($app, $name='world') {
            return $app->render('hello.html', array(
                'name' => $name
            ));
        };
        $app->route('/hello/<string>', $hello);
        $app->route('/', $hello);

        $app->run();
    }
 }
then put your ham/ directory in packages with a file rs.config.php:

    spl_autoload_register(function($class)
 {
     if($class == 'Ham')
         require_once(dirname(__FILE__).'/ham.php');
 }
then use .htaccess or something similar to route all requests to:

index.php?r=RocketHam

EDITS: oops sorry not used to formatting code on here


Gotcha, that's kinda cool. I just learned about this http://www.php.net/manual/en/language.oop5.magic.php#object....

The __invoke method means I can use my apps AS closures which is totally sweet.




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

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

Search: