SitePoint Sponsor |
|
User Tag List
Results 26 to 50 of 175
Thread: PHP Retro Style MVC Framework?
-
Sep 24, 2008, 03:12 #26
- Join Date
- Feb 2008
- Location
- Atlit, Israel
- Posts
- 470
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Learn about the new Retro Framework
Code PHP the way it was meant to be coded!
-
Sep 24, 2008, 03:14 #27
- Join Date
- Feb 2008
- Location
- Atlit, Israel
- Posts
- 470
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
arkinstall - the dump function calls var_dump wrapped with PRE tags, so yes unfortunately it outputs them.
If it's a community project, though, I'm sure at some point someone would love to replace that.Learn about the new Retro Framework
Code PHP the way it was meant to be coded!
-
Sep 24, 2008, 03:27 #28
- Join Date
- May 2006
- Location
- Lancaster University, UK
- Posts
- 7,062
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
Waiting to be added to the project, but heres a suggestion for the returning a variable:
PHP Code:function _dump()
{
$args = func_get_args();
ob_start();
var_dump($args);
return sprintf('<pre>%s</pre>', ob_get_clean());
}
Jake Arkinstall
"Sometimes you don't need to reinvent the wheel;
Sometimes its enough to make that wheel more rounded"-Molona
-
Sep 24, 2008, 04:14 #29
- Join Date
- Feb 2008
- Location
- Atlit, Israel
- Posts
- 470
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Haha, obviously. I'll add it right now.
Learn about the new Retro Framework
Code PHP the way it was meant to be coded!
-
Sep 24, 2008, 05:00 #30
- Join Date
- Feb 2008
- Location
- Atlit, Israel
- Posts
- 470
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Working demo:
PHP Code:class Posts extends Controller
{
public function index($request)
{
$posts = find('posts');
// Add a relationship and get all the corresponding records
// The neat thing is that every record you get is not read-only
// you can set new values and save() it.
$posts = relate($posts, 'id', 'comments', 'post_id');
$data['posts'] = $posts;
render('posts.index', $data);
}
public function update($request)
{
// Find a single comment based on filters and update it
$c = single('comments', array('post_id' => 2));
$c->text = 'the only comment for this post';
$c->save();
}
public function add($request)
{
// Was the form sent?
if($request->isPostBack)
{
// Create a new comment
$post = record('comments');
$post->post_id = post('post_id');
$post->text = post('subject');
$post->save();
}
render('posts.add');
}
}
PHP Code:<? foreach($posts->loop() as $post): ?>
<h1><?=html($post->subject)?> at <?=dt2d($post->date, 'd/m/y')?></h1>
<? foreach($post['comments']->loop() as $comment): ?>
<p><?=html($comment->text)?></p>
<? endforeach; ?>
<? endforeach; ?>Learn about the new Retro Framework
Code PHP the way it was meant to be coded!
-
Sep 24, 2008, 06:15 #31
- Join Date
- May 2006
- Location
- Lancaster University, UK
- Posts
- 7,062
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
Cool.
Just wondering, you have a few functions which do similar things, such as:
PHP Code:function redirect($url)
{
if(!preg_match('~^http://~', $url))
{
$url = $GLOBALS['rooturi'].$url;
}
header('Location: '.$url);
}
/* reload the current page */
function reload()
{
$url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
header('Location: '.$url);
}
PHP Code:function redirect($url)
{
if(!preg_match('~^http://~', $url))
{
$url = $GLOBALS['rooturi'].$url;
}
header('Location: '.$url);
}
/* reload the current page */
function reload()
{
$url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
redirect($url);
}
Edit:
Update to redirect():
PHP Code:function redirect($url)
{
if(!preg_match('~^https?://~', $url))
{
$url = $GLOBALS['rooturi'].$url;
}
header('Location: '.$url);
exit;
}
Jake Arkinstall
"Sometimes you don't need to reinvent the wheel;
Sometimes its enough to make that wheel more rounded"-Molona
-
Sep 24, 2008, 06:38 #32
- Join Date
- Feb 2008
- Location
- Atlit, Israel
- Posts
- 470
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Yeah of course. I kind of rushed through a lot of it so it's good you let me know about these small errors in design.
I also made a video... Uploading now, will post when it's done.
BTW Jake, I PMed you.Learn about the new Retro Framework
Code PHP the way it was meant to be coded!
-
Sep 24, 2008, 06:48 #33
- Join Date
- Feb 2008
- Location
- Atlit, Israel
- Posts
- 470
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Ok the video is just a tad annoying because the noise removal feature had some funny side-effects and the frame rate is 4 but those are just minor things, it's a good video introduction to the framework.
It shows how to work with the database and views and you can see the results "live".
http://serialize.us/retro/retro.htmlLearn about the new Retro Framework
Code PHP the way it was meant to be coded!
-
Sep 24, 2008, 06:59 #34
- Join Date
- May 2006
- Location
- Lancaster University, UK
- Posts
- 7,062
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
Everything is so much simpler like that...
Round of applause!Jake Arkinstall
"Sometimes you don't need to reinvent the wheel;
Sometimes its enough to make that wheel more rounded"-Molona
-
Sep 24, 2008, 07:05 #35
- Join Date
- Feb 2008
- Location
- Atlit, Israel
- Posts
- 470
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thank you, thank you.
I actually came up with the idea last week.. And I don't need to tell you how it is when you think you have a good idea, right? Haha... Yeah, couldn't wait to get it to work.
Jake, if you didn't still get my PM - add me to MSN - yam.marc@hotmail.com so we can work on this more closely.
All the rest - again - feel free to add me if you want to help out!Learn about the new Retro Framework
Code PHP the way it was meant to be coded!
-
Sep 24, 2008, 07:09 #36
- Join Date
- May 2004
- Location
- Central USA
- Posts
- 806
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Nice video... is there a way to turn off the phoney keyboard typing sounds when you're recording?
Stackbox CMS - Full edit-on-page drag-and-drop CMS
Autoridge - Vehicle information & maintenance part numbers
Twitter | Blog | Online Javascript Compressor
-
Sep 24, 2008, 07:14 #37
- Join Date
- Feb 2008
- Location
- Atlit, Israel
- Posts
- 470
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Yeah, should I next time?
Learn about the new Retro Framework
Code PHP the way it was meant to be coded!
-
Sep 24, 2008, 07:36 #38
- Join Date
- May 2008
- Location
- Kalmar, Sweden
- Posts
- 45
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I'm definitely interesting in helping you out with development on this, just watched your video and it looks great from what I've seen. I'm going to test it more thoroughly wen i get home from work, keep up the good work man!
-
Sep 24, 2008, 09:19 #39
- Join Date
- Apr 2007
- Posts
- 1,205
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I just looked at the project upload times - 14 minutes between builds. You guys are really jamming! I'm going to have a look at the code and see if I have any ideas to contribute.
-
Sep 24, 2008, 09:22 #40
- Join Date
- Jul 2008
- Location
- Montréal, Canada
- Posts
- 22
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Sent you a mail Marc this sounds really interesting !
-
Sep 24, 2008, 09:30 #41
- Join Date
- May 2006
- Location
- Lancaster University, UK
- Posts
- 7,062
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
Latest build out.
Seriously, this thing is getting great!Jake Arkinstall
"Sometimes you don't need to reinvent the wheel;
Sometimes its enough to make that wheel more rounded"-Molona
-
Sep 24, 2008, 09:33 #42
- Join Date
- Feb 2008
- Location
- Atlit, Israel
- Posts
- 470
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
http://code.google.com/p/retrophpmvc/downloads/list
Jake also covered up the functions we had in build 2 so far, thanks much! Me and Jake are working well together and just think if we could all get into a group (Jake suggested a sitepoint one, perhaps?) or MSN convos and brain storm until we get exactly what we want!Learn about the new Retro Framework
Code PHP the way it was meant to be coded!
-
Sep 24, 2008, 09:34 #43
- Join Date
- Feb 2008
- Location
- Atlit, Israel
- Posts
- 470
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I also think the secret of this framework is:
We're not looking for ways to make it too clever or complex or flexible.
We're admitting that we are lazy programmers, and lazy development is what we want! And I think most people are like that, and just didn't want to be the first to put it out there.Learn about the new Retro Framework
Code PHP the way it was meant to be coded!
-
Sep 24, 2008, 09:37 #44
- Join Date
- Apr 2007
- Posts
- 1,205
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
Sep 24, 2008, 10:01 #45
- Join Date
- Jun 2004
- Location
- Copenhagen, Denmark
- Posts
- 6,157
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I noticed that there are a lot of places, where you're embedding strings in HTML, without escaping properly. Attributes needs to be escaped with htmlspecialchars.
Eg. instead of this:
PHP Code:return '<img src="'.$link.'" alt="'.$link.'" />';
PHP Code:return '<img src="'.htmlspecialchars($link).'" alt="'.htmlspecialchars($link).'" />';
-
Sep 24, 2008, 10:33 #46
- Join Date
- May 2004
- Location
- Central USA
- Posts
- 806
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Are you guys not working in SVN? I don't see anything in the trunk and the changelog is empty. You guys really need to get this thing in Google's SVN repository so that changes can be tracked and viewed online without downloading the package.
Stackbox CMS - Full edit-on-page drag-and-drop CMS
Autoridge - Vehicle information & maintenance part numbers
Twitter | Blog | Online Javascript Compressor
-
Sep 24, 2008, 11:13 #47
- Join Date
- May 2006
- Location
- Lancaster University, UK
- Posts
- 7,062
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
Yeah - we will do.
The current isn't exactly a version yet. He just posted it so that people could see the files at the moment - it still has alot to go before being ready for versioningJake Arkinstall
"Sometimes you don't need to reinvent the wheel;
Sometimes its enough to make that wheel more rounded"-Molona
-
Sep 24, 2008, 11:30 #48
- Join Date
- Feb 2006
- Location
- Netherlands
- Posts
- 295
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Last edited by webaddictz; Sep 28, 2008 at 06:40. Reason: (some name confusion)
-
Sep 24, 2008, 11:37 #49
- Join Date
- May 2006
- Location
- Lancaster University, UK
- Posts
- 7,062
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
Cool - we will do after this next stage then.
We're just making some, well, nothing better than kickass! form handling, so after this stage we'll go ahead with the versioning.Jake Arkinstall
"Sometimes you don't need to reinvent the wheel;
Sometimes its enough to make that wheel more rounded"-Molona
-
Sep 24, 2008, 13:00 #50
- Join Date
- Feb 2008
- Location
- Atlit, Israel
- Posts
- 470
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Good point. I'll fix that tomorrow, probably.
Anyway people - form validation is officially completed.
Story:
Me and Jake were chatting about how to go through with it... we came up with a pretty nice but vague idea - I went for a walk outside for an hour, came back with motivation... result:
PHP Code:if($request->isPostBack)
{
post('username')->min_chars(4)->max_chars(6);
post('email')->email();
post('author')->min_words(2);
post('anything')->match('^pattern$');
post('age')->ints();
if(post_valid())
echo 'yay';
else
echo 'boo';
// or
if(post('email')->email()->is_valid())
echo 'yay';
else
echo 'boo';
}
Build 5 is up in http://code.google.com/p/retrophpmvc/downloads/list - go ahead and beta test it.Learn about the new Retro Framework
Code PHP the way it was meant to be coded!
Bookmarks