Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Welcome, Guest. Please login or register.
May 25, 2017, 09:18:57 AM
Home Help Search Login Register
News: ATTENTION: Spambots must die! Humans must visit http://contact.futurescale.com to request forum access.
Pages: [1]
Print
Author Topic: Any plans for more demos?  (Read 9631 times)
andyn
Newbie
*
Posts: 1


View Profile
« on: May 18, 2009, 03:40:10 AM »

Even though I am a reasonable PHP coder and have an understanding of PureMVC in Flex, I'm finding it difficult to get to grips with PureMVC/PHP and would find it very helpful to see more demos for PHP.  In  particular a version of the Employee Admin Flex demo would help me to understand how a 'real world' web application might fit together.

Does Hasan have any plans to post more demos?   

Thanks
Andy
Logged
zermattchris
Full Member
***
Posts: 35


View Profile
« Reply #1 on: May 18, 2009, 05:39:29 AM »

We're also looking at basing a rather large project on PureMVC for PHP -- more demos would be fantastic from our end as well  Smiley

-Chris
Logged
zermattchris
Full Member
***
Posts: 35


View Profile
« Reply #2 on: May 18, 2009, 07:39:23 AM »

We're also looking at basing a rather large project on PureMVC for PHP -- more demos would be fantastic from our end as well  Smiley

-Chris

Actually, I've just spent the last couple of hours setting up a local dev virtual host (Apache) and digging through the php example code with Aptana (using the Andretti beta -- its a lot better than the current shipping version!) and XDebug (bitch to get that working correctly, but *what* a god-send to have it!).

Not only have I found the example to be *very* clean & clear, I've found it to be a lot easier to follow than the AS3 version I've been digging around in over the last months (that might be because I'm more comfortable with PHP than AS3, but also might be as one doesn't have to dig through all of the Flex bits to get to the core of the idea).

