Yii or Zend framework?

Discussion in 'PHP' started by Brad77, Nov 21, 2013.

  1. #1
    I have a site that I want converted into a framework. It is a large site. I read so many good and bad things about frameworks. I read they slow site speed down etc. I was leaning towards Zend and then I started reading about Yii. Can someone give their opinions on both? Pros and cons? I read that Yii is fastest performing framework out there.
     
    Brad77, Nov 21, 2013 IP
  2. HolyRoller

    HolyRoller Well-Known Member

    Messages:
    552
    Likes Received:
    27
    Best Answers:
    1
    Trophy Points:
    150
    #2
    Why do you need to convert a site to either of these frameworks, how is it currently coded?
     
    HolyRoller, Nov 22, 2013 IP
  3. Brad77

    Brad77 Member

    Messages:
    95
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    33
    #3
    The site is all custom php. I have been told its easier to work with when in a framework. Someone looked at my code and asked why its not in an MVC and that its messy.
     
    Brad77, Nov 22, 2013 IP
  4. HolyRoller

    HolyRoller Well-Known Member

    Messages:
    552
    Likes Received:
    27
    Best Answers:
    1
    Trophy Points:
    150
    #4
    My preference is just to work within straight PHP rather than using a framework, there seems to always be a new framework that is a must learn these days.
     
    HolyRoller, Nov 22, 2013 IP
  5. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #5
    Messy it might be. However, MVC and PHP is still in its infancy, and basically, creates more trouble than it's worth, most of the time. Depending, you end up with 100s of class-files, includes and other crap. It depends on how complicated your site is, of course.

    "Someone looked at it, and told me it was messy" - again, it might be. Or someone has their head stuck up some framework's ass, and refuses to get it out.
    Frameworks MIGHT be easier for future devs, if they know the framework, but than again - if the site is working properly now, why rewrite the whole thing? And believe me, it will be a complete rewrite, nothing half-assed is gonna be any better.

    The question isn't "Which framework should I use" it's "Should I use a framwork at all".
     
    PoPSiCLe, Nov 22, 2013 IP
    sabato likes this.
  6. NetStar

    NetStar Notable Member

    Messages:
    2,471
    Likes Received:
    541
    Best Answers:
    21
    Trophy Points:
    245
    #6
    I might catch heat for this but oh well... Frameworks on paper are fantastic. They allow you to speed up the development of a web site by writing less and producing organized code that can easily be expanded. Simply wonderful...on paper.

    Now in reality, you will spend more time learning how to use a framework and coming up with work arounds to do things your way, or a more logical way, than you would if you were to just build the site without one! It's bad enough we have to deal with interpreted languages being slow. Now we have to deal with a slow language with many layers and layers AND layers of framework, orm, and templating code that just bogs us down even more! While it's awesome that a framework claims to allow you to do more with less code, for any project I have ever worked on with zf I've always had to write more code than if I didn't use zf. Go figure.. And just when you master a framework they drop support and come out with a new version making all previous work legacy code and forcing you to learn yet another entirely new approach.

    My advice is to learn how to write your code the right way. Get in the the habit of learning object oriented programming which will allow you to create and reuse your own components. Learn design patterns like Mvc and single entry points. I don't recommend recreating your own framework but there is nothing wrong with building a foundation to your projects. The Mvc approach I use in my projects is about 10kb tops and I use php as my templating language.
     
    NetStar, Nov 22, 2013 IP
  7. Brad77

    Brad77 Member

    Messages:
    95
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    33
    #7
    So I had my site built in custom coding. Now having issues with some of the lines and getting someone else to fix they are saying its "messy or spagetti like" they tell me that having it in a framework keeps your code manageable , readable, error free and secure.

    Can my code be put in a MVC format? Its already created but obviously to others its messy.
     
    Brad77, Nov 24, 2013 IP
  8. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #8
    It might be easier for others to understand your code, especially if it's messy and spaghetti-like, as you say - if your code is mostly self-documenting, has proper documentation for functions and classes, and is created properly, it shouldn't take an experienced PHP-coder more than a day or two to understand the basics, at most. Maybe a little less if it's built in a framework. However, depending on how much custom code you have (yes, I understand all of your site is custom coded) or will need to have customcoded even if you run a framework, it might not be too much of a save.
    Saying that using a framework will automatically make your code manageable, readable and secure is at best a naive look on the world, at worst a blatant lie. It MIGHT help on all those accounts, but that means you'll have to have coders who knows what they're doing.

    It's completely possible to mess up the code, manage-wise, readability-wise or security-wise, even if you use a framework.

    The way I guess your code is today, no it cannot be put in a MVC-format. It will need a complete rewrite, to benefit from being put in a framework, using that framework's MVC-structure etc.

    Given, MVC in PHP-world is a bit of a WTF, since the whole point of PHP is too keep the code as minimized as possible, and provide direct output and input (via filters and such, but you understand what I mean). The MVC approach using PHP isn't always the best way.
     
    PoPSiCLe, Nov 24, 2013 IP
  9. NetStar

    NetStar Notable Member

    Messages:
    2,471
    Likes Received:
    541
    Best Answers:
    21
    Trophy Points:
    245
    #9
    The real question is... Is it messy to others or is it just confusing to the inexperienced? We have no idea what your code looks like or who looked at it previously.
     
    NetStar, Nov 24, 2013 IP
  10. Brad77

    Brad77 Member

    Messages:
    95
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    33
    #10
    I see your point of view clearly. From someones eyes of always use a Framework only then looking at something not in a framework would be messy I guess especially if you are not used to seeing it. It make complete sense to me.
     
    Brad77, Nov 24, 2013 IP
  11. MakZF

    MakZF Well-Known Member

    Messages:
    390
    Likes Received:
    9
    Best Answers:
    1
    Trophy Points:
    140
    #11
    If it's a large site and the current codebase is not too difficult to maintain, I would probably avoid moving over to a framework, unless you have a lot of free time on your hands to learn a framework and apply it properly. Frameworks are clearly useful if used right, but you would have to take care and not just turn an existing spaghetti code base and rewrite it to another one. Frameworks often provide many useful features - such as security, caching, etc. but it's largely up to you to implement a maintainable codebase.
     
    MakZF, Nov 25, 2013 IP
  12. NetStar

    NetStar Notable Member

    Messages:
    2,471
    Likes Received:
    541
    Best Answers:
    21
    Trophy Points:
    245
    #12
    Just to point out. A framework doesn't make your code secure, readable, organized, and easy to update. Your programming does. I've seen many developers switch over to a framework for the above reasons to only recreate a complete and utter mess. Keep in mind, you will make tons of mistakes when learning a new framework. Why would you want your current project to be your test pilot when learning a framework? It doesn't make sense.

    If you feel you absolutely need a framework and would like to learn one (which is never a bad idea) then do so. But don't do so at the expense of making your existing project less secure, organized and optimized.
     
    NetStar, Nov 25, 2013 IP
  13. Brad77

    Brad77 Member

    Messages:
    95
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    33
    #13
    Is there a way to clean up code that is messy? Make it more structured without using a framework?
     
    Brad77, Nov 25, 2013 IP
  14. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #14
    Uhm. Rewrite whatever messy parts you have? Keep consistent function and classnames, keep the variable names easy to understand, document and comment code that isn't self-documenting, etc.
    Try to find more effective ways to achieve the same goals - ie, if you have 200 lines of code where 10 could do the same job, if only reorganised, do so.
    Anyway, making messy code more readable/understandable will most likely require a bit of refactoring and recoding.
     
    PoPSiCLe, Nov 26, 2013 IP