Friday, May 4, 2012

PHP - MVC framework?


I am just starting out in the PHP world. I have used asp.net mvc and come from a VS 2008 background..



I looked at PHP and it seems that a lot of the code is mixed in with the html... so I was looking for something to manage separation... I found



http://kohanaphp.com/home



but being a complete beginner in this i am unsure if its a good framework .... It uses the MVC pattern which should be good as i used this in other products...



I would really love some guidance..



I want to be able to start with PHP and i want to be able to keep as close as possible to PURE php but with a bit more separation (html and php code etc to help with maintainability )



Is MVC a good way to go? And is kohanaphp a good product, its open soruce as far as i can see but maybe there is a better alternative.



I have gone with the ZEND editor, well i have a trial ... it appears to be a general good editor for PHP?



Thanks



EDIT



Wow! thanks for such great feedback... So i am sort of stuck (after reading advise etc) between codeigniter and kohana ...



It appears that codeigniter has really good documentation but still uses OOP on PHP 4... Is this still the case??



So what does this actually mean? I can't use PHP 5 OOP features with codeigniter??



I must admit i was really ready to go with kohana but after doing a bit more investigation it appears that its documentation is very poor..



ZEND FRAMEWORK



Does anyone have any comments with regards to zend framework?


Source: Tips4all