I'm very pleased to have taken a proper look at this, as we were considering using the Zend framework, but I must admit that Zend seems to be not only a bit of a moving target, but also the fact that there's so much of it (that's good & bad) that it makes starting a project with it for the first time rather daunting. At the moment, after looking at the PHP port of PureMVC, the idea of using it as the project's base MVC setup and then possibly using some of the Zend modules on their own, sounds very appealing -- the best of both worlds!

 Cool
-Chris

Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2866



View Profile WWW
« Reply #3 on: May 18, 2009, 10:52:17 AM »

That's great feedback Chris. If you should happen to come up with any Hello World type code as you start out, let us know. There's a definite need for more demos here!

-=Cliff> 
Logged
zermattchris
Full Member
***
Posts: 35


View Profile
« Reply #4 on: May 21, 2009, 12:54:34 AM »

Hi Cliff,

I'd be happy to share anything of appropriate sharing quality that might come out of my current experimenting.  Smiley

One thing I'm looking at from the Zend framework, is the way they use a FrontController to handle routing. Basically, they only have a single index.php page in the public part of the site and all requests are routed through it to the Zend Frameworks, which then figures out which class(es) need to be called and returns the correct View (with re-writing).

I'm not exactly sure how PureMVC would handle such a set-up? Am I be better off trying to mimic the Zend way, or should I be creating matching public directories and index.htm files, that match the incoming URLs and then pass the work off to PureMVC?

The advantages I see of trying the Zend way are:
  • Single point of public entry into the system -- keeps things cleaner
  • Single point of public entry into the system -- if done correctly would most likely be more secure

The advantages of having a 'routing' index.htm file in each of the appropriate public visible folder would be:
  • Might be easier to glean the site's structure from the public directory tree
  • Might also keep the back-end code a bit simpler
  • Would allow the [simple] use of .htaccess in various areas of the site, to say force SSL in a basket area
  • No need to muck with rewriting the URL

To be honest, I'm not sure which Route (no pun intended) I should be looking to move forward with here. Cliff (or others) if you have any suggestions, I'm all ears  Cool

Regards,
-Chris






Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2866



View Profile WWW
« Reply #5 on: May 22, 2009, 04:22:42 PM »

The Facade is the single entry point into the PureMVC system.

A single page could be set up that causes your facade to be created and in your StartupCommand, you could look at the URL and figure out what action the person is trying to take, and then fire off the command to complete that action, which might mean registering specific proxies, commands and mediators to read data, process it, template it and ship it back out to the user.

-=Cliff>
Logged
zermattchris
Full Member
***
Posts: 35


View Profile
« Reply #6 on: May 23, 2009, 01:31:56 AM »

Thanks Cliff,

That's exactly what I'm going to try and do. I'm using the Rewrite rules, lifted from the Zend .htaccess file, to send any request that doesn't map to a found public resource, to the index.php page (which makes it a catch-all), which (via a non-public bootstrap file) kicks off the Facade. Here's the .htaccess code if anyone's interested:

Code:
# This is the Zend rewrite that sends all requests to the index.php page.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

In the boostrap I'm setting up my app's environment constants as well as calling facade-startup()

My Startup Command is registering a *RequestProxy*.
The index.php public entry page is then passing the requested URL into the RequestProxy:
Code:
$facade = ApplicationFacade::getInstance();
$facade->retrieveProxy( "RequestProxy" )->setRequest( $_SERVER['PHP_SELF'] );

Which parses the URL and sends off a *ROUTE* Notification to the rest of the system.


I'm still at the very beginning of my grasp of PureMVC, and I wouldn't be surprised to find a cleaner way of what I'm' doing above, but the basic concept is slick! I'm also planning on being able to handle multiple languages in the URL. The Router concept above makes it easy to do translation lookups on the URL string coming in. Our project is based in the midst of Europe (Zermatt, Switzerland to be exact) and we're looking to support multiple languages in a solid SEO way.

If I can come up with a semi-clean way of doing this routing, I'll drop you a line and if you're interested you can critique it, with an eye towards making it a community add-on.

Thanks much for the really cool stuff Cliff (and friends).

Regards,
-Chris


Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2866



View Profile WWW
« Reply #7 on: May 26, 2009, 07:41:13 AM »

Index.php should probably not 'reach into' the system beyond the Facade.

A better idea would be to model your startup after the ordinary way of doing things in other languages. Put a startup method on the facade, and pass the request into that method. Then in the startup command, register the RequestProxy and any other actors you need.

Then as the last step of StartupCommand, when everything else that needs to be registered is in place and interested, invoke a routeRequest method on the RequestProxy and let it do its thing. This keeps the page code from needing to do anything other than startup the PureMVC apparatus, passing the request.

Code:
$facade = ApplicationFacade::getInstance();
$facade->startup( $_SERVER['PHP_SELF'] );

-=Cliff>
Logged
zermattchris
Full Member
***
Posts: 35


View Profile
« Reply #8 on: May 29, 2009, 11:31:08 AM »

Thanks for the pointer Cliff -- I'll def follow your suggestion  Wink

Cheers,
-Chris

Logged
hasan
Moderator
Newbie
*****
Posts: 8



View Profile WWW
« Reply #9 on: July 11, 2009, 03:12:31 PM »

Hey Chris,

Cliff is spot on. The most your index.php script should know of your PMVC is the Facade and the only action it should initiate is the Facade's startup() method. You're on the right track with .htaccess. You could even go further and create "clean urls" that you can parse and pipe into your PMVC application for some pretty slick processing (data retrieval, AMF integration, templating, etc).

I've been thinking about doing some quick posts on different ways to instantiate a PMVC application in PHP but have been brutally swamped @ work. Stay tuned though, because the PHP community here is definitely going to continue to grow...Wink

P E A C E

Hasan
Logged

P E A C E

Hasan
Pages: [1]
Print
Jump to: