Welcome Guest, Not a member yet? Register   Sign In
About php frameworks
#1

[eluser]Unknown[/eluser]
Hello there ! (sorry in advance if there are english mistakes, it's not my language)

I'm an amateur php-coder, sometimes coding for small commercial projects, and I'm just discovering the existence of php frameworks. Until now, I always coded from scratch, just using the phplib templates system.

I've watched the 'blog in 20 minutes' introduction. OK, 20 minutes is fast for doing that.

But in that example, all the elements are simple, for instance, the link made with the url_helper achor() is a normal link. What if I wanted to add a onclick javascript onto my link ? Is there another function ? Do i have to add parameters to anchor() ? And what if I have to put a style, an id, or any other thing ? Do I have to modify the anchor() function ?

Well, what is sure, is that I will have to read the manual just to make a link.

At this point, I ask myself if it isn't just simpler to type in raw html code, which isn't that complex anyway.

And I guess the question is the same about almost everything. Look at the open_form() function, or the mysql functions...

It seems to me as if all of this is just an alternative syntax which I have to relearn, maybe somewhat shorter, but not easier.


I know my post somewhat trollish, I guess I didn't get it... (at least my post will give you feedback about how the introduction video is understood). But I didn't find explanations about the general purpose of a framework, and it's hard to make an idea before using it for a whole project.

Thanks !
#2

[eluser]nmweb[/eluser]
You refer to the helper functions. They are meant to help you, do some things a little faster. Of course they will never be able to completely replace html since that would require adding another markup layer. It's also not that important, complex things you'll often have to do yourself but sometimes its easier to use the helpers. I for example wrote a Form generation library and the library never uses html, it only uses the helpers which contain the html. This keeps my code cleaner and if I ever want to switch form xhmtl to html I only have to edit the helpers.

I think that's the main advantage, your libraries are way cleaner when they use helpers to generate html and it keeps the code DRY.
#3

[eluser]Michael Wales[/eluser]
The helpers you refer to are just one small aspect of the framework - the framework as a whole makes a ton of things easier.

In your current coding practice: what happens when you switch from MySQL to MS SQL? You have to write a lot of new code. In CI - nothing, it still works.

Are you currently protecting your applications from SQL injection and XSS attacks? CI does it for you.

What happens when you want to use sessions? Well, you have to make sure you called session_start() before anything else, you have to worry about how the session ID will be passed from page to page, etc. In CI, you just tell it to set a session variable - everything else is done for you.

These are just minor examples, from 2 of CodeIgniter's 25 libraries.
#4

[eluser]dmiden[/eluser]
The anchor function has the capability to set other attributes of the link,
Code:
anchor(uri segments, text, attributes)

Attributes can also be an array, f.ex. array('class' => 'bold green dumb', 'title' => 'shrek')

One of the main reasons why I use CI is the rich but still lightweight framework.
I usually code bigger commercial projects and CI gets me started in no-time!
Of course do I load my own libraries/helpers.

CI also helps me literally 'code' cleaner. Thumbs up for that.
#5

[eluser]bcdennis[/eluser]
I think you're missing the forest for the trees. No framework is perfect and I've yet to find one that completely meets my needs. What frameworks are intended to do is increase your time to deployment by providing you a basic (or not so basic) application foundation. You just have to find that framework that gives you the biggest productivity boost. CodeIgniter works for because it's lightweight, provides a solid foundation, and doesn't box me in.




Theme © iAndrew 2016 - Forum software by © MyBB