LebGeeks

A community for technology geeks in Lebanon.

You are not logged in.

#1 June 27 2010

Kassem
Member

Thoughts on CakePHP

Hey guys,

Today I've started watching a video training series on how to build an invoice application using CakePHP. So far I have good impressions about the framework. I've finished the first 3 lessons up-till-now, the first was about installing CakePHP, the second about creating the models/controllers/views, and the third was about form validation.

Installing CakePHP and "baking" your application is relatively easy. You then have to use the command line prompt which comes along with the CakePHP files and it's just a matter of reading questions and typing "y" or "n". It is a little boring when you have to create several models/controllers/views. The nice thing is that within around 5 minute you're done with all the scaffolding and foundation work of your application. At that time, you already have a fully function CRUD application. Note that you need to follow some conventions while naming your tables' attributes, the primary keys (should always be id), foreign key (foreign table name _ id)... etc.

And then comes validation which really made me think "Damn! it's really worth spending the time and effort learning this thing!". Inside your models, you provide the necessary validation rules for every form field you want to validate. There are already several pre-built rules which will help you validate your forms very easily. Every form can take as many validation rules as needed. The bottom line is: your application will be secure and it wouldn't take much effort!

Update:
Another good feature about CakePHP is its schema tool. The schema tool runs in the console and makes it VERY easy to alter or drop tables. Its main purpose is for version control. It allows you to create snapshots of the database, and you can easily roll-back or forward to the snapshot you want. It also makes it very easy to share the schema among your team members. Whenever there's a change in the schema, you can simply send them the php file generated by the schema tool and then they could easily update their schema as well.

... to be continued

Last edited by Kassem (July 10 2010)

Offline

#2 June 28 2010

Joe
Member

Re: Thoughts on CakePHP

I have been playing with Symfony for the last three months. PHP frameworks are really interesting. Wonder how it compares to cake ?

Offline

#3 June 28 2010

Kassem
Member

Re: Thoughts on CakePHP

rahmu wrote:

I have been playing with Symfony for the last three months. PHP frameworks are really interesting. Wonder how it compares to cake ?

Yeah definitely! I will provide some feedback on every feature I come across with CakePHP, maybe you could reply and compare that with Symphony or maybe provide an overview of Symphony like I'm doing with cake?

And yeah, PHP frameworks look very interesting. I never knew frameworks actually do the job for you, I thought they merely facilitate some of the tasks. From what I've seen with CakePHP, you could probably get done with full featured website/web app in a few hours work. Efficient eh?

Last edited by Kassem (June 28 2010)

Offline

#4 June 28 2010

Joe
Member

Re: Thoughts on CakePHP

The idea behind frameworks is automatic code generation. It takes a while getting used to, definitely weird to debug, but once you are comfortable with it, it boosts your productivity like crazy.

I don't have the time for a full review of Symfony right now, but I could definitely do a quick one :

Symfony is based on PHP 5 fully enforcing OOP programming and MVC design pattern. Out of the three approaches I found for MVC, it uses the third one. So it comes as no surprises that it has an ORM tool bundled with it (Doctrine). This abstraction layer makes database interaction so much easier.

A lot of the work consists of calling symfony tasks (functions) from the command line. Based on editable conf files, the tasks will generate chunks of code you use for your application. The developer's job usually consists of extending (inheritance) those generated classes, to create their own methods.  Conf files are written in YAML, a superset of JSON.

Finally, Symfony filters the data autmatically, enhancing the security of your app (juste like Cake does :-) )

Offline

#5 June 28 2010

arithma
Member

Re: Thoughts on CakePHP

I have tried CodeIgniter so far. It's extremely easy to play with, and some developers like it. However the thing I have against it is the lack of a concrete module.
HTML, CSS, and Javascript are insane. Let's face it, they're not doing what they were first designed to be doing. You do actually need a framework that hides that insanity from you. I'll talk more later. But keywords: Lack of a module, irresponsible clashing introduced by non locality of id attributes and verbose specification of the web page. All that while attaching a mismatching language to a DOM. What the hell were they thinking when they thought getElementByID is all ok? How about all those intermixed <script> tags..?

