What's the best way to learn mvc in PHP? [closed] - php

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm totally new to mvc,how to pick it up?

Go this way:
Read about MVC (Google it, see the wikipedia article)
Choose a Framework (I suggest CodeIgniter - Has a great user guide)
Then go through the user guide and try the things.
The video tutorials are also good, check nettuts.com for CI.

Go this way:
Know what is MVC
Why it is useful
How does it work
Where it should be used optimally
How do frameworks use it (if possible to know)
Learn how frameworks implement it (try using a framework)
Learn a framework so that you can become habituated to using MVC
I know I might sound foolish, but this way can be of great help to newcomers.

Maintain some project written in spaghetti code (CSS + JS + HTML + PHP + SQL, all in one single file), then think how you would separate all these and you'll discover MVC.
Kidding aside. Read about it what you can, try some framework but don't avoid maintenance projects. It is in these projects that you'll see the benefits of MVC or at least those of separation of concerns.
See also this related question.

You can read all about MVC with a simple google search. However, you won't fully understand the beauty of it until you pick a framework and dive in. I hear great things of CodeIgniter. It was my first framework when getting into MVC.
In the end I chose CakePHP. Why? CodeIgniter, while very simple to get started with, gave me too much freedom for a beginner to MVC. I wanted strict rules and conventions to show me how its supposed to be done rather than what I think MVC should be. Maybe later on down the road I'll come back to CI. Either way you choose, my suggestion is to take a small project you coded, and code it in any of the PHP frameworks out there.
CakePHP's and CodeIgniter's communities are among the most helpful. Join a google group for Cake/CI. Read about what people are trying to do. See what problems people are having and good luck!

First research the MVC pattern and look for tutorials that explain how to implement it. Next, get an MVC framework for PHP and use that since there's no sense trying to reinvent the wheel and roll your own.

Related

Learning process of PHP (Framework Symfony, OOP) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am starting a new challenge. I am on my way to learn PHP since (I already have good knowledge in HTML CSS), i would like to have you advise in a good procedure of learning this.
To be specific my final goal is to be a very developer in PHP by the end of 2015 and able to work on project on my own and/or with team as freelancer.
I would like to hear from you guys a step by step learning programs which will conduct me to have confirmed knowledge in PHP OOP and Framework Symphony2. As i don't want to skip the stages i'd like your advise :
I have basic understanding of (loop, if/else, function).
I am looking some course (updated) and exercise to push up my level slowly but efficiency. A list of step would be a great start.
I'd suggest that you ensure that have a solid understanding of generic programming principles before you focus on a specific language. Knowing markup languages like HTML is relatively easy in comparison. When you get to programming, there's a lot more things to consider.
There's plenty of available free resources that should be able to help you.
http://www.tutorialspoint.com/computer_programming/
welcome to SO. There are lots of resources out there, some easier than others for a beginner. I would start on something like code academy and augment that with resources like php.net.
Then when youve covered those tutorials (I would do all the markup stuff like HTML as well) think of a personal project and build it. Its all very well reading manuals and doing tutorials, but you need a real live project to force you into finding solutions for real debugging issues. That cant really be taught.
Its worth noting that PHP isnt the only server side language out there, so keep an open mind and be ready to investigate other avenues as you find them.
Bear in mind to be able to hold your own in the industry is very different from being able to handle your personal projects ok. There are a lot more variables (no pun intended) in industry and the skillset you need to have is often wider.
Good luck with it.

