Page 1 of 1
PHP Cake or my own code ?
Posted: Wed Nov 30, 2011 3:18 am
by amirbwb
Hello,
I have created many websites using only classic php and functions
But now I decided to learn classes, I understood how it works but haven't used it yet.
I have phpcake tutorials, but don't know if it is good to learn it or it is not a good idea or it not for professionals ...
Please give me more idea about phpcake and if I should learn it, so I will understand more how we use classes in big projects and cms ?
Does professional programmers use a framework or they code everything by themselves ?
Thank you,
Re: PHP Cake or my own code ?
Posted: Wed Nov 30, 2011 3:49 am
by maxx99
It depends on project, but usually we go with Zend Framework / Symfony / Smarty (or even PHP portlets in Liferay)

When it comes to professional development: faster you develop (of course with good quality) => more money for your company

Re: PHP Cake or my own code ?
Posted: Wed Nov 30, 2011 3:53 am
by amirbwb
mmm am thinking of if learned framework Zend for example, maybe I will forget how to code a simple classic php cuz I will use frameworks codes,
and I will continue selling websites that are based on a "virtual" code that I haven't created myself ...
Re: PHP Cake or my own code ?
Posted: Wed Nov 30, 2011 5:32 am
by maxx99
Don't assume that framework will do everything for you, it won't

E.g. look at this form extending Zend_Form class.
Code: Select all
$title = new Zend_Form_Element_Select('title');
$title->setLabel('Title')
->setMultiOptions(array('mr'=>'Mr', 'mrs'=>'Mrs'))
->setRequired(true)->addValidator('NotEmpty', true);
$firstName = new Zend_Form_Element_Text('firstName');
$firstName->setLabel('First name')
->setRequired(true)
->addValidator('NotEmpty');
$lastName = new Zend_Form_Element_Text('lastName');
$lastName->setLabel('Last name')
->setRequired(true)
->addValidator('NotEmpty');
$email = new Zend_Form_Element_Text('email');
$email->setLabel('Email address')
->addFilter('StringToLower')
->setRequired(true)
->addValidator('NotEmpty', true)
->addValidator('EmailAddress');
Of course thats not all but more or less output will look like this:

With decorators you can change look&feel as much as you want.
This example shows just working with what Framework gives you, but still, who'd like to do all of this manually? When you have e.g. 20-50 different forms in your app?
You will still need a lot of PHP knowledge to know how it works, to code your business logic, or write your own validators, components, adapters... etc.
Another advantage of this approach is that when you don't have anyone to learn from (internet doesn't always get it right

), framework will give you some guidance of how to run things the good way (MVC is a good example here). Code is easier to work with, basically anyone seeing your sources for the first time will be able to work with it (I'm not talking only about ZF here

)
Re: PHP Cake or my own code ?
Posted: Wed Nov 30, 2011 10:36 am
by amirbwb
when I finished understanding php language without classes, I said OMG it's very simple and what classes could do more for me!! But now I discovered that classes came just after opening the php quotation "<?php", classes are everything!! ... Ahhhhhhhh I have a long way to get into Classes mood anw thank you maxx99 ... I appreciate your help ... =)