Offline

#6 June 30 2010

GoogleGirl
Member

Re: Thoughts on CakePHP

well yeah Kassem the cakephp framwork is a very easy to learn though it will take some time to get used to it specially if you're used to the "freelance coding". Here using cakephp you have to follow their naming conventions and their structure , though you can override most of their classes but thus you loose the cake magic which are the predefined classes that simplify the coding.
I've been using the cakephp for time now , first i started with the 1.1 and now im using the 1.2 version .
let me know if u have any questions , maybe i can help !

Offline

#7 July 10 2010

Kassem
Member

Re: Thoughts on CakePHP

Ok I've just updated my first post in this thread.

@arithma: What are your experiences with the CodeIgniter framework? What did you like about it? What did you dislike about it besides the lack of module? Enlighten us! :)

Offline

#8 July 11 2010

Joe
Member

Re: Thoughts on CakePHP

I am trying Django. Here are my first impressions, comparing it to Symfony:

* Code is in Python, much more readable than PHP.
* There are no config files. Config is hard coded into classes directly. Symfony uses YAML.
* Django sets up its own development webserver. It's great because, who can be bothered to administer Apache in dev environment?
* No support for migrations!!! Once your models go into production they're basically fixed. (Unless you enjoy risk taking and will modify your database live ... :-S ). Symfony is great with migrations.

Here are my first impressions. The lack of migration features really bothered me. For everything else, Django rocks. Hard.

Last edited by Joe (July 11 2010)

Offline

#9 July 11 2010

rolf
Member

Re: Thoughts on CakePHP

rahmu wrote:

* Django sets up its own development webserver. It's great because, who can be bothered to administer Apache in dev environment?

Huh? What are these bothering things you are talking about?

Last edited by rolf (July 11 2010)

Offline

#10 July 11 2010

Joe
Member

Re: Thoughts on CakePHP

Well it might seem silly, but around 5% of my work time is spent on administrating Apache and PostgreSQL on my local machine. By combining an internal webserver and a SQLite storage, Django allows you to focus on the code, and thus improve your productivity.

The idea is that Apache administration is not the working specialty of web developers. It's the duty of a sysadmin to take care of those problems.

Offline

#11 July 11 2010

rolf
Member

Re: Thoughts on CakePHP

I dont know what you're talking about when you say "apache administration"!
AFAIK there maybe be some work involved during installation of apache, maybe setting up ports and directories. But once it's running, I really dont see what there is to do. Besides, is the Django server production-ready?

Offline

#12 July 11 2010

Joe
Member

Re: Thoughts on CakePHP

Some examples of the problems we encoutner at work:

- we had to migrate our website under Symfony. The first thing we had to do was to configure Apache .htaccess to reroute correctly.
- I have a coworker who has a mysterious bug on his machine, and Apache doesn't run on startup, he has to start it manually every morning.
- I remember a coworker spending time on the mod_perl module, when we needed to add a perl monitoring script to our website.

Databases could be tiresome too. For example we are adopting a TDD (Test Driven Development) approach and we decided that it'd be easier to set up for each developer an instance of the database locally on their machines. Would you believe me if I told you that we've been working on this for over 3 days ?

My only point is that Django allows you not to worry about those tasks and focus on your code, by providing an internal webserver (coupled with an optional SQLite). Of course it is not production ready. Of course at some point you'll need to configure your Apache and have it running. But this should be done once in production environment. Not on every development environment.

At least this is the Python approach. Is it useful? I am willing to believe it. But quite frankly I have just discovered this today, so I am not the authority on the matter. I just found that to be a refreshing idea.

Offline

#13 July 11 2010

rolf
Member

Re: Thoughts on CakePHP