Getting started with PHP / MVC [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
i have been using PHP for quite a sometime now, having understood the concept of OOPS, PDO, etc. i have been slowly moving forward to more advanced PHP. my strategy is always to learn more and more advance programming in every project. for my current project i would like to implement MVC, as i have been implementing my own directory or application structure before, this time i want to use MVC for my application. i did went through a MVC boilerplate tutorial on Nettuts. however that was just the basic i am searching for more and more resources for me to help get started with MVC for my projects. i am sure you guys might have passed from the same path i would like to know the links and suggestion about some of the great MVC tutorial for PHP available in the internet.
EDIT :
I have used frameworks like cakephp before i would request not to suggest using of any framework.
thank you
I would suggest you look at the MVC Design Pattern so that you understand it before you start using it.
Ideally, you should already have made some projects where you suffered a little bit because you wanted to change stuff when your project was at least halfway done.(This is one of the main motivators behind a lot of so-called advanced programming techniques. Ease of modification, flexibility and so on).
This is where stuff like what you mentioned (OO,MVC, and I would add TDD, Design Patterns) all come in).
What I do for myself and suggest others do is the following. Look into whatever you want, be it TDD, MVC or any other advanced technique. But wait until you need them.
In my personal opinion, one can much better appreciate the value of OO and MVC when one has gone through a naïve project and suffered from lack of functionality these techniques provide...
The golden rule is.. only start using a new technique when you've understood it and seen what benefits it can bring.
I say that because what I see in real life is that many people use stuff like OO, MVC and even Design Patterns without understanding the why's behind. I don't think that helps at all.
Good luck.
I strongly suggest you to take a look into Kohana framework. Its an HMVC framework, with cascading directory structure. If you are looking for books on advanced topics, "PHP Objects,
Patterns, and Practice" by Matt Zandstra describes very well about Design patterns in PHP. "Pro PHP Patterns, Frameworks, Testing and More" is also an excellent book which discuss about many advanced topics.
That tutorial discusses implementing one's own MVC framework. You can use an existing framework to implement applications using the MVC paradigm. I happen to prefer Zend for this. Here is a tutorial on using Zend MVC Framework:
http://framework.zend.com/manual/en/learning.quickstart.intro.html
You can try to start with Yii it easy to lear and use:
http://www.yiiframework.com/tour/
To get my mind around the concept, I found a lot of reading to be helpful as well as seeing it implemented from scratch. Several resources:
Book Resource: PHP In Action, pages on MVC. (Great because mentions the difference between application and web MVC).
Understanding the Concept: http://www.cs.cmu.edu/~pattis/15-1XX/15-200/lectures/modelinmvc/
Build Your Own Tutorial: http://net.tutsplus.com/tutorials/php/create-your-first-tiny-mvc-boilerplate-with-php/
Build Your Own Tutorial, more complex: http://www.nathandavison.com/posts/view/11/custom-php-mvc-tutorial-part-1-introduction

Benefits of using cakePHP? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I know PHP well. But i haven't tried cakePHP before and i was willing to learn cakePHP. So just want to know that is there any benefits of using cakePHP over PHP?
Thanks,
aby
cakePHP, like CodeIgniter, FuelPHP and Symfony (just to name a few) are frameworks. What this means is that they have tried to abstract some of the normal, every-day things you do in development in an effort to speed up development time and make you more profitable.
In today's world, there is no excuse for not using a framework. If you refuse to use a framework, you find yourself creating a lot of the things that a good framework provides anyway (i.e. data abstraction layers, session classes, form validation, etc). By using a framework, you not only gain time, but you gain stability as the different components of the framework should be designed to work well together and have been thoroughly tested by the community.
Whichever framework you choose is up to you and hopefully now you understand it's benefits.
CakePHP is an MVC framework that will allow you to setup your data model and connect it to a database to be easily manipulated in PHP. It also allows you separate your business logic from your display logic using a controller.
It also gives you a lot of useful functionality like authorization, sessions, form validation, pagination.. for free. You should check out the feature list.
If you didn't use CakePHP you would have to roll your own framework, which is a lot of extra hassle and work. There are of course other frameworks.
The answer is pretty simple, it comes down to your need's, do you need a framework?
You say that you know php well, i doubt you know it as well as you think as you would not ask a question of this nature, you would understand the concepts behind a framework.
You say:
So just want to know that is there any benefits of using cakePHP over PHP?
it's not a language sir, it's a framework that supplies the PHP foundations for an application, why would you not wan't to use such a thing, what you should be asking is:
What's the best framework to learn once you have mastered PHP Fundamentals.
But don't ask it here, there are plenty of posts that answer that question for you.
CakePHP is an MVC framework But to simply say you need to design the data models and relationship (creating necessary tables) before start the work , once you use bake command 70% of coding are given

