cakephp overviews - php

I recently started working with CakePHP but there are a few things I don't understand...
What do I have to do to get an overview of a couple of functions/views on one page like 'www.example.com/profile'. I really need help with this I am stuck in thinking in regular procedural php.

First off, you should follow the Blog tutorial on the CakePHP cook book : http://book.cakephp.org/view/1528/Blog
It's a great example and walks you through all the main stuff.
CakePHP follows an MVC structure and maps the URLs to controller/actions (using routes)
In your example www.example.com/profile, if you haven't changed the default routing, actually maps to the index method in your ProfileController. This method uses the view in /views/profiles/index.ctp to display output.
First follow the tutorial and read up on the CookBook to figure out what all this means. It's very easy to learn and they have some good documentation. Also check out code generation in CakePHP. It helps you create your apps faster (if used properly).

You need to read the manual about Routing. Also be familiar with basic Apache knowledge like mod_rewrite.

Related

Making joomla Extension in my own way

I've tried to understand the structure of joomla. I've read many kinds of documents and tutorial regarding about how to make extensions in joomla. I can't able to understand it fully. I still had some doubts on it. I've made a simple component in joomla by using MVC concept and using some joomla core files. I won't say that it is like same as what professional are making it. I've used 30% of joomla like using MVC concept, extending the core files of joomla and connected with the database using joomla syntax and some other ways also. Rest of the percent, i've used my own codes by using oops concept. So do you think that is it good enough to make an extension like this or i have to make an extension like that or i really have to learn and understand the official joomla way of making it's extension. I want to know it please.
First of all the joomla is given a brief details for developing its extensions.
You can check the following url for understanding the components structure of joomla.
http://docs.joomla.org/Developing_a_Model-View-Controller_Component/1.5/Introduction
In this doc at the end you can find a download link download the component and go through the code you will get full idea about joomla MVC concept.Its pretty simple.
I think no one can explain your requirement with what you are expecting.
Just keep this in mind while developing joomla's extensions.
1)Do not edit core file for your component task achievement.
2)Try to use jRequest class for getting submitted values.
3)For new task use your controller overrided functions.
4)Make all your sql queries inside model only.
5)And make an extension that compact able for later version too.
These are the tips i can give you.
Just walk through the code of some good extensions and try to follow that .
Hope this may help you..
For ease of maintenance and for future development I would definitely recommend that you develop your component the right way. If you are going to release the component I would say that it is a requirement.
The who MVC structure can be confusing at first but once you get your head around it is really nice.
I would suggest making the MVC skeleton by using the Joomla Component Creator
http://www.notwebdesign.com/joomla-component-creator/ and then add the custom code yourself.

Need an Sample Web Application with code of PHP using MVC

Need an Sample Web Application with code of PHP using MVC with the following functionality and the database is mysql
sample:
add
edit
delete
update
I have searched a lot. but i can't find the exact thing what i need.
Kindly provide your suggestions.
thanks in advance.
The term you can search google with is "CRUD" (Create Read Update Delete), there should be a fair few sample applications, try Netbeans examples, they post quite a few bits of PHP. Or look at the Bakery on CakePHP, this will help you with the MVC side of it
Look at the demo application of any PHP framework.
http://www.symfony-project.org/
http://cakephp.org/
http://codeigniter.com/

Are there specific parts of PHP I should learn to help me use CodeIgniter in the future?

I'd like to learn PHP with a view to using CodeIgniter to make a few apps. Does this alter what or how I should approach PHP to start with?
I'm a designer with good front-end skills. I used Coldfusion in University but want to build stuff in a language more widely supported (and respected?). CodeIgniter seems great but I'd like to know how good a grounding in PHP I'll need. Any tutorial/book suggestions much appreciated.
Here' s a post from Derek Allard about learning php with codeigniter (it's short, only a couple paragraphs):
http://www.derekallard.com/blog/post/learning-php-with-codeigniter/
yes there is one major thing you need to learn or understand first. It's the MVC model that codeigniter uses, it stands for Model, view & controller. Basicly you need to split your code into 3 layers, the model is to query the database, the controller is also called the business logic layer, you will need to check if a query can be executed or not and finally the view which is the presentation layer, what the user will see. For the rest general php knwoledge is required for codeigniter.
Here are some articles about MVC structure:
http://net.tutsplus.com/tutorials/other/mvc-for-noobs/
http://net.tutsplus.com/tutorials/php/hvmc-an-introduction-and-application/
and here is a list of 15 video tutorials about codeigniter written by authors of nettuts:
http://net.tutsplus.com/tutorials/php/codeigniter-from-scratch-profiling-benchmarking-hooks/ (this is the last tutorial of the list but it's the only one that links to all other tutorials)
EDIT: OOP (object oriënted programming) is also something you might want to have a look at.
http://net.tutsplus.com/tutorials/php/oop-in-php/
My take: first learn PHP, then learn a framework like CI. Trust me, that is the correct order.

PHP framework of intermediate complexity, in between CodeIgniter and Yii?