You may be right, Django does remove this from you, but on the other hand, in the examples you gave, the first one looks like an issue with Symfony, and the 3rd one, well...

To rephrase, Apache gives you more options, but you will have to spend time configuring them ... if you want to use them! But, if you choose not to use these options, then Apache will not require any more work then the Django embedded server. Or just a little additional work on install.

Offline

#14 July 11 2010

xterm
Moderator

Re: Thoughts on CakePHP

Django's Development Server is not production ready, hence the term "Development Server".

Django as with Ruby on Rails, is simply amazing.

Last edited by xterm (July 11 2010)

Offline

#15 July 11 2010

rolf
Member

Re: Thoughts on CakePHP

Forgive me if I sound harsh or cynical or anything like that, but I dont see what the hype is about.
I played with both technologies, but I didnt see it.
I'd appreciate if someone would enlighten me!

Offline

#16 July 11 2010

Joe
Member

Re: Thoughts on CakePHP

Frameworks vs "from scratch" : Frameworks are mandatory if you're not the only one who will maintain the code. You're also a 1000 times more productive. Scaffolding allows you to develop your CRUD (Create Read Update Delete) for any model in matters of seconds. It is also more secure, as every vulnerability is fixed by a community of users. Working "from scratch" makes it hard to follow every vulnerability.

Django vs Symfony: (only frameworks I have used so far). Both are great, both have their limits. Like I said, I was disappointed that Django doesn't support database migrations. Also, a search function in the admin is giving me a runtime error. It's automatically generated, I'd expect it to work o_O. On the bright side, Django uses Python, a great language. It also provides a perfect testing environment (webserver, db, but also an interactive shell). Coding seems easy and documentation is absolutely great.

Symfony supports many advanced DB manipulation thanks to the use of a third party ORM (developer can chose between Doctrine and Propel, though Doctrine is going to be exclusive as of v2.0). It is written in PHP. I don't like the code, but I have to admit it is thoroughly documented. Another thing I dislike is the use of YAML (the superset of JSON) to define config. Django does it in Python code immediately.

Finally it all boils down to each's preferences. But each tool (Django, Symfony, Cake, RoR, ...) or lack thereof ("from scratch") has its own approach to solve common problems. You have to learn the approach. You cannot code Symfony-like with Django. You won't like the tool and drop it.

Symfony

Offline

#17 July 12 2010

Kassem
Member

Re: Thoughts on CakePHP

I strongly recommend looking into CakePHP.

Offline

#18 July 12 2010

xterm
Moderator

Re: Thoughts on CakePHP

rolf wrote:

Forgive me if I sound harsh or cynical or anything like that, but I dont see what the hype is about.
I played with both technologies, but I didnt see it.
I'd appreciate if someone would enlighten me!

As opposed to what though? Not using a web framework or comparing to a different one?

Offline

#19 July 12 2010

rolf
Member

Re: Thoughts on CakePHP

xterm wrote:
rolf wrote:

Forgive me if I sound harsh or cynical or anything like that, but I dont see what the hype is about.
I played with both technologies, but I didnt see it.
I'd appreciate if someone would enlighten me!

As opposed to what though? Not using a web framework or comparing to a different one?

As opposed to how I normally work, that is using my own minimalistic framework (maybe framework is an ambitious title, but I do have an organization and a set of classes that I always use).

Offline

#20 July 12 2010

Joe
Member

Re: Thoughts on CakePHP

Once again, are you the only one maintaining your code? If so, use the tools you are comfortable with. A strong framework will improve your code maintainability like crazy though.

Offline

#21 July 12 2010

xterm
Moderator

Re: Thoughts on CakePHP

A web framework will help you get started faster than you would using any library you've created. Simply because it's main purpose is to relieve you from the repetitive and boiler plate code that you so often write in order to get up and running. But ofcourse, the most important part of a web framework is, Separation of Concerns.