Is there a thin framework in PHP I can use? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I'm looking for a thin web framework in PHP5 to start my project. I have come across some popular frameworks like Symhony, Zend, CodeIgniter... but they seem too complicated and their source code are too long to read. Is there a light framework out there I can use?
(I know some OOP, MVC in PHP)
Thanks for your help.
I would say Codeigniter is about as light as you are going to get, It's fairly convention-less and has proven to be the lightest in terms of overhead.
It is simple and well documented.
My choice of vote is for CODEIGNITER , because easy to use and build applications and rich documentation.
Thanks
MicroMVC for sure.
As advertised:
It offers Model, Library, Controller,
Function, and View management. Plus
other features like URI Routing,
hooks/plugins, file uploads, database
abstraction, captcha creation, and
more! If you are new the
Model/View/Controller world of OOP
All under 150kb!
I too agree with #jondavidjohn. I started with codeigniter and really impressesed with its simple well documented syntax. If you are starting framework for the first time, As for me CodeIgniter is the best choice. Give it a try http://codeigniter.com/user_guide/ ...
I find Cakephp Framework very addicted for me.................u could check it out
I think you're looking for Kohana 3 - http://kohanaframework.org/
The documentation sucks but it's very lightweight, there's a good community (even on SO), it's more simple than Symfony and more powerful than CodeIgniter (the first version of Kohana was based on CodeIgniter)
You can check PHP Frameworks site, where you can fully compare all kinds of PHP frameworks and help you choose the right php framework for your project. They offer PHP Frameworks comparison, top 10 frameworks, reviews, forum, etc.
Thanks for your help guys.
I love CI too. I also googled and found this one. It looks promising, let's see how it works out, will come back to CI if it doesn't work.
Personally, I found success with Kohana 2.3 (the later versions don't work as well IMHO) as it has a very simple MVC structure, it runs fairly quickly, and it is OO. It was based off of CodeIgniter.
However, I would pick a framework and stick with it, paying more attention to designing your application with a good understanding of MVC. Head First Design Patterns (http://www.amazon.com/First-Design-Patterns-Elisabeth-Freeman/dp/0596007124) helped me understand why MVC was useful and how to implement it. Good luck!

Lightweight MVC - no framework [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
Hi sorry if this is a naive question, but what did people do before mvc frameworks became so popular? All you hear of nowadays, and im talking php here, are mvc, Zend etc but what did developers do beforehand?
Are there some developers who use the mvc pattern but without a framework - if so how do they do this and is it really complicated to set up?
MVC is a design pattern. You can easily roll your own MVC "framework" (technically even without using object-oriented programming). The main goal is simply to have a separation between data storage, business logic, and presentation.
When I was first learning about MVC, I decided that trying to sift through the mountains of code of CakePHP or other frameworks was simply too complicated. I started writing my own "framework" using this tutorial (http://fuelyourcoding.com/php-frameworks-just-roll-your-own-part-1/). It's really not as much work as you think (you can go through that tutorial in a day and have a very nice mini-MVC), and you can expand it later into a full-fledged framework later on if you have the time and dedication.
As to the question of what developers did before frameworks, well, they just wrote everything themselves. Unfortunately this led to a lot of spaghetti code with HTML mixed with PHP blocks and SQL statements, but that's not really a fault with not having a framework, rather with not trying to implement any sort of separation of concerns.
Edit: Part 2 is probably the most important part because it shows you how to make a template. This isn't actually the exact tutorial, the one I used seems to have disappeared.

Categories