You are not logged in.

#1 2012-03-18 17:13:49

Marklar
Member
Registered: 2010-06-19
Posts: 36

PHP - Model Viewer Controller (MVC)

After months of looking I finally got an entry level PHP job.

We are using a php object oriented framework but we're not using the MVC architecture so I feel that I may be spinning my wheels. I may be in an entry level position but I seem to be on the same level as most everyone else when it comes to PHP skills. I don't feel like I really have any mentors there (it's a very unorganized place, with no version control, qa, quality design or anything. it's quite stressful sometimes). So when it comes time for me to get a new job I feel the only useful experience I'll have gained from the place is OOP in PHP but most everyone seems to be demanding MVC skills.

I can't seem to find any good MVC tutorials on the net so I wonder if anyone here knows of any or of any books that cover it well.

Thanks

Offline

#2 2012-03-18 17:34:32

litemotiv
Forum Fellow
Registered: 2008-08-01
Posts: 5,026

Re: PHP - Model Viewer Controller (MVC)

Which framework do you use? A good place to start could be one of the popular (H)MVC frameworks online documentation. For instance the CakePHP, CodeIgniter, Kohana and FuelPHP websites all have tutorials and examples for using MVC schemes.


ᶘ ᵒᴥᵒᶅ

Offline

#3 2012-03-18 18:03:17

Marklar
Member
Registered: 2010-06-19
Posts: 36

Re: PHP - Model Viewer Controller (MVC)

Thanks. I've never used a framework for any of my own projects but I've been looking into Yii. I'd rather not give the name of the framework we are using at work because it's very little known and I think we are one of their only customers. They may figure out who I am by me talking about it here big_smile (im paranoid) I'll just say that it's object oriented, and you only write PHP code. The framework generates all of your HTML and javascript. It reminds me of writing C# apps in Windows.

Everything that's normally an HTML element is a control. A div is a Panel control and a form button is a Button control. Text is a label control, etc. Each control has properties like left, top, width and height plus a whole lot more.

It's a very interesting framework but the rest of the world doesn't develop websites that way (as far as I know). I do find it to be an interesting, but limiting, approach. But it's a real pain when trying to implement third party javascript libraries.

Last edited by Marklar (2012-03-18 18:16:46)

Offline

#4 2012-03-18 18:52:47

Tzbob
Member
From: Belgium
Registered: 2011-04-12
Posts: 61

Re: PHP - Model Viewer Controller (MVC)

Marklar wrote:

Thanks. I've never used a framework for any of my own projects but I've been looking into Yii. I'd rather not give the name of the framework we are using at work because it's very little known and I think we are one of their only customers. They may figure out who I am by me talking about it here big_smile (im paranoid) I'll just say that it's object oriented, and you only write PHP code. The framework generates all of your HTML and javascript. It reminds me of writing C# apps in Windows.

Everything that's normally an HTML element is a control. A div is a Panel control and a form button is a Button control. Text is a label control, etc. Each control has properties like left, top, width and height plus a whole lot more.

It's a very interesting framework but the rest of the world doesn't develop websites that way (as far as I know). I do find it to be an interesting, but limiting, approach. But it's a real pain when trying to implement third party javascript libraries.

Your best bet is to start using different frameworks from different languages and learn the general concept of web frameworks by *doing* not by *studying*.

As for the Html/JS generating frameworks not all of them are bad, Vaadin is amazing (Java/Scala), and GWT(Java) is decent. There are similar Python projects too.

You'll also find a job easier knowing some other frameworks than PHP.

Vaadin, GWT, Ruby on Rails, Django are all frameworks I enjoy using.

Offline

#5 2012-03-19 08:25:41

pshevtsov
Member
From: Novosibirsk, Russia
Registered: 2011-01-20
Posts: 52

Re: PHP - Model Viewer Controller (MVC)

Marklar wrote:

The framework generates all of your HTML and javascript. It reminds me of writing C# apps in Windows.