If you're using RoR or Django or any similar framework, you would have a skeleton to work with. You would have numerous utilities that would generate (whilst keeping the flexibility of modifying) your components with ease. Moreover, you'd have common grounds with so many developers working with the framework as well.

The more your web application grows, the more it needs to be modularized. There are numerous articles that discuss the benefits of web frameworks that i cannot re-iterate here without missing something. The simplest way to see the power of each, is to either check the "Blog in 15 minutes" on RoR's website or the tutorial on djangoproject.com

One more thing you could do is to watch the Snakes and Rubies head to head interview.

Last edited by xterm (July 12 2010)

Offline

#22 July 12 2010

rolf
Member

Re: Thoughts on CakePHP

xterm wrote:

A web framework will help you get started faster than you would using any library you've created.

Not really since I'd have to spend twice the time reading documentation and understanding how the darn thing works before doing anything more useful then "Hello World".

xterm wrote:

Simply because it's main purpose is to relieve you from the repetitive and boiler plate code that you so often write in order to get up and running.

I copy paste from previous projects for that, besides as I said before I have some classes I always reuse (specifically database abstraction and error handling)

xterm wrote:

But ofcourse, the most important part of a web framework is, Separation of Concerns.

If you mean MVC I am also doing that on my own.

xterm wrote:

If you're using RoR or Django or any similar framework, you would have a skeleton to work with. You would have numerous utilities that would generate (whilst keeping the flexibility of modifying) your components with ease.

Although dynamic code generation is attractive, I personally prefer to go other ways. I dont deny that it can do wonders in some situations.


xterm wrote:

Moreover, you'd have common grounds with so many developers working with the framework as well.

And that is probably the biggest advantage, despite the fact that most developers can get up to speed pretty fast on an in-house framework or organisation, this is even faster, and it is a good (but not flawless) guarantee against unmaintainable code.

xterm wrote:

The simplest way to see the power of each, is to either check the "Blog in 15 minutes" on RoR's website or the tutorial on djangoproject.com

And this is why I get emotional sometimes while discussing frameworks. I did try both of these, and also spend considerably more time trying to get familiar with symfony. I came out of these trials thinking that either the whole world is misled, or I am stupid.
The truth is maybe that I am a special case (dont I like to be a special case :-)), and I know PHP very well, sometimes that not all programmers have, therefore I am better off trying to take advantage from this knowledge without frameworks or other layers of abstraction or new languages.

xterm wrote:

One more thing you could do is to watch the Snakes and Rubies head to head interview.

Interview? well thanks, I'll check it out some time.

And I want to add, thank you for taking the time to answer, I sincerely appreciate it.
I have to admitt that I didnt check the links you gave me, but I will do so soon.

Offline

#23 July 12 2010

rolf
Member

Re: Thoughts on CakePHP

rahmu wrote:

Once again, are you the only one maintaining your code? If so, use the tools you are comfortable with. A strong framework will improve your code maintainability like crazy though.

Yep, I am usually the only one - with some exceptions where someone did some minor modifications. But I think my code is easy to understand and maintain, I designed it with that in mind. It does lack documentation though.

Offline

#24 July 12 2010

Kassem
Member

Re: Thoughts on CakePHP

One other thing xterm have missed, and that is frameworks provide secure applications. The core code of the framework has been tested and is being updated by a whole community of users. Bugs are being reported keeping little space for mistakes, especially after a framework has been established and adopted by large numbers of users.

Also, in addition to the CRUD functionalities and scaffolding you get instantly when using a framework, you also have helpers, validators, components, behaviors... etc. that make your life much easier while coding your application.

Personally, I found CakePHP to be very easy to learn. The syntax is user-friendly (while Symphony isn't - at least that's what I've heard). I still have a lot to learn about Cake, but so far things are going very well. Now I think I should use an Actionscript 3.0 framework as well, because I often find myself doing ALOT of ground-work whenever I start building a Flash application. I'll have to choose between GAIA and PureMVC.

Offline

Board footer