Page 1 of 1

My micro framework

Posted: Thu Aug 06, 2009 2:19 am
by mxp
Hey everybody I am designing an open-source micro-framework for PHP its called MiMViC. I would love to open it to you people in its very early stages and would love to have some suggestions on it. You can also join hands with me :D.

P.S. Its beta is ready to download although alot is missing but still its worth checking out.

Re: My micro framework

Posted: Thu Aug 06, 2009 2:59 am
by Christopher
That certainly is minimal. However, I think that the actual minimum does a lot more than that. A lot less than a lot of the frameworks you mention, but a lot more than you are doing.

Re: My micro framework

Posted: Thu Aug 06, 2009 3:01 am
by onion2k
I read the tutorials. It seems awfully complicated for a minimal framework. Won't your controller end up with dozens of "get('/hello', 'say_hello');" lines? Isn't the point of a controller that it should handle new functions without having to register them?

Re: My micro framework

Posted: Thu Aug 06, 2009 7:32 am
by mxp
I read the tutorials. It seems awfully complicated for a minimal framework. Won't your controller end up with dozens of "get('/hello', 'say_hello');" lines? Isn't the point of a controller that it should handle new functions without having to register them?
Well I would agree on that there would be many dispatch/get/post/put/delete but I think this is the precise point where power lies. It would helpful for you to only expose the ones you want and not the ones that u don't want. Plus the custom url will make it more readable and this is the way it is being done in many frameworks like Cherrypy and Sinatra. And I have seen commercial projects working this way. However I have took your opinion seriously and now looking for really good alternatives to this problem. Your suggestions are still welcomed.

Re: My micro framework

Posted: Thu Aug 06, 2009 7:34 am
by mxp
arborint wrote:That certainly is minimal. However, I think that the actual minimum does a lot more than that. A lot less than a lot of the frameworks you mention, but a lot more than you are doing.
Its very initial i told you :D but yes I am working on porting more essential things.

Re: My micro framework

Posted: Thu Aug 06, 2009 7:39 am
by onion2k
mxp wrote:Well I would agree on that there would be many dispatch/get/post/put/delete but I think this is the precise point where power lies. It would helpful for you to only expose the ones you want and not the ones that u don't want. Plus the custom url will make it more readable and this is the way it is being done in many frameworks like Cherrypy and Sinatra. And I have seen commercial projects working this way. However I have took your opinion seriously and now looking for really good alternatives to this problem. Your suggestions are still welcomed.
I thought the idea of an MVC framework was that it could take the parameters from the URL (either as plain GET variables, or through mod_rewrite) and figure out which view to display based on that, so I can write "specialoffers.php", drop it into the website, and /specialoffers will just work without needing any changes to the controller.

That's how all the frameworks I've worked with work. In a large application with hundreds of views and dozens of models having to keep the controller up-to-date would be a right pain.

Re: My micro framework

Posted: Thu Aug 06, 2009 3:45 pm
by m4rw3r
What I like in a framework is modularity and extendability, preferably in conjunction with speed and ease of use.
Your framework is so far only based around functions, which makes it really hard to replace anything without rewriting parts of your framework.
It also is missing a strategy for loading external resources (or controllers/models/etc.), which means that the developer must be careful or he would have a mess.

The one thing I do like is the fact that you use that uri routing, it makes the URIs flexible.

Re: My micro framework

Posted: Fri Aug 07, 2009 12:44 am
by mxp
m4rw3r wrote:What I like in a framework is modularity and extendability, preferably in conjunction with speed and ease of use.
Your framework is so far only based around functions, which makes it really hard to replace anything without rewriting parts of your framework.
Well that's true but I just focused on minimality rather than classing. I can think of starting function name with framework name .i.e. get => mimivic_get. This will follow the same php legacy style but each time programmer will have to write extra mimvic_ ( and I know how frustrating it is at times).
m4rw3r wrote:It also is missing a strategy for loading external resources (or controllers/models/etc.), which means that the developer must be careful or he would have a mess.
.
Somebody already mentioned that. What I am planning is that I was thinking provide was class registration. So you can include the class file and just stick it to a URI route. It will automatically mount all of its functions as an extension to URI route; but again someone is gonna loose flexibility of having super custom URI and the concept of "MICRO" will be gone. So I guess I will have to look bit deeper into Cherrypy and other ones doing that so that I can decide on better basis the focus of framework. I am already checking out http://fewagainstmany.com/blog/python-m ... l-the-rage hope it will help improve :D

Re: My micro framework

Posted: Fri Aug 07, 2009 2:19 am
by Christopher
I tried to get the code to work with PHP 5.2 and did not have any success. There seem to be some errors in the code. Maybe it is PHP4 code.

Re: My micro framework

Posted: Fri Aug 07, 2009 5:09 am
by m4rw3r
One thing you can do to make your framework extendable without forcing the user to edit the framework file is to wrap the framework functions in conditionals like this:

Code: Select all

if( ! function_exists('func_name'))
{
    /**
     * Some function for the framework.
     */
    function func_name()
    {
        // ...
    }
}
Then the framework user can replace the functions by creating their own variants before they load the framework core.

Re: My micro framework

Posted: Fri Aug 07, 2009 5:11 am
by onion2k
Pretty horrible way of doing it though. Why not just use objects and let people extend it that way?

Re: My micro framework

Posted: Fri Aug 07, 2009 5:26 am
by m4rw3r
onion2k wrote:Pretty horrible way of doing it though. Why not just use objects and let people extend it that way?
I know it is horrible, but if he wants to use functions, then that is the only way to replace them (except for using bytekit).

Re: My micro framework

Posted: Fri Aug 07, 2009 12:15 pm
by mxp
arborint wrote:I tried to get the code to work with PHP 5.2 and did not have any success. There seem to be some errors in the code. Maybe it is PHP4 code.
Sorry there must be something you are missing. I have tested it for PHP 5.2 with Apache. What are your specs?
m4rw3r wrote:One thing you can do to make your framework extendable without forcing the user to edit the framework file is to wrap the framework functions in conditionals like this:
Sure! Why not!
onion2k wrote:Pretty horrible way of doing it though. Why not just use objects and let people extend it that way?
I wish PHP could have a Python styled module; but I am still thinking "Should I warp them in static class methods?". I don't know yet!