Everything that's normally an HTML element is a control. A div is a Panel control and a form button is a Button control. Text is a label control, etc. Each control has properties like left, top, width and height plus a whole lot more.

It's a very interesting framework but the rest of the world doesn't develop websites that way (as far as I know). I do find it to be an interesting, but limiting, approach. But it's a real pain when trying to implement third party javascript libraries.

Is seems to me that you're talking about Prado Framework. Am I right?

Offline

#6 2012-03-20 00:41:39

Marklar
Member
Registered: 2010-06-19
Posts: 36

Re: PHP - Model Viewer Controller (MVC)

pshevtsov wrote:
Marklar wrote:

The framework generates all of your HTML and javascript. It reminds me of writing C# apps in Windows.

Everything that's normally an HTML element is a control. A div is a Panel control and a form button is a Button control. Text is a label control, etc. Each control has properties like left, top, width and height plus a whole lot more.

It's a very interesting framework but the rest of the world doesn't develop websites that way (as far as I know). I do find it to be an interesting, but limiting, approach. But it's a real pain when trying to implement third party javascript libraries.

Is seems to me that you're talking about Prado Framework. Am I right?

No but it's very similar. I've never seen Prado before but I can tell it's much better documented than what we use. The main thing I don't like about these frameworks is that it relies heavily on ServerSide events which makes the app feel bloated and less responsive when it's always polling server side to do something that could easily be done clientside (javascript)

Offline

#7 2012-03-20 04:26:27

pshevtsov
Member
From: Novosibirsk, Russia
Registered: 2011-01-20
Posts: 52

Re: PHP - Model Viewer Controller (MVC)

We moved from Prado framework to Yii on one project. Both these frameworks are created by the one guy, so it wasn't hard to switch. I agree with litemotiv about frameworks' documentation and tutorials. As for me, I "learned" MVC by reading CakePHP, Prado and Yii docs and tutorials. Also, to understand MVC deeply, I suggest to look at so-called micro-frameworks (like Slim for PHP or Flask for Python), ORM (like Idiorm & Paris for PHP or SQLAlchemy for Python), and Template engines (like Twig for PHP or Jinja2 for Python).

Good luck!

Offline

#8 2012-03-25 00:33:57

jmm
Member
Registered: 2012-03-25
Posts: 1

Re: PHP - Model Viewer Controller (MVC)

Here is another vote for Yii. I have also tried Kohana and found that to be pretty easy to use and work with and really liked it. Don't be afraid to dig into the framework's source code to see how various aspects work. I find that looking at the source code is just as beneficial as reading the documentation. It also gives you a deeper understanding of both the framework and how to solve problems in PHP in general.

Perhaps you could try and introduce some of the things that are missing in your workplace like using better frameworks, version control, quality assurance, etc. Good luck!

Offline

#9 2012-04-01 17:00:33

Marklar
Member
Registered: 2010-06-19
Posts: 36

Re: PHP - Model Viewer Controller (MVC)

jmm wrote:

Here is another vote for Yii. I have also tried Kohana and found that to be pretty easy to use and work with and really liked it. Don't be afraid to dig into the framework's source code to see how various aspects work. I find that looking at the source code is just as beneficial as reading the documentation. It also gives you a deeper understanding of both the framework and how to solve problems in PHP in general.

Perhaps you could try and introduce some of the things that are missing in your workplace like using better frameworks, version control, quality assurance, etc. Good luck!

I suggested GIT when I first started because that's what I'm used to using from my C programming job I had before. But, the boss is very impatient. He was okay with me setting up GIT but he wants everything working in like 10 minutes. So I've toned down my support on running GIT (though I have been using it for myself to track my own changes). We're all running Windows there so I'm thinking maybe suggesting SVN or Bazaar

As for switching frameworks that won't happen. He doesn't like HTML. Our framework requires no markup of any kind. It's 100% PHP.

