My micro framework

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
mxp
Forum Newbie
Posts: 10
Joined: Sun Aug 03, 2008 11:39 pm

My micro framework

Post 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.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: My micro framework

Post 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.
(#10850)
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: My micro framework

Post 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?
mxp
Forum Newbie
Posts: 10
Joined: Sun Aug 03, 2008 11:39 pm

Re: My micro framework

Post 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.
mxp
Forum Newbie
Posts: 10
Joined: Sun Aug 03, 2008 11:39 pm

Re: My micro framework

Post 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.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: My micro framework

Post 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.
User avatar
m4rw3r
Forum Commoner
Posts: 33
Joined: Mon Aug 03, 2009 4:19 pm
Location: Sweden

Re: My micro framework

Post 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.
mxp
Forum Newbie
Posts: 10
Joined: Sun Aug 03, 2008 11:39 pm

Re: My micro framework

Post 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
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: My micro framework

Post 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.
(#10850)
User avatar
m4rw3r
Forum Commoner
Posts: 33
Joined: Mon Aug 03, 2009 4:19 pm
Location: Sweden

Re: My micro framework

Post 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.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: My micro framework

Post by onion2k »

Pretty horrible way of doing it though. Why not just use objects and let people extend it that way?
User avatar
m4rw3r
Forum Commoner
Posts: 33
Joined: Mon Aug 03, 2009 4:19 pm
Location: Sweden

Re: My micro framework

Post 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).
mxp
Forum Newbie
Posts: 10
Joined: Sun Aug 03, 2008 11:39 pm

Re: My micro framework

Post 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!
Post Reply