10 comments:

  1. There are an overabundance of MVC frameworks for PHP. Most of them are quite good. Which one should you choose? There are numerous questions on StackOverflow that address this.

    I'd say it's a toss-up, because most of them support MVC features more or less similarly, and also have some kind of database abstraction. So you can decide based on various non-technical criteria, such as:


    Software license (GPL, New BSD, PHP, MIT, etc.).
    Quality of online documentation, tutorials, screencasts.
    Community activity.
    Prettiness of their website. :-)


    A few of the most popular frameworks include:


    Kohana
    Solar
    Symfony
    Zend Framework
    CakePHP (compatible with PHP 4)
    CodeIgniter (compatible with PHP 4)


    And there are a number of PHP content-management systems that are so configurable as to bridge the gap into being a general-purpose framework:


    Drupal
    eZ Components
    Horde
    Joomla!
    WordPress


    There's no strict definition for what is "pure PHP" but all of the frameworks encourage a separation between PHP code and HTML presentation.

    As for editors, I don't use the Zend editor (despite the fact that I worked for Zend at one time) because I don't care for Eclipse. I simply use vim most often, but I have also used NetBeans. See The Best PHP Editor for Vista for a bunch of other options.



    update: Re your additional questions: Yes, CodeIgniter and CakePHP are examples of PHP frameworks that maintain compatibility with PHP 4. There were some rudimentary and half-hearted OO features in PHP 4, but PHP 5 really advanced the OO capabilities of the language.

    The PHP community has officially discontinued support for PHP 4 as of 2007-12-31, and the last bugfix release for 4.x was 2008-08-07.

    So I recommend against using a framework that maintains compatibility with PHP 4, unless you're really constrained to use a hosting provider that is stuck on PHP 4 and won't offer an upgraded environment (though it would be preferable to switch to a different hosting provider if this is the case).



    Re Zend Framework: I worked as the project lead on Zend Framework through their 1.0 release in June 2007. In my opinion, they're kind of an "everything including the kitchen sink" framework, and there's little rhyme or reason to their ongoing development.

    They were late to support "scaffolding" (i.e. code-generation tools) common to many other frameworks, and the tools they have are buggy and poorly documented.

    The Zend Framework project seems to have virtually abandoned all deliberate effort on the database component in the framework, and now they've proposed to replace it with Doctrine, which is a popular ORM for PHP.

    ZF's community Proposal process has become stalled, and their roadmap for future development is almost entirely devoted to refactoring their inconsistent internal code and architecture, not value-add features.

    ReplyDelete
  2. I would say, for a big application, at least, that, yes, MVC is the way to go.


    After, which framework should you used... That's another question, which has been debated on SO over and over again ; I'll let you search on the site, about that ;-)

    Some great PHP 5 Frameworks, that are suited for big/entreprise-grade applications, are, for instance :


    symfony
    Zend Framework
    You already talked about Kohana -- I've never used it, but many people here seem to know about it ^^


    And, about the many man "which framework should I use", you might want to take a look at, for instance :


    What PHP framework would you choose for a new application and why?
    Best PHP framework for an experienced PHP developer?
    Which PHP Framework is right for this project?
    PHP MVC Framework for the enterprise.
    which is the best PHP framework to use for large scale web applications


    (Semi-random selection ^^ )


    About the IDE :


    I use Eclipse PDT -- which is some kind of "free version" of Zend Studio ; I like it
    I know people who work with Zend Studio, and like it too
    There is also netbeans for PHP, which many people find good too.


    I'd say it's mostly a matter of taste, actually ;-)

    ReplyDelete
  3. I think for beginners CodeIgniter is really great.

    It provides a very simple user guide, and good tutorials.

    ReplyDelete
  4. I upvoted a few answers, but here's another one. I tried CakePHP, CodeIgniter, Kohana, Zend, Akelos and Yii.

    From my experience, it is best to start with CodeIgniter, especially if you are not familiar with MVC. It's easiest to learn because of great tutorials, videos and documentation. If you go into some other framework, you would have a hard time learning both how to do something and why it should be done that way. CodeIgniter does both "how" and "why" easily at the same time.

    Once you do a few projects with CI (one big project should be enough), you will be more experienced and then you'll see the limitations it has. Then you can select some framework for advanced users. Most frameworks push "convention over configuration" much further than CodeIgniter, so you won't be able to grasp stuff easily until you do a real application and understand what are the requirements. You will also know which features are important to you and what to look for in the next framework you will use. I choose Yii personally, because it fits my needs, but YMMV.

    ReplyDelete
  5. If you are new to PHP my suggestion is you start with CodeIgniter, Kohana is a fork of CodeIgniter and definitely a much better framework, however, you will learn quicker with the former. Another good framework is CakePHP.

    MVC is the WAY to go!

    For an editor you can use Eclipse or even Netbeans, there are quite a few out there.

    There is no such thing as PURE PHP :)

    ReplyDelete
  6. You asked for information on Zend Framework

    Zend is the PHP company. It is what Asp .Net MVC in PHP. Configuring zend framework takes some time, it is not easy as some others (especially as cakephp or codeigniter).

    I use ZF, never wrote a real project with any other, but those who use codeigniter do not say good things about ZF :) (performance matters)

    ReplyDelete
  7. I've discovered Yii a few weeks ago.
    Seems worth a try.
    I've used Zend Framework for a while but for various reason i'm investogating others frameworks for future projects.

    ReplyDelete
  8. While there are certainly some great full MVC frameworks available for PHP (CakePHP, Zend, CodeIgniter, etc.), if you want to stick as closely as possible to pure PHP but simply have MVC-like elements of separation between presentation layer, business layer, and controllers, try a simple templating engine like Smarty.

    Your MVC folder structure could look like:


    classes/

    Model (.php) files.

    public_html/

    Controller (.php) files; interacts with Model, passes data to template files and displays them.

    templates/

    View (.tpl) files; simple HTML with Smarty tags mixed in. These can be simple variables and can include special loops, etc. Check out Smarty Crash Course.



    The benefit of using Smarty is that you keep the benefits of MVC without having the bloat (and learning curve) of a full-blown framework.

    ReplyDelete
  9. MVC is excellent, and Kohana is superb. Give it a shot, you'll love it!

    I too spent a couple years working with .NET before coming over to PHP/MVC. I tried a couple frameworks prior to Kohana, but grew frustrated with them. Kohana is a very clean and elegant framework, and I've not been displeased a single day with it.

    Kohana is an improved version of CodeIgniter.

    ReplyDelete
  10. My recommendation is to use whatever was modeled after/for PHP +5.2. Kohana, Zend Framework, etc... avoid frameworks like CakePHP...

    ReplyDelete