tags:

views:

909

answers:

9

I'm looking for a simple PHP framework for a beginner :) Any recommendations?

Not Codeigniter. That's too much for me.

Thanks in advance.

A: 

I think you should check out CakePHP at http://cakephp.org/

Cake essentially allows you to think about the views, controllers and models you need to use in your application and largely allows you to forget about the problems and time challenges developers face when starting a project.

It follows the MVC pattern http://en.wikipedia.org/wiki/Model-view-controller which will keep things simple for you as it separates stuff. Additionally the framework has plenty of documentation

Stewart Robinson
-1 CakePHP is about as far away from 'simple' or 'light' as it gets.
Paolo Bergantino
-1 do you think cakePHP is simpler than codeigniter?
Mohamed
I don't know CodeIgniter,cakephp has great documentation even if it can get complex. However the idea of cake is simple. Separation allows you to think differently about your problem. Also the questions specifically said No CodeIgniter
Stewart Robinson
+4  A: 

The Simple PHP Framework may be of some interest.

The Simple PHP Framework is a pragmatic approach for developing websites with PHP 5. Our target audience is web design shops who need to get projects off the ground quickly and individual programmers who just don't care or need to use any one of the many large, cumbersome, MVC frameworks floating around.

Philip Morton
+8  A: 

Codeigniter is one of the simplest frameworks I've seen. Anything simpler, you might as well write direct php code.

trex279
+1  A: 

Take a look at Symfony: http://www.symfony-project.org/

defeated
+1  A: 

I've built this a while ago: http://code.google.com/p/wephp/

Luca Matteis
+2  A: 

Build your own?

I think a good minimalist php framework would consist of a front controller, a view class, an autoloader, and perhaps a router.

The front controller could be an index.php file in the document root. An .htaccess file would pass all requests (outside of existing resources like css, js, etc.) to index.php. The front controller would parse the url and dispatch to the correct php controller class and method. Add a router class, and you could optionally map specific url patterns to any controller you wish.

A view class could simply load a specified php view file and extract() an array variables passed to it. Alternatively, the view class could be a template engine like Smarty.

You'll eventually need helper and library classes. The Zend Framework or PEAR components could be used along with a custom autoloader function so you don't have to require component classes before instantiating them.

Store all your php files except the index.php front controller outside of the document root to avoid direct access.

rick
+1... but drop the Front Controller and let Apache do its f**king job. Look into MultiViews, which it makes it possible for URL "/customer/1/edit" to really refer to "customer.php" with positional parameters "/1/edit".
Tom
Well MultiViews isn't as flexible as mod_rewrite and a front controller. With MultiViews, urls must match the file name(path/to/file*). So no optional routing, and no storing controllers above doc root to avoid direct access. Also, you'd have to include code in each controller to parse the url.
rick
The trouble with any Apache solution (MultiViews and/or .htaccess) vs passing everything to a front controller is also that (with former) you've two places to update everything. This gets to be a pain with *really* big sites.
da5id
Also, I put my front controller in a separate file to index.php (which generally has just bare layout), but that's just pedantics :)
da5id
@da5id - you make a very good point about having 2 places to update. That affects transparency, consistency, and portability. I like a simple .htaccess file that rewrites everything that isn't an existing file or directory to index.php. Your point makes me think of the pain of stored procedures.
rick
+9  A: 

This question is a bit like going to the hardware store and having a conversation like:

You: I'd like to buy some tools.
Staff Member: Ok, great. What are you building?
You: Don't know yet. But I'm sure I'll need some tools.

There is absolutely no point in solving a problem until you have a problem. Just code vanilla PHP until you decide some particular task is too hard/messy/etc and a framework will actually help you.

And, this may go against the "must-have-framework" crowd, but honestly I think for trivial tasks you're typically better rolling your own (I see logging in Java as a prime example of overcomplication and the merits of rolling your own).

cletus
A: 

Check out LightVC. Super lightweight.

Bob Somers
+1  A: 

I second CodeIgniter. It is simple, well documented and was instrumental in helping my understanding of the MVC style of programming. It doesn't require the use of the command line and it's conventions made a lot of sense to me. I believe it is definitely an excellent beginner's PHP framework.

Now with pros there are some cons. No built-in user authentication libraries (you can download plugins to fill that hole) and while obviously open source I just wasn't as thrilled about it's company backing and therefore intentions as I would of hoped.

CodeIgniter is definitely the place to start with PHP frameworks in my opinion.