Here's an example of a simple site with a button that you click and then shows a javascript alert box.

<?php

class Index extends WebSite
{
    function Index()
    {
         parent::WebSite('My test Site'); // the title
         $this->Display();
    }
    function Display()
    {
        $this->Elements->Add($button = new Button('Click Me'));
        $button->Click = new ServerAction($this, 'SayHello');
    }
    function SayHello()
    {
        Library::Alert('Hello World!');
    }
}

?>

Offline

#10 2012-04-01 21:06:54

litemotiv
Forum Fellow
Registered: 2008-08-01
Posts: 5,026

Re: PHP - Model Viewer Controller (MVC)

Marklar wrote:

Here's an example of a simple site with a button that you click and then shows a javascript alert box.

I really don't like stuff like that, optimizing the frontend is just as important as the backend, in terms of performance, user experience and maintainability. Code like the above makes it virtually impossible to create rich and dynamic interfaces that are optimized for the end user instead of only making the developer's life "easier".


ᶘ ᵒᴥᵒᶅ

Offline

#11 2012-04-02 17:29:41

holland01
Member
Registered: 2011-12-22
Posts: 50

Re: PHP - Model Viewer Controller (MVC)

Have you tried CodeIgniter? It's actually pretty good; I'd say the only downside is that it has more of a template programming like feel rather than a dynamic programming feel, mainly because all of the "fun" stuff has already been done for you. Still, if you're looking for something to get the job done in a quick, simple, and easy fashion, I'd recommend taking a look at CodeIgniter as well.

Offline

#12 2012-04-04 08:42:35

ViruSzZ
Member
From: The Streets
Registered: 2010-10-14
Posts: 202
Website

Re: PHP - Model Viewer Controller (MVC)

holland01 wrote:

Have you tried CodeIgniter? It's actually pretty good; I'd say the only downside is that it has more of a template programming like feel rather than a dynamic programming feel, mainly because all of the "fun" stuff has already been done for you. Still, if you're looking for something to get the job done in a quick, simple, and easy fashion, I'd recommend taking a look at CodeIgniter as well.


+1 on CI. CI is an amazing micro framework based on MVC and if you need to get something done really quickly, I would go with it. I've been using it for creating web applications on a regular basis and it have never failed.

It is true that a big part of the backend job is already done for you, but hey, you can always dive in and code the things your way. CI is also very well documented and can be learned pretty fast.


Their Momma Made Em, Their Momma Gave em & now she can`t even SAVE`em | My WebLog

Offline

#13 2012-04-07 18:08:53

holland01
Member
Registered: 2011-12-22
Posts: 50

Re: PHP - Model Viewer Controller (MVC)

I'm actually rolling more of a CMS right now myself, which, while not quite MVC, has an MVC-like inspiration smile. It's nothing new, though: tons of people have done it before.

Offline

#14 2012-06-24 17:08:28

Marklar
Member
Registered: 2010-06-19
Posts: 36

Re: PHP - Model Viewer Controller (MVC)

ViruSzZ wrote:
holland01 wrote:

Have you tried CodeIgniter? It's actually pretty good; I'd say the only downside is that it has more of a template programming like feel rather than a dynamic programming feel, mainly because all of the "fun" stuff has already been done for you. Still, if you're looking for something to get the job done in a quick, simple, and easy fashion, I'd recommend taking a look at CodeIgniter as well.


+1 on CI. CI is an amazing micro framework based on MVC and if you need to get something done really quickly, I would go with it. I've been using it for creating web applications on a regular basis and it have never failed.

It is true that a big part of the backend job is already done for you, but hey, you can always dive in and code the things your way. CI is also very well documented and can be learned pretty fast.

I've had some free time and decided to learn some CI. Boy that was easy. Like I said before I tend to make things too complicated. I read the first few chapters of the user guide and then i was off making my own app

I've got some code that ive written for CI posted on a blog i just started
rucoding.com

Offline

Board footer

Powered by FluxBB