Something easy like CI (this means mandatory good, easy, up to date documentation). But also with some more features than CI.
Yii has lots of features, but it is also more complex (and it kind of forces you to have to use lots of it features). That means adding some functionality to your web-app takes three times as long because you have to figure out lots of new small functionalities of Yii.
It's kind of like the CI "gets out of your way" when it needs to, and Yii gets in your way, and if you don't do it its way, it breaks.
Features missing in CI that would be nice to have in this new "intermediate" PHP framework:
Code generation (crud).
Authentication.
Access control.
Layouts.
Widgets.
Easyer / automated pagination (like yii)
easy uri parameters
Where Yii causes me problems:
It's like for every small task there is some inbuilt functionality (this is good), but, YOU HAVE to use the inbuilt functionality, otherwise bad things happen. (CI gets out of your way, but does it too much, Yii helps a lot, but is butting in too much at times, and it forces you to sift through its documentation so that you discover these functions without which you are not able to accomplish a task that would take four time less, in CI, or in a non framework app).
Is there something in between ?
(ASP.NET MVC could be 'it', but I don't know the language, so the effort to learn it would be greater than learning Yii php framework really well, so I am looking for a PHP Framework)
I am a fan of CakePHP. I feel it has the specs you provided. If you want something more cutting edge you can take a look at Lithium
I have found some resources that kindof solve the problem, because they contain examples (Milan Babuškov's sugestion helped focus on "the solution").
Yii playground - examples
Yii cookbook - examples
Yii blog tutorial - more examples
PS. there is also google - I find solution (and examples) the fastest this way - ex: implement + pagination + yii
I've used both CI and Yii (on my own projects if that makes any difference). CI was my first introduction to MVC, and I found it easy going because it let me use any crappy structure and code. I wrote two full sites in CI (www.insolvencynews.com and www.thebigeat.com if you want to see complexity.)
I had a look at CakePHP but got NOWHERE.
Then I moved on to Yii and, like you, I found it pretty tough and rigid. But I then found that it was so powerful and extensible that I was so much more efficient. When I needed to add a few new features to the old CI sites, it was faster to rewrite the entire sites on Yii than to code up the extra features in CI.
I can't recommend a framework in the middle, but I can recommend sticking with Yii. When you say Yii gets in the way, can you give an example? Looking at DB stuff (in ascending order of dependence on Yii):
you can code using PHP's core MySQL functions.
$result = mysql_query($sql);
you can use Yii's DB abstraction layer.
Yii::app()->db->createCommand($sql)->queryAll();
You can use Yii's ActiveRecord:
Takeaway::model()->findAll();
you could try kohana (especially coming from ci)
You should check out the CI community, some of those extensions maybe have been written by someone else (I remember seeing Authentication and Components/Widgets somewhere)
Symfony is worth checking out. I personally don't like it much because they chose Prototype over jQuery for their ajax features, which is really annoying to use when you're used to jQuery.
Lithium might be good to check out too. However, it is php 5.3 only and you need to be really careful that this version of PHP is going to be supported on the server the site will be deployed on.
See this list for good comparisson:
http://en.wikipedia.org/wiki/Comparison_of_web_application_frameworks#PHP_2
From a personal point of view, I would go with symfony because of it's
rich features and
great integration with many other already bundeled components (Doctrine, Swift Mailer,..),
good (but at first complex) code generation that produces realy useable code to get you startet quickly,
powerfull use of templating (that will be the point you mention under "layouts)
many different, powerfull plug-ins, including Authentication & Access Control (it also has a plug-in to get jQuery support)
one of the best tutorials that I've seen with a framework
Downside is a
more complex structure,
IMO wired file structure,
a rather messy API documentaion compared to the tutorial
CodeIgniter is a nice framework if you don't want to create big apps but it lacks a great database integretaion and you already mentioned code generation.
im very good in Raw PHP, where the project at hand became too much to handle i decided to move to zend, with too too much complexity i finally moved to YII which really reduced the cost and overhead time for project development and most importantly for me is the simple integration of jquery, widget and advanced-OOP.
You could have a look at Qcodo / Qcubed.
They are both easy to pick up and offer code generation / ORM
Easy way to create forms in an mvc kind of way.
For what its worth, if you're looking for a PHP Framework that is like ASP.NET MVC then I think Prado is the closest thing you will find.

How do I make non-framework code to framework code? (PHP)

I just started using CakePHP and it's very different from just normal procedural or basic OOP PHP.
I am still learning PHP and still read "beginning PHP/mysql" books that teaches you basic PHP. Also lots of sites online provide code that isn't for a framework.
Is the only way to make non-framework code to say a framework, say cakePHP, by learning cakePHP thoroughly than rewriting the code yourself to fit the MVC model?
I think it would be beneficial to learn basic OOP PHP thoroughly before learning CakePHP. I admit Cake is a little restricting about naming conventions but you can customize this to your liking. I would try to rewrite a small PHP application in Cake to get familiar with it. Choosing a MVC framework does save a lot of development time if you take the time to learn on well. For Cakephp the book and API are two very valuable tools. I also suggest using Cakephp 1.3.
API
Book
CodeIgniter allows you to write things the way you want but really works best when you use it as a MVC platform. You would write all of the PHP code in the controller if you wanted and the application would still work, you could then decide to split out the code for the database into the model and then later decide to put all of the HTML into the view. That's if you would like to do it like that.
I would recommend doing tutorials and trying to use the MVC model as it has saved me a lot of time and is so much better than flat file coding.
CakePHP can be a little restricting as it requires you to follow particular naming conventions.
Hopefully this gives you a good start on a road to learning the ease and speed of MVC.

Categories