Studs Has Landed!

July 23, 2004

Well folks, it's finally here! After almost a year of ups and downs scratching an itch for a better object-oriented framework for PHP, I am pleased to announce the initial release (0.9) of the Studs MVC Framework+. I use the '+' to designate the fact that the project has become much more than just a port of Apache's Jakarta Struts to PHP. In fact, I ended up porting a good portion of the Java Servlet stack, including a JSP parser and a long-term application context (within reason). Think about that. JSP custom tag libraries in PHP, including the JSTL expression language! Add to that logging, runtime exception handling, an XML digester and an enhanded object environment and things start to get very interesting.

Why Studs? People are going to ask, so I am going to explain. Experience. I wanted to learn deep down how Java Servlets and Struts worked and there is no better way to accomplish this than by reviewing the code. More importantly, I learned about the design concepts behind this source code, which in the end is much more valuable. Practice. After a few false starts, I recognized the only way I was going to make this happen was by starting small. I followed one of the principles of eXtreme Programming and did the simplest thing that could possibly work. I continually refactored the design until I reached the point of compatibility with the design of Struts.

While there is still work to be done, I encourage anyone interested in object-oriented design, J2EE or web frameworks to give Studs a try. Start with studs basic, which is a simple "Hello World" application that can be run on any webserver with PHP 4 installed. Give it a try today!

Posted at 02:04 AM in Programming | Permalink Icon Permalink

7 Comments from the Peanut Gallery

1 | Posted by Jason on July 23, 2004 at 05:27 PM EST

Got it set up without too many labor pains. A few tips for others:

  1. Set up the include path in the index.php page to fetch the studs stuff: ini_set('include_path', './WEB-INF/lib');
  2. Uncomment the @ sign on line 53 of WEB-INF/lib/horizon/io/FileWriter.php and you'll quickly find out that WEB-INF/work needs to be chmodded to 777.
Nice work Dan! One of my first observations were the pretty urls that were accomplished without mod_rewrite. Time to implement that in mine ;-)

I'll be keeping an eye out for a full-blown app written using the framework...

2 | Posted by Jason on July 23, 2004 at 05:42 PM EST

Oh, one other note, you have to set allow_call_time_pass_reference = On in your php.ini. Dan what's up with using old programming methods?! ;)

3 | Posted by Dan Allen on July 24, 2004 at 03:28 AM EST

Jason, thanks for pointing out the issue with allow_call_time_pass_reference. I was never in fact using it for my own methods, but rather when I called native PHP methods.

However, the bad news is that it still has to remain enabled because of a bug in the serialize() function of PHP, which destroys circular references unless passing the object by reference at runtime.

PHP 4 deprecated a feature called call-time pass-by-reference. Unfortunately, the developers of PHP deprecated the feature without making appropriate alternatives available, so the net result is that, under PHP 4, some things are literally impossible to do without using call-time pass-by-reference, even though it's deprecated.

In our case, the problem is with the seralize() function. I have added it to htaccess.

4 | Posted by Dan Allen on July 26, 2004 at 03:01 AM EST

I have corrected (in CVS) the absence of a proper IOException being thrown when the "work" directory is not writable. Now it should be quite clear what the problem is and how to solve it. I will still add proper documentation in the quickstart guide.

5 | Posted by harald on July 31, 2004 at 11:29 AM EST

stud is a very impressive project. i'm curently seeking solutions for a fast growing web-community - the current used third-party software isn't much longer capably of handling the traffic. i've had a look at java/struts a while ago which in my opinion totally rocks. but as i'm more a php developer a php based solution would be much easier and faster for me to develop.

so my question: would you consider studs stable enough for developing a bigger project?

6 | Posted by Dan Allen on August 03, 2004 at 07:22 AM EST

I will admit that this is the first time this question has been posed. However, I have thought about the answer quite a bit recently, as I neared the first release.

PHP has proven itself to be extremely performant under large loads and very efficient with memory. Studs builds on these strengths by caching the configuration in a serialized file, allowing PHP to pick up right where it left off from the previous request. So yes, I do believe it is stable enough...

However, there are two main features still missing, which are still under active development. Studs does not add to the ServletContext in many cases once it is created and also does not have a graceful method of file locking on that file. This feature is not complicated, but I have put it off until now. Additionally, I have not yet implemented the role-based security from the Servlet API. I have hooks for it, but it just hasn't been completed.

Both of these features do not affect the development of a Studs-based project, but will be important when it is deployed. So I say go for it. Why? Because even if Studs turns out not to suit your needs, porting to Struts is trivial.

7 | Posted by mwdwe on May 15, 2006 at 11:54 PM EST

whats wrong with this?

sample = golflog

----.htaccess---------------------------------------

RewriteEngine On

RewriteBase /golflog/

RewriteCond %{REQUEST_URI} !(index.php) [NC]

RewriteCond %{REQUEST_URI} .*\.(action|psp)$ [NC]

RewriteRule ^(.*)$ /golflog/index.php/$1 [L]

[FilesMatch "^.*\.(action|psp)"]

allow from all

[/FilesMatch]

-------WEB-INF/web.xml---------

useRewrite true

http://localhost/golflog/index.psp -> "BLANK page"

NB: apache-2.0.54 for windows with mod_rewrite enable, PHP 5.0.4