Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Show Posts

* | |

  Show Posts
Pages: [1]
1  PureMVC Manifold / Standard Version / Registering Commands on: October 21, 2009, 02:54:01
So I've gotten a bit further in my work in php pureMVC, and I've run into another - "Am I crazy to do this?" type question.

From what I've seen, the Facade seems to be the recommended place to register commands.  But in the stateless world of web apps, it doesn't make a lot of sense to register a whole lot of commands until you've done a bit of bootstrapping and have an idea of what is being requested of the application (and therefore which commands to register and execute).

So where I got in my app building:
* register a macro command to handle startup (bootstrapping)
* start the app by sending a notification which is handled by that command
* In that command load db configuration information from an .ini file
* set those defaults in my db_connection class which will be available to any proxies that care to make use of it

At this point I'm ready to sort out what is being requested - to do this I want to make use of a router/dispatcher that will take action based on the URL.

I figured the best way to do that would be to execute a 'router' sub command that parses the URL and in turn registers an appropriate command to handle what is being requested.  Then the only thing left to do would be to send notifications to those newly registered commands (passing along arguments from the URL).

So, does that sound crazy?  i.e. having commands registering commands.  I can already foresee situations when newly registered commands would still in turn register yet more commands.

Crazy or not, I can't think of any other way to lazy load what I need.

andre
2  PureMVC Manifold / Standard Version / Shared Database Connections on: October 13, 2009, 08:56:34
Hello all.

This must be a common question and I did see some discussion about it as it relates to an AIR app, but I got a bit lost:

Basically what I would like to do is share a database connection between proxies.

First thought: Just make the connection in each proxy. Conclusion: That's just silly.

Second thought: Create a multiton that returns a database connection (actually a PDO object).  Then add DbConnection::getInstance('instancename') to the proxy constructor.  That way the connections are shared and I have the flexibility to have more than one database connection type and I can share as many of them as I like/need between any number of proxies.
Conclusion: I've built in a dependency.

Third thought: Use the same multiton (for the same reasons), but inject the dependency.  Conclusion:  Ummm, I'm not sure, because I would have to inject the database connection object from the point where I create the proxy (i.e. a command).  Is that the place for me to be getting that connection instance?  I really don't see where else I could do it.

Or am I barking up the wrong tree altogether?

Thoughts?

andre
3  PureMVC Manifold / Standard Version / Re: New to pureMVC on: October 08, 2009, 02:40:47
1) re: licensing and work
This sounds like it could very much be scripted.  If you're willing to put the word out that there may be a licensing change in the works and see if you can get buy-in from contribs, I could see about scripting a solution.
-check out all the repos.
-Iterate through each file
-Str replace
-commit
Am I crazy to think this could be done in a day?

2) I'll contact you.  I'm just groking pureMVC will have to grok how multicore works before I could be a great deal of help.  Though I've noticed that in general a class autoloader would be a nice addition to even to singlecore. Leveraging php 5.3 namespaces could be another nice feature in pureMVC.

4,5) Cool.  I'll be in touch as needed.

4  PureMVC Manifold / Standard Version / New to pureMVC on: October 07, 2009, 10:37:51
Hello all,

I dabbled with pureMVC a few months ago in the flash/flex world, and recently I've been evaluating some php MVC frameworks and remembered that pureMVC was ported to all sorts of platforms - so I came back.

I guess I'll start with a few questions:

1) Licensing: I saw this FAQ item http://puremvc.org/content/view/83/188/ but it hasn't been updated in a year.  I was wondering if indeed the main pureMVC code will go MIT and whether the php port will become licensed under MIT.  Having played in open source circles for the past 5 years I can say with pretty good confidence that the MIT license would address everything that Cliff mentions in the answer to the FAQ.
If its a question of "work", I'll be glad to patch the files to include the new license :)  There is also the option of dual licensing the code if the powers that be want to give people the option to use the CC license instead of the MIT license.  Just a thought.
Of course I can live with CC, its just a bit odd (as in different).

2) This is a more technical question regarding porting multicore:
In the case of other languages I can see the use cases for running multicore right away.  I was wondering if anyone has imagined a use case in the php world.  I'm currently in my architecting phase for my app and still in the 'wrap my head around' pureMVC for php phase.  I have yet to see a need for multicore, but maybe its because I haven't coded enough to have run into a wall that singlecore puts in my path.

3) This is a general question on architecting php apps with pureMVC and libraries:
I saw this thread http://forums.puremvc.org/index.php?topic=1234.0 where zermattchris (http://forums.puremvc.org/index.php?action=profile;u=1419) asks about how to do routing.
(I may have a more specific question about this later)  Obviously this is a rather common task in bigger php apps. i.e. routing URLs to execute the appropriate code within the php application.  Other common tasks are session handling w/ authentication etc.
So it would seem to me the best way to handle some of these common tasks is to build a few 'libraries' or 'modules' of code.  I would guess that I would write up some command classes proxies and mediators and bundle them together in a folder somewhere in my app and include them as needed in the main project.  My question I guess is has anyone done something a bit more complex in php pureMVC where they've built reusable bundles like this?  Are there any gotchas?  Have these bits of work been contributed somewhere?
I guess I'm looking for some best practice advice for the php world.  Cliff's best practices docs on AS3 are great but a) folder structure best practice advice isn't explicit (assumes AS3 world and its best practices) b) a bit off topic, but the code exampes are in AS3 :)

4) As I was typing the last question, I realized part of what I was asking was:
How big is the php pureMVC 'community'?  Or has the port simply been an academic exercise that's just kind of sitting here waiting for a community to form?  As mentioned before, I haven't run across any 'contributed modules' (e.g. a routing library) on the web.

5) Kind of leads me to my next question:  As I tinker I may likely end up writing chunks of code that may be reusable for others.  Besides posting on my own blog or having it in my own repository is there someplace else I could/should be posting things?

Anyway - besides all the questions, I just wanted to say that I like what I've seen so far.  I managed to write up my first 'hello world' app in no time (granted it wasn't pulling hello world from 3 different data sources and it didn't spit it out into a themeable templating engine), but its a start.  I'm going to take it a bit farther today.

andre
Pages: [1]