20 Replies - 8933 Views - Last Post: 05 June 2012 - 06:36 PM
#1
creating your own framework
Posted 10 July 2011 - 05:03 PM

POPULAR
Well I think a framework is like that. The actual framework are ingredients. Every class is an ingredient like a tomato or noodles, and every function is stuff that makes that ingredient what it is. This will make every future meal (script) easy, because I have already built my ingredients (classes, functions). Then all I will have to do is put it together.
tl;dr: creating your own framework to make scripts for clients easier/faster to create. Good or bad?
Replies To: creating your own framework
#2
Re: creating your own framework
Posted 10 July 2011 - 06:43 PM
creativecoding, on 10 July 2011 - 08:03 PM, said:
Good or bad as opposed to what? Not using any framework at all and writing repetitive ad hoc scripts for everything? Do you even need to ask that?
Let me put it this way. There are two kinds of PHP developers: 1) those who use a framework in their applications (either a third-party one, one they develop from scratch, or a combination thereof) and 2) those who are incompetent. Seriously, it's not even a choice. For any non-trivial project, if you don't use somebody else's framework, then you will end up writing your own. It's the only sane way to work. Reinventing the wheel for every project just isn't a productive way to use your time.
#3
Re: creating your own framework
Posted 10 July 2011 - 06:49 PM
AdaHacker, on 10 July 2011 - 07:43 PM, said:
creativecoding, on 10 July 2011 - 08:03 PM, said:
Good or bad as opposed to what? Not using any framework at all and writing repetitive ad hoc scripts for everything? Do you even need to ask that?
Let me put it this way. There are two kinds of PHP developers: 1) those who use a framework in their applications (either a third-party one, one they develop from scratch, or a combination thereof) and 2) those who are incompetent. Seriously, it's not even a choice. For any non-trivial project, if you don't use somebody else's framework, then you will end up writing your own. It's the only sane way to work. Reinventing the wheel for every project just isn't a productive way to use your time.
Ah good point. I am worried about legality. I know it really shouldn't be a problem but I am slightly worried that people will see my framework and say something like "Hey, I can sell this thing!". I'm not exactly the sharing type when it comes to code that brings me money.
#4
Re: creating your own framework
Posted 10 July 2011 - 06:52 PM
#5
Re: creating your own framework
Posted 22 July 2011 - 07:05 AM

POPULAR
However, to gather a lot of reusable code into your own little script/library over the years is only natural. Even with writing your own MVC "Framework" this is probably good practice, as most people don't require what the larger frameworks provide.
I know a lot of people who will use Zend Framework to simply acheive an MVC structure in their application, such as automatically routing a request to a specific Controller and Action. The whole Zend Framework project is located within the source of the application, yet only a few portions are used. This not only creates massive overhead for a single request by initialising all of Zend Framework's crap, but it's something that you could write yourself in around 15 minutes and have a much faster, automatic and reliable system on your hands.
#6
Re: creating your own framework
Posted 23 July 2011 - 07:36 PM

POPULAR
creativecoding, on 11 July 2011 - 12:03 AM, said:
Good. Definitely good.
... Unless you're getting payed payed by the hour, with a flexible deadline
Just make sure whatever contract you have with your client doesn't hand the ownership of your framework over to them. Make it so they are buying a modified copy of your work. As I understand this: as an "employee" your work actually belongs to your "employer"... unless you make sure it doesn't.
(Not that I'm exactly an expert on stuff like this. I steer clear of situations where things like this would be an issue
RudiVisser, on 22 July 2011 - 02:05 PM, said:
Agreed. In the time it took me to get vaguely familiar with the basics of Zend Framework I could have written my own framework to do exactly what I needed, and nothing else.
<rant>
tl;dr: Personally I think ZF, and other such frameworks, are bloated and not worth the effort. It's not hard to create simple frameworks that will work just as well, if not better, for your specific needs.
I mean, look at how Zend Framework handles database queries. I get wanting to abstract things like that, but it not only makes the "query" code less readable, but it has you learning a whole new, harder to use syntax.
How hard is it to write standard SQL code?
SELECT * FROM clients cl JOIN client_roles cr ON cl.role_id = cr.id JOIN countries co ON cl.country_id = co.id WHERE cl.id = ?
But then ZF comes along with stuff like this:
$select = $tbl->select()->setIntegrityCheck(false);
$select->from('clients')
->join('client_roles',
'clients.role_id = client_roles.id',
array('role_name' => 'client_roles.name'))
->join('countries',
'clients.country_id = countries.id',
array('country_name' => 'countries.name'))
->where('clients.id = ?', $id, 'integer');
Who really needs that? Will you perhaps be regularly swapping out database systems?
If you're switching to a database system that is so alien that standard SQL queries can't be used with minimal changes, your probably not going to be able to use the old schema anyways, so this code will have to be changed in any case!
Also, the damn class names!
$inst = new Zend_Random_Feature_That_Is_Hardly_Ever_Useful_At_All(new Zend_Another_Random_Feature_That_The_Other_One_Uses_As_A_Parameter());
After having used namespaces in previous projects, those things were driving me mad.
</rant>
#7
Re: creating your own framework
Posted 24 July 2011 - 11:49 PM
Having to "bootstrap" a web application is just the stupidest thing I've ever heard of, not to mention the additional overhead of all of ZF's crap initializing every time
#8
Re: creating your own framework
Posted 26 July 2011 - 09:53 AM
#9
Re: creating your own framework
Posted 26 July 2011 - 10:24 AM
Or, I'm just not able to spend the time on it because of the impossible deadlines imposed fairly arbitrarily.
Now, if I can just stop my boss from continuing his bad habits...
#10
Re: creating your own framework
Posted 26 July 2011 - 11:35 AM
#11
Re: creating your own framework
Posted 26 July 2011 - 11:48 AM
In general, my view with frameworks is that they should do the job delegated well and be succinct. Verbose frameworks tend to be cumbersome, and this means combining multiple jobs under one framework can be cumbersome to sift through. From what little I've looked at the PHP frameworks, this seems to be one of the problems.
So if you choose to create your own frameworks, make sure to:
-Identify the problem the framework will solve
-Provide the tools to fully solve the problem, and no more
Just my $0.02.
#12
Re: creating your own framework
Posted 01 August 2011 - 03:52 PM
codeprada, on 26 July 2011 - 05:53 PM, said:
I know what you mean. A few months back i began codeigniter, before that i was rewriting code over and over copying and pasting from old projects. but it took about a week to get used to codeigniter and that has increased my productive by 900%. Things are so much faster with forms, database, url, etc etc. You cant be creating php applications without using a framework.
#13
Re: creating your own framework
Posted 01 August 2011 - 03:58 PM
Denis1, on 01 August 2011 - 11:52 PM, said:
Well that's just not true, frameworks such as CI and ZF for simple (or most) projects are simply an expensive overhead that is not required.
I haven't used any framework for any of my PHP developments, apart from when I was forced to use ZF for a commercial project.
What I have used, however, is a reusable library of code that I have written and understand. Call that a framework if you will.
This post has been edited by RudiVisser: 01 August 2011 - 03:58 PM
#14
Re: creating your own framework
Posted 26 August 2011 - 04:59 PM
RudiVisser, on 01 August 2011 - 04:58 PM, said:
Denis1, on 01 August 2011 - 11:52 PM, said:
Well that's just not true, frameworks such as CI and ZF for simple (or most) projects are simply an expensive overhead that is not required.
I haven't used any framework for any of my PHP developments, apart from when I was forced to use ZF for a commercial project.
What I have used, however, is a reusable library of code that I have written and understand. Call that a framework if you will.
I have to agree, I never used any framework in my life but I wrote my own (if you can call it a framework). My framwork uses MVC and a routings file that routs my urls in the right direction. I have a lot of classes I reuse in every project.
#15
Re: creating your own framework
Posted 24 September 2011 - 01:17 PM
I have skimmed through many frameworks and in each framework there are stuffs I like and dislike. Most of the time, a few selected features is all that I need. I am trying to find libraries for those specific stuff.
Here are some of my findings:
- Architecture/URL routing: TinyMVC.
- Template System: phpti brings a concept of "template inheritance". Those who have used template engines like Smarty may have heard of it.
- Database: idiorm. No models and stuff. jQuery like chaining for SQL building. For complex stuff, its possible to write SQL.
- Form validation: Looking into Phorm. Still searching for a good one.
- Permission system: Searching for a RBAC or ACL system. So far I liked the Yii RBAC/ACL system.
I'd stop here. But I think we could add more to the list (web service,I18N,caching,security...). Feel free to share your thoughts.
|
|

New Topic/Question
Reply




MultiQuote











|